Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Packages/Passport/Runtime/Scripts/Private/PassportImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ public async UniTask Init(string clientId, string environment, string redirectUr
string logoutRedirectUri, string? deeplink = null)
{
_redirectUri = redirectUri;
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
if (redirectUri.Contains(GetHostedLoginPageUrl(environment))) {
Uri uri = new Uri(redirectUri);
string redirectUriParam = uri.GetQueryParameter("redirect_uri");
_redirectUri = redirectUriParam;
}
#endif
_logoutRedirectUri = logoutRedirectUri;

#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
Expand Down Expand Up @@ -772,6 +779,19 @@ protected virtual async void Track(string eventName, bool? success = null, Dicti
{
await _analytics.Track(_communicationsManager, eventName, success, properties);
}

#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
/// <summary>
/// Gets the hosted login page URL for the specified environment.
/// This is used for Windows login redirect flow.
/// </summary>
public static string GetHostedLoginPageUrl(string environment)
{
return environment == Immutable.Passport.Model.Environment.DEVELOPMENT
? "https://auth.dev.immutable.com/im-logged-in"
: "https://auth.immutable.com/im-logged-in";
}
#endif
}

#if UNITY_ANDROID
Expand Down
12 changes: 10 additions & 2 deletions src/Packages/Passport/Runtime/Scripts/Public/Passport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ string logoutRedirectUri
)
{
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
ValidateWindowsProtocols(redirectUri, logoutRedirectUri);
ValidateWindowsProtocols(environment, redirectUri, logoutRedirectUri);
#endif

if (Instance == null)
Expand Down Expand Up @@ -705,8 +705,16 @@ private void DisposeAll()
/// Validates that custom protocols are used for Windows platforms instead of http/https.
/// Windows uses registry-based deep linking which requires custom protocols.
/// </summary>
private static void ValidateWindowsProtocols(string redirectUri, string logoutRedirectUri)
private static void ValidateWindowsProtocols(string environment, string redirectUri, string logoutRedirectUri)
{
// Allow the special hosted login page URL format for Windows login redirect
string hostedLoginPageUrl = PassportImpl.GetHostedLoginPageUrl(environment);

if (redirectUri.Contains(hostedLoginPageUrl))
{
return;
}

if (IsHttpProtocol(redirectUri))
{
throw new PassportException(
Expand Down
Loading