Skip to Content

OpenID Connect and logout

Configure discovery, ID token and UserInfo claims, authentication context, subject identifiers, and logout.

Your OAuth provider is also an OpenID Connect provider. A client that requests the openid scope receives an ID token, can call UserInfo, and can take part in logout.

To serve only OpenID Connect, set requireOpenId. A request to /oauth2/authorize that leaves out openid, or sends no scope, is then redirected to the client with invalid_scope instead of being served as plain OAuth. The redirect happens once the client and redirect_uri have passed validation. Earlier failures use the server's error page. Pushed authorization requests and plugin endpoints that issue authorization codes enforce the same scope requirement and return invalid_scope directly. The setting does not apply to device authorization or CIBA approvals. openid must also be in scopes, or the plugin fails at startup:

auth.ts
oauthProvider({
  scopes: ["openid", "profile", "email"],
  requireOpenId: true, 
  // ...
});

Discovery metadata

Entro Auth serves OpenID Provider metadata at {issuer}/.well-known/openid-configuration and authorization server metadata at {issuer}/.well-known/oauth-authorization-server. If your framework does not forward these routes to auth.handler, see Expose the well-known metadata.

The OpenID configuration returns 404 when you set scopes without openid. To serve it, add openid to scopes.

The issuer comes from jwt.issuer when you set it and the provider uses the JWT plugin, and otherwise from your baseURL. With disableJwtPlugin: true, it always comes from baseURL. The provider removes a trailing slash, a query, and a fragment from that URL, lowercases its scheme and host, drops a default port, and resolves dot segments in the path. Discovery, the authorization response iss parameter, ID tokens, JWT access tokens, introspection responses, and logout tokens all report this one value. OpenID Connect Discovery §4.3 requires it to match the iss of ID tokens. ID tokens and JWT access tokens issued by versions before 1.8 carry the URL as you configured it, and the provider's own checks, such as the id_token_hint check, accept both values. A resource server that checks signatures against keys fetched from a URL, such as a remote jwksUrl, expects the discovery issuer only. Opaque access tokens have no iss claim. If a proxy terminates TLS in front of Entro Auth, set baseURL to the public https URL.

To publish fewer scopes, more claims, or a different list of token endpoint authentication methods than discovery derives, set advertisedMetadata:

auth.ts
oauthProvider({
  scopes: ["openid", "profile", "email", "offline_access", "read:post"],
  advertisedMetadata: { 
    scopes_supported: ["openid", "profile", "read:post"], 
    claims_supported: [ 
      "sub", "iss", "aud", "exp", "iat", "sid", "scope", "azp", 
      "name", "picture", "given_name", "family_name", 
      "locale", "https://example.com/org", 
    ], 
    token_endpoint_auth_methods_supported: [ 
      "none", "client_secret_basic", "client_secret_post", "private_key_jwt", 
    ], 
  }, 
})

Every value in scopes_supported must also be in scopes, or the plugin fails at startup. claims_supported replaces the default list (sub, iss, aud, exp, iat, sid, scope, azp, plus the profile and email claims when those scopes are configured), so repeat the defaults you still want. List every claim your custom claim functions add, so clients know to expect it. Clients can request through claims.userinfo only the names in this list.

token_endpoint_auth_methods_supported replaces the derived list in both discovery documents, so list every method you want clients to see. Unset, none appears only when allowUnauthenticatedClientRegistration is true or an extension contributes client discovery. A provider that keeps registration protected but accepts public clients you create yourself would otherwise omit none, and clients that follow RFC 8414 would conclude that public clients are unsupported. Include none to say otherwise. Every listed method must be one the server supports, including methods that a companion plugin adds through extendOAuthProvider. The list cannot be empty or repeat a method, or the plugin fails at startup. An unsupported method throws when discovery metadata is built. The option changes only what discovery advertises: it does not change which clients the token endpoint accepts, it does not open /oauth2/register, and it leaves the introspection and revocation lists unchanged.

Entro Auth advertises acr_values_supported from authenticationContext.acrValuesSupported, which defaults to ["0"]. In OIDC Core, "0" means the authentication did not meet ISO/IEC 29115 level 1. To assert other classes, see Authentication context.

