約定 簡稱 Id4。
Id4在.net core 中的使用符合.net core 的約定架構,即Services來注冊服務,middleware方式集成。
1. 配置服務
apache netbeans改中文?通過DI注入:
public void ConfigureServices(IServiceCollection services)
{var builder = services.AddIdentityServer();
}
也可以使用選項模式,配置更多的參數。
services.AddIdentityServer((ops) =>{ops.Endpoints.EnableDiscoveryEndpoint = true})
1. 2 Key material
- AddSigningCredential
添加簽名證書服務提供token的創建/驗證。 - AddTemporarySigningCredential
創建臨時簽名證書服務。用于DEV環境下沒有證書可用的時候。 - AddDeveloperSigningCredential
- AddValidationKeys
Adds keys for validating tokens. They will be used by the internal token validator and will show up in the discovery document. This is useful for key roll-over scenarios.
1. 3 In-Memory configuration stores
內存數據庫,存儲等。
- AddInMemoryClients
注冊內存環境的Client。 - AddInMemoryIdentityResources
注冊內存環境的IdentityResource 。 - AddInMemoryApiResources
定義內存環境中的Api資源。
1. 4 Test Stores
net core和net framework的區別,用于非生產環境下的開發。默認的quickstart UI下。
- AddTestUsers
1. 5 額外的服務
- AddExtensionGrantValidator
- AddSecretParser
- AddSecretValidator
- AddResourceOwnerValidator
- AddProfileService
- AddAuthorizeInteractionResponseGenerator
- AddCustomAuthorizeRequestValidator
- AddCustomTokenRequestValidator
1.6 緩存
- AddClientStoreCache
- AddResourceStoreCache
實現了 ICache接口。
2. 配置管道
public void Configure(IApplicationBuilder app)
{app.UseIdentityServer();
}
中間件的方式集成Id4.