duendesoftware/duende-skills/identityserver-deployment

Claude Code and agent skill by duendesoftware/duende-skills

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Guide for deploying Duende IdentityServer to production, covering reverse proxy configuration, data protection, health checks, distributed caching, multi-instance deployment, OpenTelemetry integration, logging, and common deployment pitfalls.

Install

npx vskill@latest install duendesoftware/duende-skills/identityserver-deployment

SKILL.md

The same SKILL.md was published earlier as duendesoftware/duende-skills/identityserver-deployment.

IdentityServer Deployment, Proxies, and Production Readiness

When to Use This Skill

  • Deploying IdentityServer behind a reverse proxy or load balancer
  • Configuring ASP.NET Core Data Protection for production persistence
  • Implementing health checks for monitoring IdentityServer instances
  • Setting up distributed caching for multi-instance deployments
  • Configuring OpenTelemetry for metrics, traces, and logs
  • Troubleshooting common deployment issues (HTTPS downgrade, cookie problems, key rotation failures)
  • Understanding the difference between Data Protection keys and IdentityServer signing keys
  • Setting up logging and events for production monitoring

Docs: https://docs.duendesoftware.com/identityserver/deployment

Deployment Architecture

IdentityServer is ASP.NET Core middleware. It can be hosted with the same diversity of technology as any ASP.NET Core application:

  • Hosting: On-premises, cloud (Azure, AWS, GCP), containers, Kubernetes
  • Web servers: Kestrel, IIS, Nginx, Apache
  • Artifacts: Files, containers (no Dockerfile needed with dotnet publish /t:PublishContainer)
  • Scaling: Horizontal with load balancers; requires shared state for multi-instance

Reverse Proxy and Load Balancer Configuration

The Problem

When IdentityServer runs behind a proxy that terminates TLS or changes the originating IP, the middleware sees incorrect request information. This causes:

  • HTTPS requests downgraded to HTTP
  • HTTP issuer published in .well-known/openid-configuration instead of HTTPS
  • Incorrect host names in discovery document or redirects
  • Cookies missing the Secure attribute (breaks SameSite behavior)
Solution: ForwardedHeaders Middleware

Most proxies set X-Forwarded-For and X-Forwarded-Proto headers. Configure ASP.NET Core to read them.

Option 1: Environment Variable (Simplest)

Set ASPNETCORE_FORWARDEDHEADERS_ENABLED=true. This automatically adds the middleware and accepts forwarded headers from any single proxy. Best for cloud-hosted environments and Kubernetes.

Option 2: Explicit Configuration (More Control)
csharp
// Program.cs
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders = ForwardedHeaders.XForwardedHost |
ForwardedHeaders.XForwardedProto;
// Add the IP address of your known proxy
options.KnownProxies.Add(IPAddress.Parse("203.0.113.42"));
// Or use a network range
// var network = new IPNetwork(IPAddress.Parse("198.51.100.0"), 24);
// options.KnownNetworks.Add(network);
// Number of proxies in front of the app
options.ForwardLimit = 1;
});

Important: The ForwardedHeaders middleware must run early in the pipeline, before IdentityServer middleware and ASP.NET authentication middleware.

Default KnownNetworks

By default, KnownNetworks and KnownProxies support localhost (127.0.0.1/8 and ::1). This is useful for local development or when the proxy and .NET host are on the same machine. In production, configure the actual proxy addresses.

ASP.NET Core Data Protection

