Your identity server is just a standard ASP.NET Core application including the IdentityServer middleware. Read the official Microsoft documentation on publishing and deployment first (and especially the section about load balancers and proxies).
Typically you will design your IdentityServer deployment for high availability:
IdentityServer itself is stateless and does not require server affinity - but there is data that needs to be shared between the instances.
This typically includes:
- startup configuration, e.g. key material, external provider settings etc…
The way you store that data depends on your environment. In situations where configuration data rarely changes we recommend using the in-memory stores and code or configuration files.
In highly dynamic environments (e.g. Saas) we recommend using a database or configuration service to load configuration dynamically.
You can also build your own configuration stores by implementing
Another important piece of startup configuration is your key material, see here for more details on key material and cryptography.
For certain operations, IdentityServer needs a persistence store to keep state, this includes:
- issuing authorization codes
- issuing reference and refresh tokens
- storing consent
You can either use a traditional database for storing operational data, or use a cache with persistence features like Redis. The EF Core implementation mentioned above has also support for operational data.
You can also implement support for your own custom storage mechanism by implementing
IPersistedGrantStore - by default IdentityServer injects an in-memory version.
ASP.NET Core data protection¶
ASP.NET Core itself needs shared key material for protecting sensitive data like cookies, state strings etc. See the official docs here.
You can either re-use one of the above persistence store or use something simple like a shared file if possible.
ASP.NET Core distributed caching¶
Some components rely on ASP.NET Core distributed caching. In order to work in a multi server environment, this needs to be set up correctly. The official docs describe several options.
The following components rely on
services.AddOidcStateDataFormatterCache()configures the OpenIdConnect handlers to persist the state parameter into the server-side