♻️ Refactor OpenID: Phase 1: Code Consolidation optimizations
- Add BuildAuthorizationParameters() method to reduce authorization URL duplication - Update GoogleOidcService to use common parameter building method - Add missing using statements for AppDatabase and AuthService namespaces - Improve code reusability and eliminate 20+ lines of repeated authorization logic per provider
This commit is contained in:
@@ -29,15 +29,14 @@ public class GoogleOidcService(
|
||||
throw new InvalidOperationException("Authorization endpoint not found in discovery document");
|
||||
}
|
||||
|
||||
var queryParams = new Dictionary<string, string>
|
||||
{
|
||||
{ "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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user