duendesoftware/duende-skills/identity-security-hardening
Claude Code and agent skill by duendesoftware/duende-skills
- community
Checking that the SKILL.md file is still in the repository.
Security hardening for Duende IdentityServer deployments including signing key rotation, HTTPS enforcement, CORS configuration, CSP headers, rate limiting, token lifetime tuning, and security audit patterns.
Install
npx vskill@latest install duendesoftware/duende-skills/identity-security-hardeningSKILL.md
The same SKILL.md was published earlier as duendesoftware/duende-skills/identity-security-hardening.
Identity Security Hardening
When to Use This Skill
Use this skill when:
- Hardening a Duende IdentityServer deployment before promoting to production
- Configuring HTTPS, HSTS, and TLS requirements for the identity server host
- Evaluating or enforcing client secret policies (shared secrets vs. certificates vs.
private_key_jwt) - Setting PKCE requirements, restricting grant types, or locking down redirect URI validation
- Configuring Content Security Policy (CSP) and CORS for IdentityServer UI pages and endpoints
- Applying rate limiting to the token endpoint to protect against brute-force and enumeration attacks
- Tuning token lifetimes, enabling reference tokens, or implementing token replay detection
- Rotating signing keys or choosing between RS256 and ES256 algorithms
- Hardening session lifetimes, idle timeouts, and back-channel logout behavior
- Auditing an existing IdentityServer setup against OAuth 2.0 Security Best Current Practice (RFC 9700)
Core Principles
- HTTPS Everywhere — IdentityServer must only be reachable over HTTPS in production. Any HTTP request should be permanently redirected. HSTS with
includeSubDomainsandpreloadis the minimum bar. - Reduce Token Blast Radius — Short access token lifetimes, reference tokens for sensitive APIs, and audience validation ensure that a stolen token can do minimal damage.
- PKCE is Non-Negotiable — Every authorization code flow client must use PKCE, regardless of whether it is a public or confidential client.
RequirePkce = trueis the default; never disable it. - Asymmetric Client Authentication — Prefer certificate-based or
private_key_jwtclient authentication over shared secrets. Secrets that are never transmitted cannot be stolen in transit. - Strict Redirect URI Matching — Wildcards in redirect URIs are a critical attack surface. Every production URI must be fully qualified and must match exactly.
- Restrict Grant Types Per Client — Every client should only allow the grant types it actually uses. Disabling implicit flow and unused grants is one of the highest-impact, lowest-effort hardening steps.
- Defense in Depth — Combine transport security, token constraints, rate limiting, CSP, and CORS into a layered defense. No single control is sufficient.
Related Skills
identityserver-configuration— Server-side configuration of clients, resources, and signing keys that these hardening patterns build uponoauth-oidc-protocols— Protocol-level context for PKCE, PAR, DPoP, and grant type trade-offsaspnetcore-authentication— Applying OIDC authentication hardening in client applicationsaspnetcore-authorization— Enforcing authorization policies that consume the hardened tokens produced here
Docs: https://docs.duendesoftware.com/general/security-best-practices/
Sub-Documents
| Document | Description | When to Load | |
|---|---|---|---|
| docs/cors-csp.md | CORS ICorsPolicyService implementation and CSP middleware with header examples | CORS origins, Content-Security-Policy, X-Frame-Options, clickjacking, custom CORS policy | |
| docs/rate-limiting.md | ASP.NET Core AddRateLimiter configuration for token and authorization endpoints | Rate limiting, brute force, 429, sliding window, fixed window, token endpoint protection | |
| docs/session-hardening.md | Server-side sessions, cookie lifetime configuration, back-channel logout client setup | Session security, CookieSlidingExpiration, BackChannelLogoutUri, session fixation, inactivity |
Pattern 1: Transport Security — HTTPS, HSTS, and TLS
IdentityServer handles credentials and tokens. Every byte must travel over TLS. ASP.NET Core provides the pipeline middleware to enforce this.
Configure HSTS options in Program.cs before Build():
Behind a Reverse Proxy
When IdentityServer sits behind a load balancer or reverse proxy that terminates TLS, the inner request arrives as HTTP. Configure ForwardedHeaders so IdentityServer sees the correct scheme:
Important: WithoutForwardedHeaders, IdentityServer publishes anhttp://issuer URI in the discovery document, causing token validation failures in every downstream API.
Kestrel TLS Configuration
For direct Kestrel hosting (no reverse proxy), configure TLS explicitly:
Pattern 2: Signing Key Security — Algorithm Selection and Rotation
Signing keys are the root of trust for every token IdentityServer issues. The default RS256 algorithm is broadly compatible. ES256 (ECDSA) offers smaller tokens and is appropriate for new deployments. Supported signing algorithm families are RS (RSA PKCS#1), PS (RSA-PSS), and ES (ECDSA).
Rotation overlap rule: Always publish a new public key before using it to sign tokens, and keep a retired public key available until all tokens signed with it have expired. Consumers must be able to fetch the key (via JWKS) both before it starts signing and after it stops. Automatic Key Management handles this overlap automatically; manual key managers must do phased rotation (below).
Automatic Key Management (Recommended)
Key Storage — ASP.NET Data Protection
Automatic key management encrypts signing keys at rest using ASP.NET Data Protection. Configure Data Protection to use durable, shared storage. See ASP.NET Core Data Protection for complete configuration guidance.
v8 licensing note: On IdentityServer v8, Automatic Key Management, Server-Side Sessions, and SAML throw at startup when a license is present but lacks the entitlement (other licensed features only log a warning). Run lower environments with the production license key so entitlement gaps surface before production. Also note the v8 license key is a signed JWT with akidheader and fails on v7/BFF runtimes withIDX10503. See ASP.NET Core Data Protection for complete configuration guidance.
Warning: Never store Data Protection keys on ephemeral storage (e.g., container local disk). If keys are lost, all encrypted data (persisted grants, cookies, server-side sessions) becomes unreadable.
Manual Key Rotation (Three-Phase Process)
When using static keys, never swap them in a single deployment. Use a phased rotation to avoid breaking in-flight token validation:
Pattern 3: Token Constraints — Lifetimes, Reference Tokens, and Audience Validation
Token constraints limit the damage from token compromise and ensure tokens are only usable at their intended audience.
Token Lifetime Tuning
Reference Tokens
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/identity-security-hardening/SKILL.md
Popularity
- 7-day trend score
- 0
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/identity-security-hardening)