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

            });
        }
5
  • 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 Commented Jun 15, 2020 at 22:23
  • @AlirezaMadad, i edited my answer with the code i have on ConfigureKeyCloak. Commented Jun 16, 2020 at 7:56
  • stackoverflow.com/questions/54260837/… Commented Jun 17, 2020 at 4: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 Commented Jun 17, 2020 at 4:45
  • please let me know if this was any help thank you Commented Jun 17, 2020 at 4:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.