ID token claims

To add claims to the ID token, set customIdTokenClaims. It receives the user, the granted scopes, the client's metadata, and the grantId when the issuance has one. It returns an object of claims to add:

auth.ts
oauthProvider({
  customIdTokenClaims: ({ user, scopes, metadata }) => ({ 
    "https://example.com/org": user.organizationId, 
  }), 
})
  • In the authorization code flow, profile and email claims go to UserInfo, not the ID token. Add them in customIdTokenClaims if a client needs them in the ID token.
  • Entro Auth owns the protocol claims (iss, sub, aud, exp, nbf, iat, jti, nonce, sid, at_hash, c_hash, s_hash, auth_time, acr, amr, azp). Custom values for these names are dropped with a warning log.
  • Use URI-namespaced names for application claims, as OIDC Core §5.1.2 recommends.
  • To stop issuance, for example when the user has left the organization, throw from the function.

When an extension also contributes claims, see Claim precedence.

By default, ID tokens carry acr: "0", meaning the authentication did not meet ISO/IEC 29115 level 1 (OIDC Core §2), and no amr. To assert other values, see Authentication context.

With disableJwtPlugin: true, ID tokens are signed with HS256 using the client secret, so public clients get no ID token. See Without the JWT plugin. The OpenID configuration then omits jwks_uri, because there are no keys to publish, and lists ["HS256"] in id_token_signing_alg_values_supported. OIDC Discovery §3 marks jwks_uri as required.

Authentication context

To assert a stronger authentication class in acr, or the methods the user signed in with in amr, set authenticationContext with both fields:

  • acrValuesSupported lists the acr values the provider may issue. Discovery advertises it as acr_values_supported. Include "0" if resolve can return no acr.
  • resolve returns the acr and amr the current session established. For requests with the openid scope, it runs once, when the user approves an authorization request, a device code, or a CIBA (Client-Initiated Backchannel Authentication) request on the provider's pages. It receives user, session, client, the approved scopes, the request headers, and requestedAcrValues (from claims.id_token.acr and acr_values). For the openid scope, it also runs when a plugin endpoint issues a code with issueAuthorizationCode, and then receives the methods that endpoint reported as amr. completeCibaRequest does not call resolve, and records the acr and amr you pass instead.

Return only what the session proved. Entro Auth does not record how a session signed in, so track it yourself. The example below marks sessions created by a completed two-factor challenge. Sessions created through a trusted device skip that challenge and stay unmarked.

auth.ts
import { entroAuth } from "@entro314labs/entro-auth";
import { jwt, twoFactor } from "@entro314labs/entro-auth/plugins";
import { oauthProvider } from "@entro314labs/entro-auth-oauth-provider";

const MFA = "urn:example:acr:mfa";

export const auth = entroAuth({
  session: {
    additionalFields: {
      twoFactorVerified: { type: "boolean", defaultValue: false, input: false },
    },
  },
  databaseHooks: {
    session: {
      create: {
        // Two-factor verification endpoints create the session only after the
        // second factor succeeds.
        before: async (session, ctx) => ({
          data: {
            ...session,
            twoFactorVerified:
              ctx?.path?.startsWith("/two-factor/verify-") ?? false,
          },
        }),
      },
    },
  },
  disabledPaths: ["/token"],
  plugins: [
    twoFactor(),
    jwt({ disableSettingJwtHeader: true }),
    oauthProvider({
      loginPage: "/sign-in",
      consentPage: "/consent",
      authenticationContext: { 
        acrValuesSupported: ["0", MFA], 
        // Assert only what the session proved: the two-factor step, not how the
        // first factor was done.
        resolve: ({ session }) =>
          session.twoFactorVerified === true
            ? { acr: MFA, amr: ["mfa"] } 
            : { acr: "0" }, 
      }, 
    }),
  ],
});

The claims parameter requires openid in the effective scopes, including any defaults applied when the client omits scope. If those scopes omit openid, claims validation returns invalid_request. With requireOpenId enabled, the client must send openid explicitly or scope validation returns invalid_scope first.

