features.registration
OIDC Dynamic Client Registration 1.0 and RFC7591 - OAuth 2.0 Dynamic Client Registration Protocol
Specifies whether Dynamic Client Registration capabilities shall be enabled. When enabled, the authorization server shall expose a client registration endpoint that allows clients to dynamically register themselves with the authorization server at runtime, enabling automated client onboarding and configuration management.
default value:
{ enabled: false, idFactory: [Function: idFactory], // see expanded details below initialAccessToken: false, issueRegistrationAccessToken: true, policies: undefined, secretFactory: [AsyncFunction: secretFactory] // see expanded details below}(Click to expand) features.registration options details
idFactory
Section titled “idFactory”Specifies a helper function that shall be invoked to generate random client identifiers during dynamic client registration operations. This function enables customization of client identifier generation according to authorization server requirements and conventions.
default value:
function idFactory(ctx) { return nanoid();}initialAccessToken
Section titled “initialAccessToken”Specifies whether the registration endpoint shall require an initial access token as authorization for client registration requests. This configuration controls access to the dynamic registration functionality. Supported values include:
string- The authorization server shall validate the provided bearer token against this static initial access token valueboolean- When true, the authorization server shall require adapter-backed initial access tokens; when false, registration requests are processed without initial access tokens.
default value:
falseExample: (Click to expand) To add an adapter backed initial access token and retrieve its value.
new (provider.InitialAccessToken)({}).save().then(console.log);issueRegistrationAccessToken
Section titled “issueRegistrationAccessToken”Specifies whether a registration access token shall be issued upon successful client registration. This configuration determines if clients receive tokens for subsequent registration management operations. Supported values include:
true- Registration access tokens shall be issued for all successful registrationsfalse- Registration access tokens shall not be issued- Function - A function that shall be invoked to dynamically determine token issuance based on request context and authorization server policy
default value:
trueExample: (Click to expand) To determine if a registration access token should be issued dynamically.
// @param ctx - koa request contextasync issueRegistrationAccessToken(ctx) { return policyImplementation(ctx)}policies
Section titled “policies”Specifies registration and registration management policies that shall be applied to client metadata properties during dynamic registration operations. Policies are synchronous or asynchronous functions assigned to Initial Access Tokens that execute before standard client property validations. Multiple policies may be assigned to an Initial Access Token, and by default, the same policies shall transfer to the Registration Access Token. Policy functions may throw errors to reject registration requests or modify the client properties object before validation.
recommendation: Referenced policies MUST always be present when encountered on a token; an AssertionError will be thrown inside the request context if a policy is not found, resulting in a 500 Server Error.
recommendation: The same policies will be assigned to the Registration Access Token after a successful validation. If you wish to assign different policies to the Registration Access Token:
// inside your final ran policyctx.oidc.entities.RegistrationAccessToken.policies = ['update-policy'];default value:
undefinedExample: (Click to expand) To define registration and registration management policies.
To define policy functions configure features.registration to be an object like so:
{ enabled: true, initialAccessToken: true, // to enable adapter-backed initial access tokens policies: { 'my-policy': function (ctx, properties) { // @param ctx - koa request context // @param properties - the client properties which are about to be validated // example of setting a default if (!('client_name' in properties)) { properties.client_name = generateRandomClientName(); } // example of forcing a value properties.userinfo_signed_response_alg = 'RS256'; // example of throwing a validation error if (someCondition(ctx, properties)) { throw new errors.InvalidClientMetadata('validation error message'); } }, 'my-policy-2': async function (ctx, properties) {}, },}An Initial Access Token with those policies being executed (one by one in that order) is created like so
new (provider.InitialAccessToken)({ policies: ['my-policy', 'my-policy-2'] }).save().then(console.log);secretFactory
Section titled “secretFactory”Specifies a helper function that shall be invoked to generate random client secrets during dynamic client registration operations. This function enables customization of client secret generation according to authorization server security requirements and entropy specifications.
default value:
async function secretFactory(ctx) { return crypto.randomBytes(64).toString('base64url');}