When answering Data Protection questions, explicitly cite the general documentation (<https://docs.duendesoftware.com/general/data-protection/>) and state that Data Protection is a cross-cutting concern for all Duende SDKs (IdentityServer, BFF, etc.).
Cross-cutting concern: Data protection is critical for all Duende products — both IdentityServer and BFF. See ASP.NET Core Data Protection for comprehensive guidance covering all Duende SDKs.
Why It Matters

Data Protection is critical for IdentityServer. It encrypts and signs sensitive data including:

  • Signing keys at rest (when automatic key management is used)
  • Persisted grants at rest
  • Server-side session data at rest
  • State parameters for external OIDC providers
  • UI message payloads (logout context, error context)
  • Authentication session cookies
  • Anti-forgery tokens
Production Configuration
csharp
// Program.cs
builder.Services.AddDataProtection()
// Choose a persistence method
.PersistKeysToFoo() // PersistKeysToFileSystem, PersistKeysToDbContext,
// PersistKeysToAzureBlobStorage, PersistKeysToAWSSystemsManager,
// PersistKeysToStackExchangeRedis
// Choose a key protection method
.ProtectKeysWithBar() // ProtectKeysWithCertificate, ProtectKeysWithAzureKeyVault
// Set explicit application name
.SetApplicationName("My.IdentityServer");
Critical Rules
  1. Always persist keys to durable storage using a .PersistKeysTo...() method
  2. Ensure the storage itself is durable — e.g., if using Redis, configure Redis persistence (RDB/AOF)
  3. Always set an explicit application name with .SetApplicationName() to prevent key isolation issues
  4. Share keys across all load-balanced instances
  5. Consider a key escrow sink — for backup/restore of corrupted data protection keys, configure an IXmlEncryptor-based escrow
Data Protection Keys vs Signing Keys
AspectData Protection KeysIdentityServer Signing Keys
PurposeEncrypt/sign sensitive data at rest and in cookiesSign JWT tokens (id_tokens, access tokens)
CryptographySymmetric (private key)Asymmetric (public/private key pair)
VisibilityInternal to the applicationPublic keys published via discovery/JWKS
Managed byASP.NET Core frameworkIdentityServer (automatic key management)
StorageConfigured via .PersistKeysTo...()File system (default), EF operational store, or custom ISigningKeyStore

Both are critical secrets. Losing either causes failures.

Common Data Protection Problems
ProblemSymptomSolution
No shared keys in load-balanced environmentCryptographicException: key not found in key ringConfigure shared key persistence
Keys generated in dev included in buildKeys from wrong environment can't be read in productionExclude ~/keys directory from source control and builds
Application name mismatchKeys from one deployment can't be read by anotherSet explicit SetApplicationName() consistently
IIS lacking permissionsEphemeral keys generated every restartFollow Microsoft's IIS Data Protection configuration
.NET 6 path normalization changeKeys break between .NET versionsAlways set explicit application name (reverted in .NET 7+)
Symptoms of Data Protection Failure
  • CryptographicException in logs
  • Error messages like "Error unprotecting key with kid {Signing Key ID}"
  • "The key {Data Protection Key ID} was not found in the key ring"
  • Automatic signing key management fails silently

IdentityServer Data Stores for Multi-Instance

Configuration Data

For multi-instance deployments, configuration data must be shared:

ScenarioRecommendation
Rarely changing configurationIn-memory stores loaded from config files (with redeploy for changes)
Dynamic configuration (SaaS)Database via EF Core stores or custom stores
Operational Data

Operational data must always be shared in multi-instance deployments:

  • Authorization codes, tokens, consent — via persisted grant store
  • Signing keys — via ISigningKeyStore (EF operational store or custom)
  • Server-side sessions — via IServerSideSessionStore

Use Entity Framework Core or a persistent cache like Redis.

High Availability and Multi-Region
  • Keep the IdentityServer runtime stateless; runtime state (grants, consent, automatic signing keys, sessions) lives in external stores. In-memory config is fine if every instance runs the same build.
  • Configuration data (clients/resources) tolerates delayed replication, but disabling a client or rotating a secret only takes effect once caches/replicas catch up. Operational data must be visible to every instance almost immediately, or codes/refresh tokens fail with invalid_grant.
  • Consistent issuer: iss is derived from the request host by default. Every instance/region must resolve the same issuer for a given request (same public host name and path base from the proxy; with a single issuer you may fix IssuerUri). With Multi-Issuer or Spaces the issuer legitimately varies per host/space, but must still resolve identically on every instance.
  • Share signing keys (shared key store) and Data Protection keys (with the same explicit application name) across all nodes/regions; synchronize clocks.
  • Active-active needs: consistent issuer, operational store visibility across regions, shared signing + DP keys, synchronized clocks. If synchronous consistency across regions isn't achievable, prefer active-passive/regional failover with defined RPO/RTO over silently accepting eventual consistency for operational data.
  • User accounts live outside IdentityServer's stores; plan their replication separately.

Distributed Caching

Some optional features require ASP.NET Core's IDistributedCache:

FeatureWhy It Needs Distributed Cache
OIDC state data formatterStores external provider state server-side instead of in URL
JWT replay cachePrevents JWT client credentials replay
Device flow throttlingRate-limits polling across instances
Authorization parameter storeStores PAR request data

Configure a distributed cache for multi-instance deployments:

csharp
// Program.cs — Example using Redis
builder.Services.AddStackExchangeRedisCache(options =>
{
options.Configuration = "localhost:6379";
});

Health Checks

Use ASP.NET Core health checks so load balancers/orchestrators can tell whether IdentityServer is healthy. The docs no longer recommend custom IHealthCheck classes that invoke the discovery/JWKS endpoint handlers; use a liveness probe (middleware is up, no dependency checks) plus a readiness probe (tagged dependency checks).

Liveness
csharp
// Program.cs
builder.Services.AddHealthChecks();
var app = builder.Build();
app.MapHealthChecks("/health/live");
Liveness + Readiness (database dependencies)
csharp
// Program.cs
builder.Services.AddHealthChecks()
.AddDbContextCheck<ConfigurationDbContext>(tags: ["db", "ready"])
.AddDbContextCheck<PersistedGrantDbContext>(tags: ["db", "ready"]);
app.MapHealthChecks("/health/live", new() { Predicate = _ => false }); // runs no checks: only proves the pipeline responds
app.MapHealthChecks("/health/ready", new() { Predicate = x => x.Tags.Contains("ready") });

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
9
Repository forks
3
7-day trend score
0

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/duendesoftware/duende-skills/identityserver-deployment/badge)](https://verified-skill.com/skills/duendesoftware/duende-skills/identityserver-deployment)

Something wrong with this skill or its page? Tell us.