abpframework / eShopOnAbp

Reference microservice solution built with the ABP Framework and .NET, runs on Kubernetes with Helm configuration, includes API Gateways, Angular and ASP.NET Core MVC applications, PostgreSQL and MongoDB databases
https://www.eShopOnAbp.com/
MIT License
694 stars 272 forks source link

MVC service with keycloak #209

Closed alihdev closed 7 months ago

alihdev commented 1 year ago

Hello,

We have added a new service, MVC, and everything is working fine and configured. However, we encountered an issue in the login index. How can we change it to Keycloak and save the token for the CurrentUser?

How can we authenticate user using Keycloak ?

image

Is there any speed solution?

gterdem commented 11 months ago

I can't say that i understand this problem fully.

On the main branch, it already uses Keycloak and authenticates against the Keycloak server. Hence the CurrentUser is populated based on it. So, the user is already authenticated against the Keycloak.

Sorry, what do I miss?

alihdev commented 11 months ago

Hi, We have added a new MVC service. When we click on the login button (in index.cshtml),

 <a abp-button="Primary" href="~/Account/Login"><i class="fa fa-sign-in"></i> @L["Login"]</a>

this error occurs.

image

The account controller:

image

After we add

[DependsOn(
   ...
    typeof(AbpAccountHttpApiClientModule),
    typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule),
    typeof(AbpAccountWebOpenIddictModule)
)]

this error occurs.

image

We need the steps to configure authorization and authentication with Keycloak.

gterdem commented 7 months ago

The authorization and authentication sample is the PublicWeb application itself. Please check https://github.com/abpframework/eShopOnAbp/blob/main/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs and the keycloak data seeding.

Closing the issue, re-open if you still have problems.