Adds OIDC and SSO login to Payload and the Next.js App Router, working with any discovery-compliant identity provider such as Keycloak, Authentik, Okta, Auth0, Google Workspace or Microsoft Entra ID. It registers authorize and callback endpoints, verifies ID tokens against the provider's JWKS, and creates standard Payload sessions. Requires Payload 3, Next.js 15 or newer and React 19.
OpenID Connect (OIDC) & SSO authentication plugin for Payload CMS
Installation
npm i @payload-kit/oidc0
Stars
0
Forks
3
Open Issues
Yesterday
Last Updated
745
Weekly Downloads
v0.1.0-alpha.1
npm Version
249.4 KB
Unpacked Size
1
Dependencies
00 since Nov 22
| Date | Stars |
|---|---|
| Dec 6, 2026 | 0 |
| Dec 5, 2026 | 0 |
| Dec 4, 2026 | 0 |
| Dec 3, 2026 | 0 |
| Dec 2, 2026 | 0 |
| Dec 1, 2026 | 0 |
| Nov 30, 2026 | 0 |
| Nov 29, 2026 | 0 |
| Nov 28, 2026 | 0 |
| Nov 27, 2026 | 0 |
| Nov 26, 2026 | 0 |
| Nov 25, 2026 | 0 |
| Nov 24, 2026 | 0 |
| Nov 23, 2026 | 0 |
| Nov 22, 2026 | 0 |
Shared by 5 plugins in gngz/payload-kit.
Trends appear after 7 days of data. Collecting since Dec 2 — 5 daily snapshots so far.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1474969753-oidc)<a href="https://payloaddirectory.dev/plugins/1474969753-oidc"><img src="https://payloaddirectory.dev/badge/1474969753-oidc.svg" alt="Payload Directory"></a>README
OpenID Connect (OIDC) and Single Sign-On (SSO) plugin for Payload CMS and Next.js App Router. Works with any OIDC Discovery compliant identity provider (Authentik, Keycloak, Pocket ID, Okta, Auth0, Google Workspace, Microsoft Entra ID) using Authorization Code Flow with PKCE (S256), nonce checks, JWKS signature verification via jose, and native Payload sessions.
pnpm add @payload-kit/oidc
Peer dependencies: payload (^3.0.0), @payloadcms/ui (^3.0.0), next (>=15.0.0), react (^19.0.0).
Set the provider environment variables:
OIDC_ISSUER_URL=https://id.example.com
OIDC_CLIENT_ID=payload-cms
OIDC_CLIENT_SECRET=optional-client-secret-if-confidential
OIDC_AUTO_CREATE_USER=false
Register oidcPlugin in payload.config.ts:
import { buildConfig } from "payload";
import { oidcPlugin } from "@payload-kit/oidc";
export default buildConfig({
plugins: [
oidcPlugin({
enabled: Boolean(process.env.OIDC_ISSUER_URL && process.env.OIDC_CLIENT_ID),
issuer: process.env.OIDC_ISSUER_URL,
clientId: process.env.OIDC_CLIENT_ID,
clientSecret: process.env.OIDC_CLIENT_SECRET,
autoCreateUser: false,
enableAdminSettingsGlobal: true,
adminGroup: "Administration",
ui: {
injection: "beforeLogin",
buttonLabel: { pt: "Iniciar sessão com SSO", en: "Sign in with SSO" },
providerIcon: "fingerprint",
},
roleMapping: {
claim: "groups",
userField: "role",
map: {
admin: "admin",
admins: "admin",
},
},
}),
],
});
When enabled is false, or when issuer or clientId is omitted, the plugin returns the Payload config unchanged and registers no SSO endpoints.
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Enables or disables the plugin. |
issuer | string | undefined | required | Base URL of the OIDC provider (/.well-known/openid-configuration). |
clientId | string | undefined | required | Registered OIDC client ID. |
clientSecret | string | undefined | Client secret for confidential OIDC clients. |
scopes | string[] | ["openid", "profile", "email", "groups"] | OAuth2/OIDC scopes requested during authorization. |
redirectUri | string | ${serverURL}/api/sso/callback | Callback URL registered with the identity provider. |
userCollectionSlug | string | "users" | Slug of the Payload auth collection. |
autoCreateUser | boolean | false | Creates a Payload user record on first SSO login when true. |
stateSigningSecret | string | Derived from payload.secret (HKDF-SHA512) | Optional dedicated secret for HMAC-SHA512 state signing; defaults to a domain-separated key derived from payload.secret. |
allowedAlgorithms | string[] | DEFAULT_ALLOWED_ASYMMETRIC_ALGORITHMS | Asymmetric JWS algorithms accepted for id_token verification (includes classical RSA/ECDSA/EdDSA and RFC 9964 ML-DSA-44/65/87; rejects none and HS*). |
allowedEmailDomains | string[] | undefined | Restricts SSO login to the listed email domains. |
requireVerifiedEmail | boolean | true | Requires email_verified === true before linking to an existing local user by email. |
mapUserClaims | (params) => Record<string, unknown> | Promise<Record<string, unknown>> | undefined | Optional callback returning extra fields to merge into the user document on create/update. |
enableAdminSettingsGlobal | boolean | false | Registers an sso-settings global for runtime control of enabled, autoCreateUser, button labels, and groupMappings. |
adminGroup | string | Record<string, string> | "Administration" | Admin navigation group for sso-settings. |
settingsAccess | { read?, update? } | admin role check | Access control overrides for sso-settings. |
ui | OidcUiOptions | { injection: "manual" } | Login button placement (manual, beforeLogin, afterLogin), buttonLabel, showDivider, dividerText, providerIcon (lock, user, key, shield, fingerprint), and CustomButton. |
roleMapping | OidcRoleMappingConfig | undefined | Maps claims (claim, supporting dot-notation like realm_access.roles) to userField via map, defaultRole, or a custom resolveUserRoles callback. |
The package splits server config, RSC wrapper, and client button across three entry points to preserve the Next.js App Router boundary:
@payload-kit/oidc: oidcPlugin, endpoint and component constants (OIDC_LOGIN_BUTTON, OIDC_LOGIN_BUTTON_CLIENT), crypto/token/discovery/role helpers, and TypeScript types.@payload-kit/oidc/rsc: OidcLoginButtonServer (Server Component referenced by OIDC_LOGIN_BUTTON). Hides itself automatically when /api/sso/authorize is inactive or sso-settings.enabled is false.@payload-kit/oidc/client: OidcLoginButton ("use client" component referenced by OIDC_LOGIN_BUTTON_CLIENT).sequenceDiagram
autonumber
actor User as Browser
participant App as Payload (@payload-kit/oidc)
participant IdP as OIDC Provider (IdP)
User->>App: GET /api/sso/authorize?returnTo=/admin
App->>IdP: GET /.well-known/openid-configuration (cached)
IdP-->>App: Discovery metadata (authorization, token, jwks_uri, userinfo)
App-->>User: 302 Redirect to IdP (PKCE S256, signed state, nonce)<br/>Set-Cookie: __sso_state, __sso_verifier, __sso_nonce, __sso_return_to
User->>IdP: Authenticate & consent
IdP-->>User: 302 Redirect /api/sso/callback?code=...&state=...
User->>App: GET /api/sso/callback (with temporary HttpOnly cookies)
App->>App: Verify HMAC-SHA512 state & cookie match
App->>IdP: POST token_endpoint (code + code_verifier + client credentials)
IdP-->>App: id_token + access_token
App->>IdP: GET jwks_uri (cached)
IdP-->>App: JWKS public keys (RS*/ES*/PS*/EdDSA / ML-DSA-44/65/87)
App->>App: Verify id_token signature, iss, aud, azp, exp, nbf, nonce<br/>Log verified idTokenAlg & idTokenKid (debug)
opt userinfo_endpoint configured
App->>IdP: GET userinfo_endpoint (Bearer access_token)
IdP-->>App: UserInfo claims
App->>App: Assert userinfo.sub === id_token.sub
end
App->>App: Enforce email domain, email_verified, roleMapping & user sync<br/>Run beforeLogin / afterLogin hooks & create Payload session
App-->>User: 302 Redirect to sanitized returnTo<br/>Set-Cookie: payload-token & clear temporary SSO cookies
GET /api/sso/authorize checks runtime settings, fetches and caches OIDC discovery metadata (HTTPS required in production), generates PKCE (S256), HMAC-SHA512 signed state (via HKDF-SHA512 key separation from payload.secret or stateSigningSecret), and nonce, stores them in HttpOnly, SameSite=Lax cookies (__sso_state, __sso_verifier, __sso_nonce, __sso_return_to), and redirects to the provider.GET /api/sso/callback verifies state and its HMAC signature, exchanges code and code_verifier at token_endpoint, verifies the id_token signature against jwks_uri (iss, aud, exp, nbf with 60s skew, nonce) using allowedAlgorithms (supporting classical RSA/ECDSA/EdDSA and post-quantum RFC 9964 ML-DSA-44/ML-DSA-65/ML-DSA-87 on Node.js >= 24.7.0 with OpenSSL 3.5+), logs the verified idTokenAlg and idTokenKid at debug level, checks userinfo.sub === id_token.sub when userinfo_endpoint is present, enforces allowedEmailDomains, resolves roles, runs beforeLogin and afterLogin hooks, creates a Payload session with addSessionToUser, and sets the Payload auth cookie.X25519MLKEM768) at your edge/reverse proxy and Node.js runtime to mitigate Harvest Now, Decrypt Later (HNDL), and ensure reverse proxy HTTP header and cookie buffers accommodate larger ML-DSA signatures.claims.email_verified === true.roleMapping.defaultRole is omitted, unmapped new users are rejected instead of falling back to "admin".oidcSub, authProvider, and lastOidcLogin to the auth collection with API write access disabled (create: () => false, update: () => false).returnTo paths are sanitized against origin parsing, and login error banners only accept codes in KNOWN_SSO_ERROR_CODES.payload-totp) continue to enforce their verification or setup step on admin routes after OIDC login.MIT
payload zitadel plugin
Log in to the Mzinga admin through Zitadel or another OIDC provider using authorization code with PKCE
72608/wk11v?
payload keycloak
Keycloak SSO-only authentication for Payload 3 using OIDC with PKCE and permission-based access helpers
5511/wk0v3
payload simple social login
Google and Microsoft social login for the Payload admin panel and auth collections
7119/wk3v3
payload auth
Replace Payload's built-in auth with Better Auth for a shared admin and frontend session
7021.0k/wk349v3
payload github auth
Sign in to the Payload admin with a GitHub App, with access rules by email, org or team
6021/wk0v4
payload auth plugin
Authentication plugin adding OAuth, OIDC, SSO and passkey sign-in to Payload CMS
594.7k/wk310v3