How a request for a class is handled depends on whether it is essential:

  • An essential request (claims={"id_token":{"acr":{"essential":true,"value":"…"}}}) that the session does not satisfy fails with access_denied at the client's redirect URI. If no value in acrValuesSupported could satisfy it, the request fails before sign-in. The Unmet Authentication Requirements specification specifies unmet_authentication_requirements for this failure.
  • A voluntary request (acr_values, or an acr claim without essential) can succeed even when the session has a different authentication class. The ID token reports the session's current acr.

For authorization-code requests, use beforeAuthorization to require a class the client asks for with acr_values. At /oauth2/authorize, the hook can send the user to sign in again before consent or refuse the request.

For device and CIBA approvals on the provider's pages with the openid scope, use authenticationContext.resolve to refuse a session that does not meet your rule. If your own app approves CIBA requests, enforce the rule before calling completeCibaRequest.

resolve must return an acr from acrValuesSupported, or omit it to use "0". amr must be an array of strings. Any other result fails the authorization with server_error.

To refuse an authorization yourself, throw an APIError with an OAuth error such as access_denied. The client receives that error and its error_description. For a device code, the user sees the error on your verification page instead, and the code stays pending so the user can retry. To refuse at the token endpoint instead, after the client redeems the grant, use beforeTokenIssuance.

The acr and amr are stored with the authorization code or device code and with the refresh token. ID tokens from later refreshes therefore keep the values of the original authentication (OIDC Core §12.2). They change only when the user authorizes again.

UserInfo

/oauth2/userinfo accepts GET and POST and returns claims for an access token whose scopes include openid. Send the token as Authorization: Bearer <token>, or DPoP <token> for a DPoP-bound token. A header without one of those schemes counts as no token. A token without openid gets 403 insufficient_scope, with a challenge naming openid. An expired or revoked token, or one whose session has ended, gets 401 invalid_token (RFC 6750 §3.1).

Every 401 and 403 from UserInfo carries a WWW-Authenticate challenge that tells the client how to retry. The table shows the 401 challenges. The response also lists WWW-Authenticate in Access-Control-Expose-Headers, so a browser client on another origin can read the challenge.

RequestChallenge
No access tokenBearer scope="openid", DPoP scope="openid", algs="…", with no error code
A token sent with the Bearer scheme or in the form body, when the token is not DPoP-boundBearer error="invalid_token", …
A DPoP-bound token, or any request that uses the DPoP schemeDPoP error="…", error_description="…", algs="…" (RFC 9449 §7.1)

The 403 for a token without openid carries error="insufficient_scope" and scope="openid". Its scheme follows the table: DPoP for a DPoP-bound token or a request that uses the DPoP scheme, otherwise Bearer.

algs lists the proof algorithms from dpop.signingAlgorithms. UserInfo validates the access token before it checks the DPoP proof, so an invalid, expired, or revoked token gets invalid_token whatever the proof contains. For a valid DPoP-bound token, the error is invalid_dpop_proof when the proof is missing or fails verification, for example when its htu, htm, or key does not match. When dpop.nonce.required is on, a proof without a current server nonce gets use_dpop_nonce instead, and the response carries a DPoP-Nonce header to retry with. Every other failure gets invalid_token, including a DPoP-bound token sent with the Bearer scheme. An auth.api.oauth2UserInfo call has no HTTP request to check a proof against, so a DPoP-bound token fails with invalid_token, and the thrown error carries the same challenge in its headers.

const response = await fetch("https://auth.example.com/api/auth/oauth2/userinfo", {
  headers: { Authorization: `Bearer ${accessToken}` },
});

Claims follow the granted scopes:

ScopeClaims
openidsub
profilename, picture, given_name, family_name
emailemail, email_verified

By default, UserInfo omits name when the user’s name is empty and picture when their image is empty. Your customUserInfoClaims callback can supply either claim, including an empty string. The default follows OpenID Connect Core §5.3.2.

Entro Auth returns a claim from the table above even when its scope was not granted, if all of these are true:

  • The client requests the claim through the claims.userinfo parameter.
  • The claim appears in claims_supported.
  • Your consent page did not remove the claim. It removes one when it passes a claims object to oauth2.consent that leaves the claim out.
  • The user has a value for the requested standard claim. The built-in resolvers omit missing values and skip empty names and images.
  • The access token is opaque. With a JWT access token, UserInfo returns only the claims its scopes cover.

