I have a login page that I need to have two authentication methods. A normal login, using the ASP.NET MVC controllers and sessions and other that uses the local key cloak with a shared database that I can retrieve the user and the data from there and then authenticate him in the normal database.
So my Startup.cs
is this:
public void Configuration(IAppBuilder app)
{
ConfigureNormalAuth(app);
ConfigureKeyCloak(app);
}
For the ConfigureKeyCloak
method I'm using the UseOpenIdConnectAuthentication
.
My question is, how can I edit my Startup.cs
to manage if a user clicks on "Entrar" he does the normal ASP.NET MVC login, if he clicks in "Key Cloak" he goes to a different page to login in a shared database.
Thanks in advance
EDIT
This is my code for ConfigureKeyCloak:
public void ConfigureKeyCloak(IAppBuilder app)
{
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap = new Dictionary<string, string>();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
ClientId = clientid,
Authority = url,
RedirectUri = redirect,
PostLogoutRedirectUri = redirect,
ClientSecret = "20a0b258-b908-4ba4-846b-2b23a6c4a009",
SignInAsAuthenticationType = "Cookies",
RequireHttpsMetadata = false,
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthorizationCodeReceived = async (context) =>
{
string authorizationCode = context.Code;
}
}
});
}