sec: get links to the backend to initiate the receipt of provider data
This commit is contained in:
@ -97,20 +97,26 @@ public class OAuthService(ILogger<OAuthService> logger, Dictionary<OAuthProvider
|
||||
return userInfo?.MapToInternalUser();
|
||||
}
|
||||
|
||||
public (OAuthProvider Provider, Uri Redirect)[] GetAvailableProviders(HttpContext context, CookieOptionsParameters cookieOptions, string redirectUrl)
|
||||
{
|
||||
var redirectUri = "?client_id={0}" +
|
||||
"&response_type=code" +
|
||||
$"&redirect_uri={redirectUrl}" +
|
||||
"&scope={1}" +
|
||||
$"&state={new RequestContextInfo(context, cookieOptions).Fingerprint}_{{2}}";
|
||||
|
||||
return providers.Select(x => (x.Key, new Uri(ProviderData[x.Key].RedirectUrl.TrimEnd('/') +
|
||||
string.Format(redirectUri,
|
||||
x.Value.ClientId,
|
||||
ProviderData[x.Key].Scope,
|
||||
Enum.GetName(x.Key))))
|
||||
).ToArray();
|
||||
public Uri GetProviderRedirect(HttpContext context, CookieOptionsParameters cookieOptions, string redirectUri, OAuthProvider provider)
|
||||
{
|
||||
var providerData = providers[provider];
|
||||
|
||||
var redirectUrl = $"?client_id={providerData.ClientId}" +
|
||||
"&response_type=code" +
|
||||
$"&redirect_uri={redirectUri}" +
|
||||
$"&scope={ProviderData[provider].Scope}" +
|
||||
$"&state={new RequestContextInfo(context, cookieOptions).Fingerprint}_{Enum.GetName(provider)}";
|
||||
|
||||
|
||||
|
||||
return new Uri(ProviderData[provider].RedirectUrl + redirectUrl);
|
||||
}
|
||||
|
||||
public (OAuthProvider Provider, Uri Redirect)[] GetAvailableProviders(HttpContext context, string redirectUri)
|
||||
{
|
||||
return providers.Select(x => (x.Key, new Uri(redirectUri.TrimEnd('/') + "/?provider=" + (int)x.Key)))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public async Task<(OAuthProvider provider, OAuthUser User)> LoginOAuth(HttpContext context, CookieOptionsParameters cookieOptions, string redirectUrl, string code, string state, CancellationToken cancellation = default)
|
||||
|
Reference in New Issue
Block a user