♻️ 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:
@@ -43,6 +43,29 @@ public abstract class OidcService(
|
||||
/// </summary>
|
||||
public abstract string GetAuthorizationUrl(string state, string nonce);
|
||||
|
||||
/// <summary>
|
||||
/// Builds common authorization URL query parameters
|
||||
/// </summary>
|
||||
protected Dictionary<string, string> BuildAuthorizationParameters(string clientId, string redirectUri, string scope, string responseType, string state, string nonce, string? responseMode = null)
|
||||
{
|
||||
var parameters = new Dictionary<string, string>
|
||||
{
|
||||
["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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process the callback from the OIDC provider
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user