From 8949803609bb1a541f7a1dfd887ab94b1b7771a3 Mon Sep 17 00:00:00 2001 From: Jack Palmer Date: Thu, 5 Feb 2026 13:23:57 +0000 Subject: [PATCH] feat: auth0 strategy - set invitation query parameter as authorizationParam when present Signed-off-by: Jack Palmer --- .changeset/calm-jars-wear.md | 5 +++++ .../src/strategy.ts | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 .changeset/calm-jars-wear.md diff --git a/.changeset/calm-jars-wear.md b/.changeset/calm-jars-wear.md new file mode 100644 index 0000000000..2b71931600 --- /dev/null +++ b/.changeset/calm-jars-wear.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-auth-backend-module-auth0-provider': minor +--- + +Set invitation query parameter as authorizationParam when present diff --git a/plugins/auth-backend-module-auth0-provider/src/strategy.ts b/plugins/auth-backend-module-auth0-provider/src/strategy.ts index a8699555a7..c2eb2a283c 100644 --- a/plugins/auth-backend-module-auth0-provider/src/strategy.ts +++ b/plugins/auth-backend-module-auth0-provider/src/strategy.ts @@ -16,6 +16,7 @@ import Auth0InternalStrategy from 'passport-auth0'; import type { StateStore } from 'passport-oauth2'; +import type express from 'express'; /** @public */ export interface Auth0StrategyOptionsWithRequest { @@ -47,15 +48,24 @@ export class Auth0Strategy extends Auth0InternalStrategy { this.organization = options.organization; } + authenticate(req: express.Request, options: Record): void { + super.authenticate(req, { + ...options, + invitation: req.query.invitation?.toString(), + }); + } + authorizationParams(options: Record): Record { const params = super.authorizationParams(options); if (this.organization) { - return { - ...params, - organization: this.organization, - }; + params.organization = this.organization; } + + if (options.invitation) { + params.invitation = options.invitation; + } + return params; } }