使用IdentityServer4頒發令牌基本步驟如下:
- 在 Startup.Configure 方法調用 app.UseIdentityServer ,添加IdentityServer4到應用的 HTTP 請求處理管線. 使庫 服務 對OpenID連接和 類似使用 /connect/token的OAuth2端點的請求.
- 在Startup.ConfigureServices調用 services.AddIdentityServer配置 IdentityServer4 .
- 利用一下數據配置認證服務器:
-
- 用於簽名的證書(credentials).
- 用戶可能請求訪問的 Identity and API resources:
- API resources 包括 被保護的數據或者功能,用戶可以通過access token訪問. 例如需要授權的web API資源.
- Identity resources 包括信息(claims) ,用於在客戶端認證用戶. claims可能包括用戶名, email地址等.
- 將要請求token建立連接的客戶端.
- 用戶信息的存儲機制,如 ASP.NET Core Identity 或者其他方案.