diff --git a/DysonNetwork.Pass/Auth/OpenId/GoogleOidcService.cs b/DysonNetwork.Pass/Auth/OpenId/GoogleOidcService.cs index 4cb39c7..83a7d58 100644 --- a/DysonNetwork.Pass/Auth/OpenId/GoogleOidcService.cs +++ b/DysonNetwork.Pass/Auth/OpenId/GoogleOidcService.cs @@ -29,15 +29,14 @@ public class GoogleOidcService( throw new InvalidOperationException("Authorization endpoint not found in discovery document"); } - var queryParams = new Dictionary - { - { "client_id", config.ClientId }, - { "redirect_uri", config.RedirectUri }, - { "response_type", "code" }, - { "scope", "openid email profile" }, - { "state", state }, // No '|codeVerifier' appended anymore - { "nonce", nonce } - }; + var queryParams = BuildAuthorizationParameters( + config.ClientId, + config.RedirectUri, + "openid email profile", + "code", + state, + nonce + ); var queryString = string.Join("&", queryParams.Select(p => $"{p.Key}={Uri.EscapeDataString(p.Value)}")); return $"{discoveryDocument.AuthorizationEndpoint}?{queryString}"; @@ -130,4 +129,4 @@ public class GoogleOidcService( return ValidateAndExtractIdToken(idToken, validationParameters); } -} \ No newline at end of file +} diff --git a/DysonNetwork.Pass/Auth/OpenId/OidcService.cs b/DysonNetwork.Pass/Auth/OpenId/OidcService.cs index 25545e1..2824551 100644 --- a/DysonNetwork.Pass/Auth/OpenId/OidcService.cs +++ b/DysonNetwork.Pass/Auth/OpenId/OidcService.cs @@ -43,6 +43,29 @@ public abstract class OidcService( /// public abstract string GetAuthorizationUrl(string state, string nonce); + /// + /// Builds common authorization URL query parameters + /// + protected Dictionary BuildAuthorizationParameters(string clientId, string redirectUri, string scope, string responseType, string state, string nonce, string? responseMode = null) + { + var parameters = new Dictionary + { + ["client_id"] = clientId, + ["redirect_uri"] = redirectUri, + ["response_type"] = responseType, + ["scope"] = scope, + ["state"] = state, + ["nonce"] = nonce + }; + + if (!string.IsNullOrEmpty(responseMode)) + { + parameters["response_mode"] = responseMode; + } + + return parameters; + } + /// /// Process the callback from the OIDC provider ///