Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Oauth2 Oidc Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-oauth2-oidc-knowledge-patch)
---
name: oauth2-oidc-knowledge-patch
description: OAuth 2.0 / OIDC
version: null
license: MIT
metadata:
author: Nevaberry
---
# OAuth 2.0 and OpenID Connect
Load this skill when implementing or reviewing authorization-flow security,
token restrictions, browser authorization responses, or protected-resource
metadata discovery and validation.
## Reference index
| Reference | Topics |
| --- | --- |
| [Authorization-flow security](references/authorization-security.md) | PKCE, nonce checks, issuer binding, redirect trust, CORS, framing, browser origins, audiences, refresh tokens, identity claims |
| [Protected-resource metadata and discovery](references/protected-resource-metadata.md) | Discovery URLs, resource binding, bearer transports, signing, token binding, localization, signed metadata, reciprocal metadata, challenge refresh |
## Reject PKCE downgrade requests
The token endpoint MUST reject a request containing `code_verifier` when the
corresponding authorization request had no `code_challenge`.
Clients MUST confirm server support before relying on PKCE for CSRF protection.
Authorization servers MUST make support detectable, preferably through
authorization-server metadata:
```json
{"code_challenge_methods_supported":["S256"]}
```
## Validate the token-endpoint nonce before using tokens
Confidential OpenID Connect clients MAY prevent code injection with a
transaction-specific `nonce` bound to the browser session. Public clients MUST
use PKCE.
The client MUST validate the nonce in the ID Token from the token endpoint,
even if an ID Token arrived in the authorization response, and defer all use
of ID Tokens and the access token until this check succeeds.
## Bind each transaction to its issuer
For clients using multiple authorization servers, bind the expected issuer to
each browser transaction. Require the response issuer to match before exchanging
the code, using the authorization response's `iss` parameter or its equivalent
in a JARM response or front-channel ID Token.
If no issuer identifier exists, bind the authorization and token endpoint pair
or a unique identifier for that pair. Use distinct redirect URIs as a fallback
when response issuer checks are unavailable.
## Apply redirect authentication and trust rules
The authorization server MUST authenticate the user before redirecting, prompting
for credentials when required outside silent authentication. It SHOULD redirect
automatically only if it trusts the callback, even when the URI is registered.
It MAY let the user decide whether to continue to an untrusted callback.
An authorization server MAY trust a `redirect_uri` without further checks when
it can verify the origin and integrity of the authorization request carrying it,
for example through JAR or PAR with client authentication.
A server issuing a redirect MAY add a fragment such as `#_` to the `Location`
URL to keep the browser from reattaching a fragment from the original URL:
```http
Location: https://client.example/continue#_
```
## Check browser origins and endpoint policy
For authorization responses sent with `postMessage`:
- The authorization server MUST use an explicit, trusted `targetOrigin` and
exact matching against registered receiver origins.
- The client MUST match `event.origin` exactly against the authorization server's
origin.
- Protections for redirect-based authorization responses still apply.
The token, authorization-server metadata, `jwks_uri`, and dynamic client
registration endpoints MAY support CORS for direct browser access. Keep CORS
disabled at the authorization endpoint, which clients reach through navigation.
Authorization servers SHOULD use CSP level 2 or later across the authorization
endpoint and applicable login, device authorization, consent, and error pages.
They SHOULD support per-client allowed framing origins through administrator
settings, dynamic registration, or both.
## Restrict token audiences, scope, and identity claims
For audience restriction to protect against a counterfeit resource server,
use the actual resource server URL to which the client sends requests. Verify
the audience at the resource server on every request. The client can identify
the destination to the authorization server with the RFC 8707 `resource`
parameter or a deployment-defined `scope`.
Bind each refresh token to the scopes and resource servers the resource owner
consented to. Refresh tokens SHOULD expire after a period without use; the
authorization server chooses the timeout globally or by client or grant policy.
When clients and users share a subject namespace, the authorization server
SHOULD prevent clients from influencing identifiers or claims that could be
mistaken for a resource owner's identity. If it cannot, it MUST give the resource
server another way to distinguish client-only grant access tokens from access
tokens for grants involving a resource owner.
## Discover and bind protected-resource metadata
Fetch metadata with `GET`. Derive the URL from the fragment-free HTTPS resource
identifier: remove a terminating path slash and insert
`/.well-known/oauth-protected-resource` after the authority, before the path
and any query.
```text
Resource https://api.example.com/orders?tenant=blue
Metadata https://api.example.com/.well-known/oauth-protected-resource/orders?tenant=blue
```
An application MUST specify its well-known suffix, which can be the default or
another registered suffix. A resource MAY publish at multiple such locations.
The returned `resource` MUST match:
- The original resource identifier for well-known discovery.
- The exact URL of the request that elicited the challenge for
`WWW-Authenticate` discovery.
Decode any JSON escapes, compare Unicode code points as supplied, and discard
the response on a mismatch.
## Validate signed metadata before applying precedence
`signed_metadata` is a JWT string signed or MACed with JWS. It MUST include an
`iss` identifying the attester. Supporting consumers MUST validate it with a
key belonging to that issuer before giving its claims precedence over
corresponding plain JSON members.
Consumers SHOULD treat an invalid signature or untrusted issuer as an error,
and SHOULD reject a JWT containing a nested `signed_metadata` claim.
An authorization server's `protected_resources` list is reciprocal to a
resource's `authorization_servers` list of RFC 8414 issuer identifiers. Either
list may be partial or absent. Profiles using both should cross-check them for
consistency and apply their own rules for trusting an authorization server.
## Preserve metadata defaults and empty-value semantics
The general response rule uses arrays for multivalued parameters, omits
parameters with zero values, and requires consumers to ignore unknown members.
The explicit bearer-method semantics are:
| `bearer_methods_supported` | Meaning |
| --- | --- |
| `[]` | Zero supported bearer transports |
| Absent | Support unspecified |
| Transport names | `header`, `body`, `query` |
Both `tls_client_certificate_bound_access_tokens` and
`dpop_bound_access_tokens_required` default to `false`. The former advertises
support for mutual-TLS certificate-bound tokens; the latter indicates whether
the resource always requires DPoP-bound tokens.
The optional `resource_signing_alg_values_supported` array advertises JWS `alg`
values for signing resource responses, excludes `none`, and implies no default
algorithms when omitted. See the metadata reference for signing keys, DPoP proof
algorithms, authorization detail types, and localized member names.
## Refresh metadata when challenged
`WWW-Authenticate` can carry `resource_metadata` with schemes such as `DPoP`
and extension parameters such as `max_age`. A new challenge containing
`resource_metadata` signals a possible metadata change. The client SHOULD
fetch, validate, and use the updated metadata.
```http
HTTP/1.1 401 Unauthorized
WWW-Authenticate: DPoP resource_metadata="https://api.example.com/.well-known/oauth-protected-resource/orders", max_age="300"
```