♻️ Refactor OpenID: Phase 3: Async Flow Modernization

- Added async GetAuthorizationUrlAsync() methods to all OIDC providers
- Updated base OidcService with abstract async contract and backward-compatible sync wrapper
- Modified OidcController to use async authorization URL generation
- Removed sync blocks using .GetAwaiter().GetResult() in Google provider
- Maintained backward compatibility with existing sync method calls
- Eliminated thread blocking and improved async flow throughout auth pipeline
- Enhanced scalability by allowing non-blocking async authorization URL generation
This commit is contained in:
2025-11-02 14:58:23 +08:00
parent 74a9ca98ad
commit b9edf51f05
8 changed files with 81 additions and 13 deletions

View File

@@ -42,9 +42,17 @@ public abstract class OidcService(
protected abstract string ConfigSectionName { get; }
/// <summary>
/// Gets the authorization URL for initiating the authentication flow
/// Gets the authorization URL for initiating the authentication flow (async)
/// </summary>
public abstract string GetAuthorizationUrl(string state, string nonce);
public abstract Task<string> GetAuthorizationUrlAsync(string state, string nonce);
/// <summary>
/// Gets the authorization URL for initiating the authentication flow (sync for backward compatibility)
/// </summary>
public virtual string GetAuthorizationUrl(string state, string nonce)
{
return GetAuthorizationUrlAsync(state, nonce).GetAwaiter().GetResult();
}
/// <summary>
/// Builds common authorization URL query parameters