Entro Auth does not fill in other requested names, such as locale. To return one on request, list it in advertisedMetadata.claims_supported together with the defaults you still want, as in Discovery metadata. Then read requestedClaims in customUserInfoClaims, described below.

Entro Auth reads only the claim names under claims.userinfo. It ignores essential, value, and values there, and it ignores claims.id_token requests except acr. OIDC Core §5.5.1 says a claim whose value does not match a requested value is left out of the response. It also says a mismatch on sub must cause the authentication to fail, and §3.1.2.2 says the provider must not reply with a token for a different user. Entro Auth ignores a value on sub too. A client that requests a specific sub must check the sub it receives.

To add claims to the UserInfo response, set customUserInfoClaims. It receives the user, the access token's scopes, the access token payload as jwt, and requestedClaims. requestedClaims lists the claim names requested through claims.userinfo. It also receives the access token's grantId when the token has one. An opaque token has one when it was issued with a refresh token or redeemed from an authorization code. A JWT access token carries the provider's grant_id claim, and so the callback receives it, only when revocableJwtAccessTokens is on. A claim you add with customAccessTokenClaims is in jwt either way. It returns an object of claims to add:

auth.ts
oauthProvider({
  customUserInfoClaims: ({ user, scopes, requestedClaims, jwt }) => ({ 
    locale: "en-GB", 
    ...(requestedClaims.includes("website") ? { website: user.website } : {}), 
  }), 
})

A returned claim replaces the standard claim of the same name, except sub.

Pairwise subject identifiers

Clients that receive the same sub for a user can link that user's activity across those clients. By default, sub is the user ID, which is the same for every client (the public subject type). To let clients receive a sub that other clients cannot correlate, set pairwiseSecret:

auth.ts
oauthProvider({
  pairwiseSecret: process.env.PAIRWISE_SECRET, // at least 32 characters
})

Discovery then lists "public" and "pairwise" in subject_types_supported. A client opts in with subject_type: "pairwise" through dynamic registration or adminCreateOAuthClient. createOAuthClient ignores the field.

