antosubash / blog-comments

MIT License
0 stars 0 forks source link

posts/migrating-identity-service-to-open-iddict-module #22

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Migrating Identity Service to OpenIddict Module

In this post we will see how to replace Identity server with OpenIddict in our microservice

https://blog.antosubash.com/posts/migrating-identity-service-to-open-iddict-module

eltinghana commented 1 year ago

great write up but I get this error when I run the angular app after implementing all the changes. Basic error="invalid_client", error_description="The 'client_secret' parameter required for this client application is missing.", error_uri="https://documentation.openiddict.com/errors/ID2054". The App keep reloading

eltinghana commented 1 year ago

great write up but I get this error when I run the angular app after implementing all the changes. Basic error="invalid_client", error_description="The 'client_secret' parameter required for this client application is missing.", error_uri="https://documentation.openiddict.com/errors/ID2054". The App keep reloading

I was able to resolve this. It has to o with my appsettings for the seeding of Clients. I provided a secret for the Web_App which wasn't suposed to be.

cbyare commented 1 year ago

Hi Anto, Thanks for this great tutorial , I encountered a problem when I create Tenant from Angular app ,identity service and administration service do not consume I have added the event handler classes for the tenant creation I am looking forward your help

antosubash commented 1 year ago

@cbyare what is the error? make sure the RabbitMq is working properly.

cbyare commented 1 year ago

No error in the runtime the applications are successfully running , only the problem is service discovery when I try to create tenant the seeding data for the admin user is not found the users, grant permissions table as well , RabbitMQ is running and also I see the services in the queue

antosubash commented 1 year ago

@cbyare put the break point in event publish and consume paths and see what is the problem. If the event is published and not received then mostly its a configuration issue with RabbitMQ.

eltinghana commented 1 year ago

Thanks for this write up. I am getting invalid token when accessing some of the end points. some work but others return invalid token. api/feature-management and api/permission-management

antosubash commented 1 year ago

@eltinghana can you share the full exception? No sure how to help with very little info.

eltinghana commented 1 year ago

@antosubash please find attached error in swagger

content-length: 0 date: Mon,23 Jan 2023 23:29:06 GMT server: Kestrel www-authenticate: Bearer error="invalid_token" x-correlation-id: 7758b47818854742815aa4880fea9dbe

and also below is the error in abp audit logs

/api/setting-management/emailing

[ { "code": "Volo.Authorization:010001", "message": "Authorization failed! Given policy has not granted.", "details": null, "data": {}, "validationErrors": null } ]

eltinghana commented 1 year ago

@antosubash I experience the same issue when I run your ab7 branch

FranklinNdlovu commented 1 year ago

great write up but I get this error when I run the angular app after implementing all the changes. Basic error="invalid_client", error_description="The 'client_secret' parameter required for this client application is missing.", error_uri="https://documentation.openiddict.com/errors/ID2054". The App keep reloading

I was able to resolve this. It has to o with my appsettings for the seeding of Clients. I provided a secret for the Web_App which wasn't suposed to be.

@eltinghana I'm experiencing the same error, may you add more detail on how you resolved this bug.

eltinghana commented 1 year ago

@FranklinNdlovu in the appsettings in the Shared.Migrator do not provide secret for the Web_App client. and after seeding cross check the db

{ "ClientId": "Tasky_App", "RootUrls": [ "http://localhost:4200", "https://app.tasky.antosubash.com" ], "Scopes": [ "AuthServer", "SaasService", "IdentityService", "AdministrationService" ], "GrantTypes": [ "authorization_code" ], "RedirectUris": [ "http://localhost:4200", "https://app.tasky.antosubash.com" ], "PostLogoutRedirectUris": [ "http://localhost:4200", "https://app.tasky.antosubash.com" ], "AllowedCorsOrigins": [ "http://localhost:4200", "https://app.tasky.antosubash.com" ] },

FranklinNdlovu commented 1 year ago

@eltinghana Thanks, worked like a charm.

TRB7 commented 1 year ago

Hi Anto Follow all steps but getting the error below at the end, tried to abp update and abp install-lib but still the same:

ComponentNotRegisteredException: The requested service 'Volo.Abp.AspNetCore.Mvc.UI.Theming.ITheme' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.

Any idea on how to sort this out ?

TRB7 commented 1 year ago

Found the solution, after hours of code refactoring, I noticed that I was missing dependency to AbpAspNetCoreMvcUiLeptonXLiteThemeModule, after I added it worked

vigneshkumar04 commented 1 year ago

Hi Subash,

In AddAbpOpenIdConnect when i try to login from angular , I can't able to login it shows the client application is not allowed to use the specific scope. I have project using abp commerical suite.

SooRaj-1994 commented 1 year ago

