Reputation: 51
My application is Asp.Net 4.7.2 Framework MVC. I want to have three OWIN OIDC Auth configurations registered and be able to choose from them.
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{...};
In the Startup.cs, the Configuration looks something like this:
public void Configuration(IAppBuilder app)
{
app.UseOpenIdConnectAuthentication(oidcOptions1);
app.UseOpenIdConnectAuthentication(oidcOptions2);
app.UseOpenIdConnectAuthentication(oidcOptions3);
}
They are all OpenIdConnect types. When I call the challenge:
HttpContext.GetOwinContext().Authentication.Challenge();
How do I tell the challenge to use the oidcOptions2, or oidcOptions3? How can I specify which one to use?
Thanks.
Upvotes: 1
Views: 958
Reputation: 51
Never mind - pretty easy:
OpenIdConnectAuthenticationOptions oidcOptions1 = new OpenIdConnectAuthenticationOptions("first")
{
...
}
Then:
HttpContext.GetOwinContext().Authentication.Challenge("first");
Upvotes: 4