0

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;
                    }
                }

            });
        }
asdfgAt
  • 5
  • 3
  • actually why you want to use startup.cs just do authorization upon user input so if user click on fist one goes to first controller and visa versa so what is your question really? i dont get it please show more code – Alireza Madad Jun 15 '20 at 22:23
  • @AlirezaMadad, i edited my answer with the code i have on *ConfigureKeyCloak*. – asdfgAt Jun 16 '20 at 07:56
  • https://stackoverflow.com/questions/54260837/multiple-authentication-methods-in-asp-net-core-2-2 – Alireza Madad Jun 17 '20 at 04:44
  • in that answer you have two schema s I know it does not do that on click of button but simply you can authorize one with one schema an other button with another schema – Alireza Madad Jun 17 '20 at 04:45
  • please let me know if this was any help thank you – Alireza Madad Jun 17 '20 at 04:45

0 Answers0