duendesoftware/duende-skills/identityserver-deployment
Claude Code and agent skill by duendesoftware/duende-skills
- community
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-deploymentSKILL.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-configurationinstead of HTTPS - Incorrect host names in discovery document or redirects
- Cookies missing the
Secureattribute (breaksSameSitebehavior)
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)
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
Critical Rules
- Always persist keys to durable storage using a
.PersistKeysTo...()method - Ensure the storage itself is durable — e.g., if using Redis, configure Redis persistence (RDB/AOF)
- Always set an explicit application name with
.SetApplicationName()to prevent key isolation issues - Share keys across all load-balanced instances
- Consider a key escrow sink — for backup/restore of corrupted data protection keys, configure an
IXmlEncryptor-based escrow
Data Protection Keys vs Signing Keys
| Aspect | Data Protection Keys | IdentityServer Signing Keys | |
|---|---|---|---|
| Purpose | Encrypt/sign sensitive data at rest and in cookies | Sign JWT tokens (id_tokens, access tokens) | |
| Cryptography | Symmetric (private key) | Asymmetric (public/private key pair) | |
| Visibility | Internal to the application | Public keys published via discovery/JWKS | |
| Managed by | ASP.NET Core framework | IdentityServer (automatic key management) | |
| Storage | Configured via .PersistKeysTo...() | File system (default), EF operational store, or custom ISigningKeyStore |
Both are critical secrets. Losing either causes failures.
Common Data Protection Problems
| Problem | Symptom | Solution | |
|---|---|---|---|
| No shared keys in load-balanced environment | CryptographicException: key not found in key ring | Configure shared key persistence | |
| Keys generated in dev included in build | Keys from wrong environment can't be read in production | Exclude ~/keys directory from source control and builds | |
| Application name mismatch | Keys from one deployment can't be read by another | Set explicit SetApplicationName() consistently | |
| IIS lacking permissions | Ephemeral keys generated every restart | Follow Microsoft's IIS Data Protection configuration | |
| .NET 6 path normalization change | Keys break between .NET versions | Always set explicit application name (reverted in .NET 7+) |
Symptoms of Data Protection Failure
CryptographicExceptionin 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:
| Scenario | Recommendation | |
|---|---|---|
| Rarely changing configuration | In-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:
issis 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 fixIssuerUri). 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:
| Feature | Why It Needs Distributed Cache | |
|---|---|---|
| OIDC state data formatter | Stores external provider state server-side instead of in URL | |
| JWT replay cache | Prevents JWT client credentials replay | |
| Device flow throttling | Rate-limits polling across instances | |
| Authorization parameter store | Stores PAR request data |
Configure a distributed cache for multi-instance deployments:
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
Liveness + Readiness (database dependencies)
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
- SKILL.md in the repositoryCheckingskills/identityserver-deployment/SKILL.md
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
[](https://verified-skill.com/skills/duendesoftware/duende-skills/identityserver-deployment)