Skip to content

PKCE

RFC7636 - Proof Key for Code Exchange (PKCE)

Specifies the PKCE configuration, such as a policy check on the required use of PKCE.


Configures if and when the authorization server requires clients to use PKCE. This helper is called whenever an authorization request lacks the code_challenge parameter. Return:

  • false to allow the request to continue without PKCE
  • true to abort the request

default value:

function pkceRequired(ctx, client) {
// All public clients MUST use PKCE as per
// https://www.rfc-editor.org/rfc/rfc9700.html#section-2.1.1-2.1
if (client.clientAuthMethod === 'none') {
return true;
}
const fapiProfile = ctx.oidc.isFapi('2.0', '1.0 Final');
// FAPI 2.0 as per
// https://openid.net/specs/fapi-security-profile-2_0-final.html#section-5.3.2.2-2.5
if (fapiProfile === '2.0') {
return true;
}
// FAPI 1.0 Advanced as per
// https://openid.net/specs/openid-financial-api-part-2-1_0-final.html#authorization-server
if (fapiProfile === '1.0 Final' && ctx.oidc.route === 'pushed_authorization_request') {
return true;
}
// In all other cases use of PKCE is RECOMMENDED as per
// https://www.rfc-editor.org/rfc/rfc9700.html#section-2.1.1-2.2
// but the server doesn't force them to.
return false;
}