Startup¶
IdentityServer is a combination of middleware and services. All configuration is done in your startup class.
Configuring services¶
You add the IdentityServer services to the DI system by calling:
public void ConfigureServices(IServiceCollection services)
{
var builder = services.AddIdentityServer();
}
Optionally you can pass in options into this call. See here for details on options.
This will return you a builder object that in turn has a number of convenience methods to wire up additional services.
Key material
AddSigningCredentialAdds a signing key service that provides the specified key material to the various token creation/validation services. You can pass in either an
X509Certificate2, aSigningCredentialor a reference to a certificate from the certificate store.
AddTemporarySigningCredentialCreates temporary key material at startup time. This is for dev only scenarios when you don’t have a certificate to use.
AddValidationKeysAdds 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.
In-Memory/Test stores
AddInMemoryClientsAddInMemoryIdentityResourcesAddInMemoryApiResourcesAddTestUsers
Additional services
AddExtensionGrantValidatorAddSecretParserAddSecretValidatorAddResourceOwnerValidatorAddProfileServiceAddAuthorizeInteractionResponseGeneratorAddCustomAuthorizeRequestValidatorAddCustomTokenRequestValidator
Caching
AddClientStoreCacheAddResourceStoreCache
Configuring the pipeline¶
You need to add IdentityServer to the pipeline by calling:
public void Configure(IApplicationBuilder app)
{
app.UseIdentityServer();
}
Be aware that order matters in the pipeline. You want to add IdentitySever e.g. before the UI framework that implementes the login screen etc.