feat: auth0 strategy - set invitation query parameter as authorizationParam when present
Signed-off-by: Jack Palmer <jackpalmer@spotify.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-auth-backend-module-auth0-provider': minor
|
||||
---
|
||||
|
||||
Set invitation query parameter as authorizationParam when present
|
||||
@@ -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<string, any>): void {
|
||||
super.authenticate(req, {
|
||||
...options,
|
||||
invitation: req.query.invitation?.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
authorizationParams(options: Record<string, any>): Record<string, any> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user