I want to express my gratitude for your invaluable blog on ABP Microservice Architecture. I have been a loyal reader of your blog for quite some time now, and it has greatly aided me in developing my application.

Recently, I encountered an issue while upgrading my application from version 5.2.2 to version 7.2.2, following your comprehensive guide. My application (Angular) employs the Resource Owner Password Flow for authentication purposes. Initially, everything seemed to be working smoothly after the upgrade. However, I started experiencing intermittent timeouts with certain APIs. Strangely, these APIs would function perfectly at times and then suddenly become unresponsive after a while. Additionally, I noticed that the Swagger client for the affected service is also unresponsive during these periods.

What perplexes me the most is that the application does not crash nor does it generate any error logs during these timeouts. As a result, I find myself unable to pinpoint the root cause of this issue. I have scrutinized my code and configuration thoroughly, but unfortunately, I haven't been able to identify any obvious misconfigurations or bugs.

Is it possible that there might be some misconfiguration or performance bottleneck in the Redis setup, causing these intermittent timeouts?

scurlick commented 5 months ago

Hi, I am having CORS policy issue when I try to login to a services swagger. I am not able to identify where the issue is. In the logs there this which seems to suggest the login is successful but there is some CORS missing

2024-01-25 06:54:28.960 +13:00 [INF] The authorization request was successfully validated. 2024-01-25 06:54:28.971 +13:00 [INF] Executing endpoint 'Volo.Abp.OpenIddict.Controllers.AuthorizeController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore)' 2024-01-25 06:54:28.971 +13:00 [INF] Route matched with {action = "Handle", controller = "Authorize", area = "", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] HandleAsync() on controller Volo.Abp.OpenIddict.Controllers.AuthorizeController (Volo.Abp.OpenIddict.AspNetCore). 2024-01-25 06:54:28.972 +13:00 [INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy 2024-01-25 06:54:28.974 +13:00 [INF] Executing action method Volo.Abp.OpenIddict.Controllers.AuthorizeController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore) - Validation state: "Valid" 2024-01-25 06:54:29.045 +13:00 [INF] Executed action method Volo.Abp.OpenIddict.Controllers.AuthorizeController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore), returned result Microsoft.AspNetCore.Mvc.SignInResult in 70.6325ms. 2024-01-25 06:54:29.047 +13:00 [INF] Executing SignInResult with authentication scheme (OpenIddict.Server.AspNetCore) and the following principal: System.Security.Claims.ClaimsPrincipal. 2024-01-25 06:54:29.086 +13:00 [INF] The authorization response was successfully returned to 'https://localhost:7007/swagger/oauth2-redirect.html' using the query response mode: { "code": "[redacted]", "state": "VGh1IEphbiAyNSAyMDI0IDA2OjU0OjI4IEdNVCsxMzAwIChOZXcgWmVhbGFuZCBEYXlsaWdodCBUaW1lKQ==", "iss": "https://localhost:7600/" }. 2024-01-25 06:54:29.087 +13:00 [INF] Executed action Volo.Abp.OpenIddict.Controllers.AuthorizeController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore) in 115.6167ms 2024-01-25 06:54:29.087 +13:00 [INF] Executed endpoint 'Volo.Abp.OpenIddict.Controllers.AuthorizeController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore)' 2024-01-25 06:54:29.090 +13:00 [INF] Request finished HTTP/2 GET https://localhost:7600/connect/authorize?response_type=code&client_id=Ordering_Swagger&redirect_uri=https%3A%2F%2Flocalhost%3A7007%2Fswagger%2Foauth2-redirect.html&scope=Ordering&state=VGh1IEphbiAyNSAyMDI0IDA2OjU0OjI4IEdNVCsxMzAwIChOZXcgWmVhbGFuZCBEYXlsaWdodCBUaW1lKQ%3D%3D - 302 0 null 234.1783ms 2024-01-25 06:54:29.108 +13:00 [INF] Request starting HTTP/2 OPTIONS https://localhost:7600/connect/token - null null 2024-01-25 06:54:29.109 +13:00 [INF] CORS policy execution failed. 2024-01-25 06:54:29.109 +13:00 [INF] Request origin https://localhost:7007 does not have permission to access the resource.

atifrd commented 2 weeks ago

Hi Subash, i have this exception on running authserver : An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.OpenIddict.AbpOpenIddictDomainModule, Volo.Abp.OpenIddict.Domain, Version=8.2.0.0, Culture=neutral, PublicKeyToken=null: An exception was thrown while activating Volo.Abp.OpenIddict.Tokens.TokenCleanupBackgroundWorker -> Volo.Abp.DistributedLocking.MedallionAbpDistributedLock.. See the inner exception for details.