Add custom authorization header for OAuth2.0 strategy
Signed-off-by: Sonali Mishra <sonali.priyam@gmail.com> Signed-off-by: Sonali Mishra <sonali.mishra@grabtaxi.com>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
---
|
||||
'@backstage/plugin-auth-backend': patch
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
## '@backstage/plugin-auth-backend': patch
|
||||
|
||||
Added custom OAuth2.0 authorization header for generic oauth2 provider.
|
||||
@@ -85,6 +85,12 @@ export class OAuth2AuthProvider implements OAuthHandlers {
|
||||
tokenURL: options.tokenUrl,
|
||||
passReqToCallback: false as true,
|
||||
scope: options.scope,
|
||||
customHeaders: {
|
||||
Authorization: `Basic ${this.encodeClientCredentials(
|
||||
options.clientId,
|
||||
options.clientSecret,
|
||||
)}`,
|
||||
},
|
||||
},
|
||||
(
|
||||
accessToken: any,
|
||||
@@ -187,6 +193,10 @@ export class OAuth2AuthProvider implements OAuthHandlers {
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
encodeClientCredentials(clientID: string, clientSecret: string): string {
|
||||
return Buffer.from(`${clientID}:${clientSecret}`).toString('base64');
|
||||
}
|
||||
}
|
||||
|
||||
export const oAuth2DefaultSignInResolver: SignInResolver<OAuthResult> = async (
|
||||
|
||||
Reference in New Issue
Block a user