From ca914c97e0316a33ec2853e02d7268c3638f91db Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 19 Feb 2024 13:03:53 +0000 Subject: [PATCH] Allow specifying OIDC url state parameter for passing data to callback (#4068) * Allow specifying more OIDC client metadata for dynamic registration Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Allow specifying url_state for dynamic oidc client registration Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Export NonEmptyArray type Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Allow specifying more OIDC client metadata for dynamic registration Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Export NonEmptyArray type Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix test Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/oidc/authorize.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/oidc/authorize.ts b/src/oidc/authorize.ts index 557a5c7e4..9e0546ad6 100644 --- a/src/oidc/authorize.ts +++ b/src/oidc/authorize.ts @@ -129,6 +129,7 @@ export const generateAuthorizationUrl = async ( * @param nonce - state * @param prompt - indicates to the OP which flow the user should see - eg login or registration * See https://openid.net/specs/openid-connect-prompt-create-1_0.html#name-prompt-parameter + * @param urlState - value to append to the opaque state identifier to uniquely identify the callback * @returns a Promise with the url as a string */ export const generateOidcAuthorizationUrl = async ({ @@ -139,6 +140,7 @@ export const generateOidcAuthorizationUrl = async ({ identityServerUrl, nonce, prompt, + urlState, }: { clientId: string; metadata: ValidatedIssuerMetadata; @@ -147,8 +149,9 @@ export const generateOidcAuthorizationUrl = async ({ redirectUri: string; nonce: string; prompt?: string; + urlState?: string; }): Promise => { - const scope = await generateScope(); + const scope = generateScope(); const oidcClient = new OidcClient({ ...metadata, client_id: clientId, @@ -164,6 +167,7 @@ export const generateOidcAuthorizationUrl = async ({ state: userState, nonce, prompt, + url_state: urlState, }); return request.url;