Hi,
I am currently working on an ASP.NET Zero-based solution that includes a primary project named Web.Host. This project is successfully utilizing JWT-based authentication along with social login providers (e.g., Facebook, Google) configured through ABP modules.
I am attempting to add an additional API project named Web.Reports to the solution. The goal is to have Web.Reports use the same authentication mechanism as Web.Host, enabling the frontend to authenticate once and access endpoints from both Web.Host and Web.Reports seamlessly.
Best regards!
2 Answer(s)
-
0
Hi @[email protected],
I will review the code a bit more to provide the best solution.
-
0
Hi
@[email protected]
,Based on your setup, it's possible to reuse the same authentication mechanism across both
Web.Host
andWeb.Reports
without much customization. Since theTokenAuthController
is already in theWeb.Core
project, both APIs can leverage the same logic seamlessly.To achieve this, I recommend the following steps:
- Move the
AuthConfigurer
class fromWeb.Host
toWeb.Core
. This will allow bothWeb.Host
andWeb.Reports
to share the same authentication configuration without duplicating code. - In the
Startup.cs
of yourWeb.Reports
project, ensure that the authentication settings mirror those ofWeb.Host
. Specifically, copy over the configurations related to JWT authentication, authorization policies, and any other relevant middleware.
Once this setup is complete, the same token should work seamlessly across both APIs, allowing your frontend to authenticate once and access endpoints from both projects without issues.
- Move the