Skip to content

Commit ae47e33

Browse files
fix(redirect): [PM-30810] Https Redirection for Cloud Users - Addressed reviewer feedback.
1 parent d7431f4 commit ae47e33

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/Core/Auth/Identity/TokenProviders/DuoUniversalTokenService.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ private static bool IsBitwardenCloudHost(string host)
166166
}
167167

168168
var normalizedHost = host.ToLowerInvariant();
169-
return normalizedHost.EndsWith("bitwarden.com") ||
170-
normalizedHost.EndsWith("bitwarden.eu") ||
171-
normalizedHost.EndsWith("bitwarden.pw");
169+
return Constants.BitwardenCloudDomains.Any(d => normalizedHost.EndsWith(d));
172170
}
173171

174172
private static DuoDeeplinkScheme? GetDeeplinkSchemeOverride(HttpContext httpContext)

src/Core/Constants.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public static class Constants
3333
public const string SSHKeyCipherMinimumVersion = "2024.12.0";
3434
public const string DenyLegacyUserMinimumVersion = "2025.6.0";
3535

36+
/// <summary>
37+
/// Domain suffixes for Bitwarden cloud-hosted environments.
38+
/// </summary>
39+
public static readonly string[] BitwardenCloudDomains = ["bitwarden.com", "bitwarden.eu", "bitwarden.pw"];
40+
3641
/// <summary>
3742
/// Used by IdentityServer to identify our own provider.
3843
/// </summary>

src/Identity/IdentityServer/ApiClient.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// FIXME: Update this file to be null safe and then delete the line below
22
#nullable disable
33

4+
using Bit.Core;
45
using Bit.Core.Settings;
56
using Bit.Identity.IdentityServer.RequestValidators;
67
using Duende.IdentityServer.Models;
@@ -82,12 +83,9 @@ public ApiClient(
8283
}
8384
else if (id == "mobile")
8485
{
85-
RedirectUris = new[] {
86-
"bitwarden://sso-callback",
87-
"https://bitwarden.com/sso-callback",
88-
"https://bitwarden.eu/sso-callback",
89-
"https://bitwarden.pw/sso-callback",
90-
};
86+
RedirectUris = new[] { "bitwarden://sso-callback" }
87+
.Concat(Constants.BitwardenCloudDomains.Select(d => $"https://{d}/sso-callback"))
88+
.ToArray();
9189
PostLogoutRedirectUris = new[] { "bitwarden://logged-out" };
9290
}
9391

0 commit comments

Comments
 (0)