duendesoftware/duende-skills/oauth-oidc-protocols
Claude Code and agent skill by duendesoftware/duende-skills
- community
Checking that the SKILL.md file is still in the repository.
OAuth 2.0 and OpenID Connect protocol fundamentals including authorization code flow with PKCE, client credentials, refresh tokens, discovery documents, JWKS, and token introspection. Protocol-level troubleshooting and compliance.
Install
npx vskill@latest install duendesoftware/duende-skills/oauth-oidc-protocolsSKILL.md
The same SKILL.md was published earlier as duendesoftware/duende-skills/oauth-oidc-protocols.
OAuth 2.0 & OpenID Connect Protocols
When to Use This Skill
Use this skill when:
- Choosing the correct OAuth 2.0 grant type for a scenario
- Debugging token exchange flows or redirect-based authentication
- Understanding what claims and headers appear in identity tokens vs access tokens
- Implementing or troubleshooting PKCE (Proof Key for Code Exchange)
- Working with discovery documents, JWKS endpoints, or token introspection
- Reviewing security properties of different protocol flows
- Implementing refresh token rotation or token revocation
Core Principles
- OAuth 2.0 is for Authorization, OIDC is for Authentication — OAuth alone does not tell you who the user is. OpenID Connect adds an identity layer (the ID token) on top of OAuth.
- Authorization Code + PKCE is the Universal Flow — Use it for web apps, SPAs (via BFF), native apps, and any interactive scenario. It replaced implicit flow.
- Tokens are Opaque to Clients — Clients should not parse access tokens. Only the resource server (API) validates access tokens. Clients use the ID token for authentication.
- Discovery Documents are the Source of Truth — Always resolve endpoints from
/.well-known/openid-configurationrather than hardcoding URLs. - Refresh Tokens Require Secure Storage — Refresh tokens are long-lived credentials. Rotate them on every use (
OneTimeOnly) and store them server-side.
Related Skills
identityserver-configuration— Server-side configuration of clients, resources, and scopesaspnetcore-authentication— Implementing OIDC authentication in ASP.NET Core appstoken-management— Automated token lifecycle with Duende.AccessTokenManagementidentity-security-hardening— Security hardening including DPoP, PAR, and FAPIduende-bff— Backend-for-Frontend pattern for SPAs
Docs: https://docs.duendesoftware.com/identityserver/fundamentals
Concept 1: The OAuth 2.0 / OIDC Mental Model
Roles
| Role | OAuth 2.0 Term | OIDC Term | Example | |
|---|---|---|---|---|
| User | Resource Owner | End-User | A person logging in | |
| Browser/App | Client | Relying Party (RP) | ASP.NET Core web app | |
| Token Server | Authorization Server | OpenID Provider (OP) | Duende IdentityServer | |
| API | Resource Server | — | ASP.NET Core Web API |
Tokens
| Token | Purpose | Who Consumes It | Format | |
|---|---|---|---|---|
| ID Token | Proves user identity | Client application | Always JWT | |
| Access Token | Authorizes API calls | Resource server (API) | JWT or reference | |
| Refresh Token | Obtains new access tokens | Client application | Opaque handle |
Critical Rule: Clients authenticate users with the ID token. Clients authorize API calls with the access token. Never use an access token to determine who a user is. Never send an ID token to an API.
Concept 2: Grant Types (Flows)
Authorization Code + PKCE (Recommended for All Interactive Scenarios)
The authorization code flow with PKCE is the recommended flow for all clients that involve a user. PKCE prevents authorization code interception attacks.
How it works:
- Client generates a random
code_verifierand its SHA256 hashcode_challenge - Client redirects user to the authorize endpoint with
code_challenge - User authenticates at IdentityServer and consents (if required)
- IdentityServer redirects back with an authorization
code - Client exchanges the
code+code_verifierat the token endpoint - IdentityServer verifies the verifier matches the original challenge
- IdentityServer returns ID token + access token (+ refresh token if
offline_accessscope)
When to use: Web applications, native apps, SPAs (via BFF pattern).
Client Credentials
For machine-to-machine communication with no user involvement.
When to use: Background services, daemons, server-to-server API calls.
Key difference: No user identity — the access token contains only client claims, not user claims.
Refresh Token Exchange
WithRefreshTokenUsage = OneTimeOnly, each refresh returns a new refresh token. The old one is invalidated. This enables refresh token rotation, a key security measure. Note: the default changed toReUsein IdentityServer v7.0 — setOneTimeOnlyexplicitly for rotation.
Deprecated / Discouraged Flows
| Flow | Status | Why | |
|---|---|---|---|
Implicit (token / id_token) | Deprecated | Tokens in URL fragments; no PKCE protection | |
| Resource Owner Password (ROPC) | Discouraged | Client handles credentials directly; no MFA support | |
| Hybrid | Replaced | Use Authorization Code + PKCE instead |
Concept 3: Discovery and JWKS
Discovery Document
Every OpenID Connect provider publishes a discovery document at /.well-known/openid-configuration. This JSON document advertises:
- Endpoint URLs (authorize, token, userinfo, introspection, revocation, end\_session)
- Supported grant types, scopes, claims, and response types
- Signing algorithms and JWKS URI
- Token endpoint authentication methods
Best Practice: Never hardcode endpoint URLs. Always resolve them from the discovery document. This ensures your application adapts to URL changes and load balancer configurations.
JWKS (JSON Web Key Set)
The JWKS endpoint (advertised via the jwks_uri field in the discovery document; in Duende IdentityServer this is /.well-known/openid-configuration/jwks) publishes the public keys used to verify token signatures. APIs and clients fetch this to validate JWTs.
Key rotation: When IdentityServer rotates signing keys, the new key appears in JWKS during the propagation period before it becomes the active signing key. Client libraries cache JWKS for 24 hours by default.
Concept 4: Token Anatomy
ID Token (JWT)
Key claims:
iss— Issuer (must match your IdentityServer URL)sub— Subject (unique user identifier)aud— Audience (must match the client ID)nonce— Replay protection (sent in authorize request, echoed in token)at_hash— Hash of the access token (binds the ID token to the access token)amr— Authentication methods used
Access Token (JWT)
Key claims:
aud— The API resource(s) this token is valid forclient_id— Which client requested this tokenscope— Granted permissionsjti— Unique token identifier (for revocation tracking)
Reference Tokens
Reference tokens are not self-contained JWTs. Instead, the access token is an opaque identifier. The API must call the introspection endpoint to validate it:
When to use reference tokens:
- Tokens contain sensitive claims you don't want exposed to intermediaries
- You need immediate token revocation (JWT lifetimes are not revocable until expiry)
- Token size is a concern (reference tokens are small opaque strings)
Concept 5: Token Introspection and Revocation
Introspection
APIs validate reference tokens by calling the introspection endpoint. The API authenticates itself with its own secret:
Revocation
Clients can revoke access tokens and refresh tokens:
What can actually be revoked: revocation (RFC 7009) only deactivates reference access tokens and refresh tokens, which are persisted server-side. A JWT access token is stateless and cannot be revoked — it stays valid untilexp. Use reference tokens when you need immediate invalidation.
Client Authentication: private_key_jwt
Confidential clients can authenticate with a signed JWT assertion instead of a shared secret. The assertion's aud MUST be the authorization server's issuer identifier (disco.Issuer), never the token endpoint URL — the latter enabled token-endpoint confusion attacks (CVE-2025-27370 / CVE-2025-27371). Set the JWT typ header to client-authentication+jwt to opt into strict audience validation (RFC 7523bis).
Concept 6: Scopes and Claims Mapping
Scopes Control What's in Tokens
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 reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/oauth-oidc-protocols/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/oauth-oidc-protocols)