Keycloak integration with MVC ASP.NET Core what needs to be done?

2,149 views
Skip to first unread message

Praning James

unread,
Dec 9, 2022, 8:38:38 PM12/9/22
to Keycloak User
Hi,

I am trying to integrate Keycloack on the latest ASP.NET Core MVC 6.0,
i see that this package https://github.com/dylanplecki/KeycloakOwinAuthentication is no longer maintained and it is only for (non Core) ASP.NET MVC 4.5

so what i did is I google and i found some tutorials, but i cant seem to have it working and getting the isAuthenticated to always false, and not getting sesion or cookies passed after succesful login.
I have opened forums like this to no response:
https://stackoverflow.com/questions/74741584/integration-with-keycloak-isauthenticated-is-always-false-and-cookies-may-not-h

ok so here is my question,
After I set the services.OpenIDConnect parameters  and setting the [Authorize] in a controller (example in /privacy) when i access that link (http://localhost:13636/privacy) it redirects to the Keycloak login page which is correct, but after login page, 
i set it to redirect to https://localhost:13636/home.
upon returning at /home controller, User.Identity.IsAuthenticated is still false, Im not sure if authentication was passed, retain, or cookies were sent, etc.

Where do i go from here?
Is there something I need to do and handle in the redirection page to have my authentication successful?  like token, claim processing or what not?

What do I need to set in my keycloak admin dashboard?
i created the realm, users and roles and thats it, I havent setup anything other than that,
like i did not setup Token Exchange or Protocol Mappers. (As I dont have guide).

Anybody can help?
I just want my simple application,  a plain ASP.NET Core MVC 6 application built from scratch (new project) without any change but just the keycloak integration. 

I want this application to, pop-up/redirect the Keycloak login form when [Authorize] is set, and upon succesful login redirect to a page and recognize that the login occur and thats it.
Looks like I am realy missing a huge part of the process here and why my application is not authenticated after login.

Let me know what other information you guys need.


Pietro Braghieri

unread,
Jan 4, 2023, 11:14:14 AM1/4/23
to Keycloak User
Reply all
Reply to author
Forward
0 new messages