-
-
Save justintoth/4f5cc4238d7a942369aef12209769004 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private readonly OpenIdConnectPostConfigureOptions _oidcPostConfigureOptions; | |
private readonly IOptionsMonitorCache<OpenIdConnectOptions> _oidcOptionsCache; | |
private readonly OAuthPostConfigureOptions<OAuthOptions, OAuthHandler<OAuthOptions>> _oauthPostConfigureOptions; | |
private readonly IOptionsMonitorCache<OAuthOptions> _oauthOptionsCache; | |
public SsoController( | |
OpenIdConnectPostConfigureOptions oidcPostConfigureOptions, | |
IOptionsMonitorCache<OpenIdConnectOptions> oidcOptionsCache, | |
OAuthPostConfigureOptions<OAuthOptions, OAuthHandler<OAuthOptions>> oauthPostConfigureOptions, | |
IOptionsMonitorCache<OAuthOptions> oauthOptionsCache) | |
{ | |
_oidcPostConfigureOptions = oidcPostConfigureOptions; | |
_oidcOptionsCache = oidcOptionsCache; | |
_oauthPostConfigureOptions = oauthPostConfigureOptions; | |
_oauthOptionsCache = oauthOptionsCache; | |
} | |
[HttpPost("refresh-config/{ssoIdentityProviderId:int}")] | |
public IActionResult RefreshConfig(int ssoIdentityProviderId) | |
{ | |
var ssoIdentityProvider = SingleSignOnStore.Model.Instance.GetIdentityProvider(ssoIdentityProviderId); | |
if (ssoIdentityProvider == null) | |
return NotFound(); | |
switch (ssoIdentityProvider.SsoFlowType) | |
{ | |
case SsoFlowType.Oidc: | |
var oidcOptions = new OpenIdConnectOptions(); | |
StartupSsoExtensions.SetOidcOptions(ssoIdentityProvider, oidcOptions); | |
_oidcPostConfigureOptions.PostConfigure(ssoIdentityProvider.SsoCode, oidcOptions); | |
_oidcOptionsCache.TryRemove(ssoIdentityProvider.SsoCode); | |
_oidcOptionsCache.TryAdd(ssoIdentityProvider.SsoCode, oidcOptions); | |
break; | |
case SsoFlowType.OAuth2: | |
var oauth2Options = new OAuthOptions(); | |
StartupSsoExtensions.SetOAuth2Options(ssoIdentityProvider, oauth2Options); | |
_oauthPostConfigureOptions.PostConfigure(ssoIdentityProvider.SsoCode, oauth2Options); | |
_oauthOptionsCache.TryRemove(ssoIdentityProvider.SsoCode); | |
_oauthOptionsCache.TryAdd(ssoIdentityProvider.SsoCode, oauth2Options); | |
break; | |
/*case SsoFlowType.SamlNew: | |
var samlOptions = new OAuthOptions(); | |
StartupSsoExtensions.SetSamlOptions(ssoIdentityProvider, samlOptions); | |
_samlPostConfigureOptions.PostConfigure(ssoIdentityProvider.SsoCode, samlOptions); | |
break;*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment