【发布时间】:2021-08-17 02:15:19
【问题描述】:
我的应用程序是 Asp.Net 4.7.2 Framework MVC。我想注册三个 OWIN OIDC Auth 配置并能够从中进行选择。
OpenIdConnectAuthenticationOptions oidcOptions1 = new OpenIdConnectAuthenticationOptions
{
ClientId = _oktaMvcOptions.ClientId,
ClientSecret = _oktaMvcOptions.ClientSecret,
Authority = _issuer,
RedirectUri = _oktaMvcOptions.RedirectUri,
ResponseType = OpenIdConnectResponseType.Code,
RedeemCode = true,
Scope = scopeString,
PostLogoutRedirectUri = _oktaMvcOptions.PostLogoutRedirectUri,
TokenValidationParameters = tokenValidationParameters,
SecurityTokenValidator = new StrictSecurityTokenValidator(),
AuthenticationMode = (_oktaMvcOptions.LoginMode == LoginMode.SelfHosted) ? AuthenticationMode.Passive : AuthenticationMode.Active,
SaveTokens = true,
Notifications = new OpenIdConnectAuthenticationNotifications
{
RedirectToIdentityProvider = BeforeRedirectToIdentityProviderAsync,
SecurityTokenValidated = SecurityTokenValidatedAsync,
AuthenticationFailed = _oktaMvcOptions.AuthenticationFailed,
},
};
OpenIdConnectAuthenticationOptions oidcOptions2 = new OpenIdConnectAuthenticationOptions{...};
OpenIdConnectAuthenticationOptions oidcOptions3 = new OpenIdConnectAuthenticationOptions{...};
在 Startup.cs 中,配置如下所示:
public void Configuration(IAppBuilder app)
{
app.UseOpenIdConnectAuthentication(oidcOptions1);
app.UseOpenIdConnectAuthentication(oidcOptions2);
app.UseOpenIdConnectAuthentication(oidcOptions3);
}
它们都是 OpenIdConnect 类型。当我发起挑战时:
HttpContext.GetOwinContext().Authentication.Challenge();
如何告诉挑战使用 oidcOptions2 或 oidcOptions3?如何指定使用哪一个?
谢谢。
【问题讨论】:
标签: c# authentication model-view-controller owin openid-connect