12 Answer(s)
-
0
- You don’t “reuse Project B’s auth service” by referencing code. In ABP, the correct approach is: Project B runs as a dedicated AuthServer (OpenIddict/OIDC), and Project A becomes an OIDC client that redirects users to Project B to sign-in and receives tokens.
1) Make Project B the Auth Server (central)
- Ensure Project B has an
*.AuthServer(or equivalent host) running and reachable, e.g.https://auth.mycompany.com
- Make sure Project B issues tokens for the scopes/audiences that Project A will need (at minimum:
openid,profile,email,roles, plus your API scope if A will call B’s APIs).
2) Register Project A as a client in Project B (OpenIddict Application)
Project A must exist as an OpenIddict application in Project B (client_id/client_secret + redirect URIs).
Practical ABP way:
- Use ABP OpenIddict “Application Management” to create an application for Project A (client).
- Configure:
- ClientId: e.g.
ProjectA_Blazor - RedirectUri:
https://project-a-host/signin-oidc - PostLogoutRedirectUri:
https://project-a-host/signout-callback-oidc - Grant type:
authorization_code(with PKCE recommended) - Scopes:
openid profile email roles(+ API scopes you need)
- ClientId: e.g.
3) Configure Project A (Blazor Web App) to use Project B as Authority
In Project A
appsettings.json:"AuthServer": { "Authority": "https://auth.mycompany.com", "RequireHttpsMetadata": "true", "ClientId": "ProjectA_Blazor", "ClientSecret": "YOUR_CLIENT_SECRET" }Then in Project A authentication configuration (Program.cs / Module), set OpenId Connect to point to Project B (
Authority = AuthServer:Authority) and ensure the redirect URI path matches/signin-oidc.4) (Optional) If Project A must call Project B’s HttpApi
- Use the access token issued by Project B and call Project B’s API with
Bearer {access_token}. - If Project A is also ABP and you want typed/dynamic proxies, use ABP’s HttpApi.Client approach (create/consume an API client package or add
HttpApi.Clientproject reference pattern).
Sources
- https://abp.io/docs/latest/suite/solution-structure
- https://abp.io/docs/latest/modules/openiddict#application-management
- https://abp.io/support/questions/4849
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
现在我有2个项目A,B 项目A: BLAZOR WEB APP / tired,ms sql 项目B: BLAZOR WEB APP / tired,ms sql
A和B都有一个authserver项目
这种情况下你可以创建一个独立的authserver项目, 然后使用它作为共用,并移除AB中的authserver
Openiddict支持这种情况. 只需要修改application的重定向url或者添加新的客户端就可以
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)