Entro Auth computes the value with HMAC-SHA256 over the client's sector identifier and the user ID, keyed with pairwiseSecret (OIDC Core §8.1). Clients in different sectors always receive different sub values for the same user, and a client always receives the same sub for the same user. Entro Auth assigns the sector when the client is created:

  • A client whose redirect URIs all use https gets the host of its first redirect URI, including any port. Clients on the same https host share a sector, so they receive the same pairwise sub.
  • Any other client gets a sector of its own. Examples are clients with an authority-free private-use redirect URI (com.example.app:/callback) or a loopback one (http://localhost:8787/callback). Any app can register a custom scheme, and any local process can listen on a loopback port, so those redirect URIs do not identify the client.

Changing a client's redirect URIs recomputes its sector, so moving to another host changes the sub its users receive. Clients created before Entro Auth stored sectors keep the sector of their first redirect URI host, so their users' sub does not change. Unrelated custom-scheme or loopback clients created before then can share a sector.

The calculation assumes that user IDs contain no dot. OIDC Core §8.1 says different sector identifiers must produce different subject values, and a dot in a user ID can break that. The built-in ID generators (the default, uuid, and serial) never produce a dot. If a custom advanced.database.generateId function or your database assigns user IDs, make sure they contain no dot when you use pairwise subjects.

  • Pairwise sub appears in the ID token, UserInfo, and introspection. Introspection returns the sub of the client the token was issued to. For a delegated token, introspection also names each user in act and a user in may_act by the sub that client sees for that user.
  • JWT access tokens carry the user ID as sub by default, so resource servers can look users up. A client can decode its own JWT access tokens, so a pairwise client that requests a resource learns the user ID. The provider issues a JWT access token only when the client requests a resource, the JWT plugin is enabled, and the resource does not use opaque access tokens. Otherwise the token is opaque. To keep the user ID from pairwise clients, set accessTokenSubject: "pairwise", or give the resource opaque access tokens.

Pairwise sub in JWT access tokens

With accessTokenSubject: "pairwise", JWT access tokens issued to a pairwise client carry the same sub as its ID tokens:

auth.ts
oauthProvider({
  pairwiseSecret: process.env.PAIRWISE_SECRET,
  accessTokenSubject: "pairwise", 
})

Resource servers that read sub from those tokens then see a different value for the same user under each sector, and cannot look the user up by that value. Keep the default if a resource server keys its data on the user ID across clients. Tokens for clients with subject_type: "public" and client_credentials tokens are unaffected.

The option also covers tokens from delegation. Each user named in act, at every level, carries the sub that the token's client sees for that user. That is the same sub the client saw in the user's own access token. A service named in act keeps its client ID when its entry carries sub_profile: "service", which token exchange sets on every service actor. An entry without sub_profile, such as one from a token delegated before the provider added it, is presented as a user. A user named in may_act is presented the same way.

The token also carries a ba_sub claim: the user ID, and the token's act and may_act with user IDs, encrypted with a key derived from the Entro Auth secret. Each token gets a fresh nonce, so the value does not link users across clients. UserInfo, introspection, and token exchange read the user from it. Resource servers should ignore it. Rotating the Entro Auth secret without keeping the old one makes existing tokens inactive.

Endpoints you build on the provider API still receive the user ID in sub, and can call resolveSubject to get the value a client sees.

pairwiseSecret must be at least 32 characters. Changing it changes every pairwise sub and breaks existing client accounts. Treat it as permanent.

sector_identifier_uri is not supported. All redirect_uris of a pairwise client must therefore share one host and port. Pairwise clients also cannot use custom-scheme redirect URIs with a host, such as app://rp.example.com/callback. Any app can claim a custom scheme. The host in such a URI therefore does not identify the client. Registration fails with invalid_client_metadata in either case. OIDC Core §8.1 and OIDC Registration §2 say a provider that uses pairwise subjects should use sector_identifier_uri. Entro Auth does not read it. It rejects a registration that would need it instead of deriving a sub from the wrong sector.

RP-initiated logout

To let a client end the user's session, register it with enable_end_session: true. The /oauth2/end-session endpoint then implements RP-Initiated Logout for it:

auth.ts
await auth.api.adminCreateOAuthClient({
  headers,
  body: {
    redirect_uris: ["https://app.example.com/callback"],
    post_logout_redirect_uris: ["https://app.example.com/logout"],
    enable_end_session: true, 
  },
});
  • It accepts GET query parameters, a form-encoded POST body, or a JSON POST body. authClient.oauth2.endSession() sends a JSON body when you pass the fields directly.

  • A valid id_token_hint for the current browser session ends it immediately. Without one, or with a hint for a different session, the user must confirm first. In a browser, Entro Auth serves the confirmation page.

  • Entro Auth redirects after logout only when post_logout_redirect_uri exactly matches one of the client's registered post_logout_redirect_uris, and adds state only to that redirect. For example, https://app.example.com/logout/ does not match a registered https://app.example.com/logout. Without a matching URI, a browser shows a logged-out page from Entro Auth.

  • When clients registered for front-channel logout must be notified, a browser gets the front-channel logout page instead. That page then redirects or shows the logged-out message.

  • An id_token_hint that fails validation gets one of these answers:

    • On a browser navigation with a current session, the user sees the confirmation page, as when no hint is sent. If the request carries a client_id and a registered post_logout_redirect_uri, the redirect happens after the user confirms.
    • In any other case, the endpoint returns 401 invalid_token, as JSON or, for a browser navigation, as an error page. It does not redirect.
    • When no client is found, the second answer is 400 invalid_client, and the confirmation in the first answer ends without a redirect.

    A disabled client gets 400 invalid_client, and a client without enable_end_session gets 401 invalid_client, before the hint is checked.

    RP-Initiated Logout §4 says the provider must not redirect to the client when it detects an error in the request. Entro Auth redirects after the user confirms.

Enable this only for clients you trust. The client, or anyone holding an ID token it received, can end that token's session without confirmation, for these reasons:

  • With a valid id_token_hint, the request does not need the user's browser.
  • An expired ID token is still accepted as a hint.

Ending the session also triggers back-channel logout for every client that holds tokens for it.

Registered clients

Clients created through dynamic client registration, a Client ID Metadata Document, or createOAuthClient cannot set enable_end_session themselves. To let them use RP-initiated logout, set clientRegistrationEnableEndSession:

auth.ts
oauthProvider({
  allowDynamicClientRegistration: true,
  clientRegistrationEnableEndSession: true, 
});

To decide per client, pass a function instead. It receives the validated registration metadata, including the assigned client_id, and registrationSource, which is "dynamic", "clientMetadataDocument", or "createOAuthClient":

auth.ts
oauthProvider({
  clientRegistrationEnableEndSession: ({ registrationSource }) =>
    registrationSource === "clientMetadataDocument",
});

Entro Auth decides once, when it creates the client. Refreshing a metadata document never grants or removes the permission, and turning the option on does not change clients that already exist. To change it for one client later, call adminUpdateOAuthClient with only enable_end_session. That works on any client, including anonymous registrations and metadata document clients, which have no owner:

revoke-logout.ts
await auth.api.adminUpdateOAuthClient({
  headers,
  body: {
    client_id: clientId,
    update: { enable_end_session: false },
  },
});

A registrant chooses its own post_logout_redirect_uris, so a client allowed to log out must keep them on the origins it already receives authorization responses on. Each URI must share a scheme, host, and port with one of the client's redirect_uris. A loopback address such as localhost or 127.0.0.1 matches on any port, and a private-use URI such as com.example.app:/logout matches on its scheme and authority. A metadata document client may also use the origin of its client_id URL. The provider returns invalid_client_metadata when an otherwise valid logout URI fails this registration rule. An entry that no client may register, such as a URI containing credentials, fails with invalid_redirect_uri.

The CIMD plugin holds a metadata document client to a stricter rule on top of this one. Unless you change originBoundFields, every entry must share the origin of its client_id URL, except for HTTP(S) loopback redirects and hostless reverse-domain private-use logout URIs such as com.example.app:/logout, so a metadata document client cannot use a web origin that only its redirect_uris have. An entry that breaks this rule is rejected with invalid_client, and the client cannot be resolved or refreshed. The redirect_uris rule also covers every post_logout_redirect_uris entry an owner adds with updateOAuthClient to a client allowed to log out, whoever created it. Entries the client already has are kept, so URIs an administrator set stay valid. adminUpdateOAuthClient is not limited by that rule, except when it grants enable_end_session to a client you do not own: the grant fails with invalid_client_metadata if one of the client's stored post_logout_redirect_uris breaks it.

With open registration, anyone can register a client. A client allowed to log out can end the session of any user who signed in to it, using an ID token it received for that user, without the user's browser. Without a hint, the user always confirms on your logout page first.

Back-channel logout

To notify a client when a user's session ends, register a backchannel_logout_uri for it. The session can end in several ways, for example through sign-out, end-session, or admin revocation. Entro Auth then sends a signed Logout Token to each client that registered a URI and holds tokens for that session:

auth.ts
await auth.api.adminCreateOAuthClient({
  headers,
  body: {
    redirect_uris: ["https://app.example.com/callback"],
    backchannel_logout_uri: "https://app.example.com/logout/backchannel", 
    backchannel_logout_session_required: true,
  },
});
  • Recipients are found through the opaque access tokens and refresh tokens stored for the session. A client that holds only a JWT access token for it, such as after a resource request without offline_access, is not notified.
  • Logout Tokens carry typ: logout+jwt, always include sid, and live for 120 seconds. The JWT plugin signs them, so a client verifies them with your JWKS. Each request has a 5 second timeout, which includes the DNS lookup, and is not retried.
  • When a session is deleted, Entro Auth revokes the session's access tokens and its refresh tokens without offline_access, whether or not any client registered a backchannel_logout_uri. Introspection and UserInfo then reject those access tokens, but a resource server that verifies JWT access tokens locally keeps accepting them until they expire. An opaque access token issued by a refresh that runs while sign-out is in progress can also stay active until it expires, on databases that enforce the session foreign key. Refresh tokens with offline_access survive, as §2.7 allows. A password reset can revoke those refresh tokens too. Tokens from the device authorization and CIBA grants have no associated session and survive sign-out.
  • A new grant gets a refresh token only when it includes offline_access, and that token survives the end of the session. RFC 10017 §6.3.2.3 says authorization servers should link the lifetime of a refresh token to the user's authenticated session when the client is a browser-based app. The provider has no option that binds every refresh token to the session. A browser-based app whose tokens must end with the session has two choices. It can omit offline_access, which means it gets no refresh token and must authorize again when its access token expires. Or it can keep its tokens on a server that handles back-channel logout.
  • backchannel_logout_uri must be a public https URL with no credentials or fragment. Loopback, private, and metadata hosts are rejected with invalid_client_metadata. This registration check does not resolve DNS.
  • Before each delivery, Entro Auth checks the stored URI again and resolves its host name. It skips that client and logs a warning when the lookup fails or any address is loopback, private, link-local (including cloud metadata), or otherwise not publicly routable. The session's tokens are still revoked. This stops a public-looking name whose DNS record points at an internal address from receiving the request.
  • The DNS check applies only on runtimes where node:dns resolves names. Elsewhere, only the host name check applies. The fetch that sends the request resolves the name again, so a DNS answer that changes between the two lookups, known as DNS rebinding, can still reach an internal address. For a strict guarantee, or if untrusted parties can register clients on your server, restrict outbound requests from the auth server to private networks at the network layer.
  • Clients registered through CIMD cannot use back-channel logout.

Back-channel logout requires the JWT plugin, which signs Logout Tokens. With disableJwtPlugin: true, registering a backchannel_logout_uri fails and discovery advertises backchannel_logout_supported: false.

Delivery runs through advanced.backgroundTasks.handler when one is set, so a slow client cannot delay sign-out. Without a handler it runs before the sign-out response returns, so set one if you deploy to serverless runtimes.

Clients on an internal network

If a client runs on an internal network, its public-looking name can resolve to a private address, as in a split-horizon DNS setup. The delivery check then skips it. To deliver to it, add the origin of its backchannel_logout_uri to trustedOrigins:

auth.ts
export const auth = entroAuth({
  trustedOrigins: ["https://app.internal.example.com"], 
  plugins: [oauthProvider({ /* ... */ }), jwt()],
});

An origin in trustedOrigins skips only the DNS check, because you vouch for where that name points. Registration and delivery still reject a loopback or private IP literal and a name such as localhost, so the URI needs a host name or public address that registration accepts.

Clients choose their own backchannel_logout_uri. Anyone who can register a client, including through dynamic client registration, can point it at any host that a trustedOrigins entry matches, and the server then sends a Logout Token there without checking where the name resolves. Wildcard entries follow the pattern rules, so a pattern such as https://*.example.com, which other features may already use, covers every host under it. The origin of your configured baseURL is always trusted. List exact origins, and never list a pattern that covers a name someone else can create.

Delivery uses the origins configured at initialization, whether you set them with an array, the ENTRO_AUTH_TRUSTED_ORIGINS variable, or a callback. A callback runs once without a Request for this purpose. An origin that only a request supplies does not count, such as one a callback returns for a particular Request or the origin of the Host header when you set no baseURL, because the sign-out request comes from the party this check guards against.

To find clients that stopped receiving tokens, search your logs for back-channel logout to client <id> skipped. The warning names the reason.

Password reset

A password reset is recovery from a compromised credential, so Entro Auth revokes every access and refresh token stored for the user, including offline_access grants that no session holds. A grant created during the compromise would otherwise outlive the reset.

  • It applies when emailAndPassword.revokeSessionsOnPasswordReset is on and revokeGrantsOnPasswordReset is not false, for /reset-password and the reset endpoints of the email OTP and phone number plugins.
  • It runs from the reset itself, so it covers a user with no live session. A client that refreshes afterwards gets 400 invalid_grant and must start a new authorization request.
  • JWT access tokens stay valid until they expire, or until the session they carry as sid ended, which the reset does. With revocableJwtAccessTokens, those of a grant that has a stored refresh token or opaque access token are revoked too. A JWT issued without a refresh token has no stored record to find.
  • Signing out and revoking all sessions keep offline_access grants, as §2.7 allows. A password reset revokes them.
  • Set revokeGrantsOnPasswordReset: false to keep a user's tokens across a reset. The reset still ends the user's sessions.

The revocation also fails a refresh that is still issuing tokens for a revoked grant. A pending authorization code fails at redemption, because the reset ended the session it was issued for, unless that redemption already passed its session check.

Front-channel logout

Front-Channel Logout notifies clients through the user's browser. When a user logs out at /oauth2/end-session, Entro Auth renders a page with one hidden iframe per client that holds tokens on the session. Each iframe loads that client's frontchannel_logout_uri, so the client can clear its own session cookies. As with back-channel logout, Entro Auth finds these clients through the opaque access tokens and refresh tokens stored for the session. A client that holds only a JWT access token gets no iframe.

The iframes are third-party content. Safari blocks third-party cookies, Firefox partitions them by default, and Chrome blocks them in Incognito and for users who turn them off. A client on a different site therefore often cannot see its session cookie inside the iframe. Front-channel logout is reliable only when your provider and its clients share a registrable domain, such as auth.example.com and app.example.com. Use back-channel logout when clients run on other sites or when logout must not depend on the browser.

To opt a client in, register a frontchannel_logout_uri on the same scheme, host, and port as one of its redirect_uris:

admin-create-oauth.ts
await auth.api.adminCreateOAuthClient({
  headers,
  body: {
    redirect_uris: ["https://app.example.com/api/auth/callback"],
    enable_end_session: true,
    frontchannel_logout_uri: "https://app.example.com/logout/frontchannel", 
  },
});

Entro Auth loads the URI with iss and sid query parameters added to any query it already has, replacing a registered iss or sid. sid matches the sid claim in the ID tokens issued to that client, so the client can ignore requests that don't match its current session. The client's endpoint should clear its session state and respond with Cache-Control: no-store. Setting frontchannel_logout_session_required: true is accepted and stored, but changes nothing, because Entro Auth always sends both parameters.

Entro Auth validates the frontchannel_logout_uri at registration and on every client update:

  • It must be an absolute http or https URL with no fragment and no credentials.
  • An http URL must be on a loopback host. allowInsecureRedirectUri does not apply to it.
  • Its scheme, host, and port must match one of the client's redirect_uris, as the specification requires. A URI that matches a loopback redirect URI, or an https redirect URI on a private network, is accepted, because the browser loads it, not the server.
  • It does not require the JWT plugin, because nothing is signed.

A URI that fails validation is rejected with invalid_client_metadata.

When the iframes are rendered

Entro Auth renders the page only when the session actually ends during a browser navigation to /oauth2/end-session, either with a verified id_token_hint or after the user confirms logout. If a session.delete.before hook vetoes the deletion, no client is notified. When no front-channel client holds tokens on the session, the endpoint redirects or shows the logged-out page as before.

Front-channel logout does not run for:

  • /sign-out or admin session revocation, because no logout page is shown in the user's browser.
  • Fetch-style calls such as authClient.oauth2.endSession(), which keep the JSON response.
  • Session expiry, which does not delete the session when it happens.

Back-channel logout still fires for the first two, because they delete the session. A client that registers both URIs receives both notifications, so make the client's logout handlers idempotent.

After the iframes load, or after 3 seconds if a client doesn't respond, the page redirects to the verified post_logout_redirect_uri. Without one, it shows the logged-out message. Without JavaScript, the iframes still load and a meta refresh performs the redirect.

The page keeps the same Content Security Policy as the other logout pages, extended only with frame-src for the client origins and its own script. It sends Referrer-Policy: no-referrer, so the id_token_hint in the URL never reaches a client.

Entro Auth advertises frontchannel_logout_supported: true and frontchannel_logout_session_supported: true on both .well-known/openid-configuration and .well-known/oauth-authorization-server, whether or not the JWT plugin is enabled.

On this page