Merge pull request #8035 from zfalen-deloitte/bugfix/duplicate-backstage-token

Bugfix/duplicate backstage token
This commit is contained in:
Patrik Oldsberg
2021-11-15 11:50:17 +01:00
committed by GitHub
4 changed files with 15 additions and 5 deletions
@@ -22,7 +22,7 @@ import { OAuthHandlers } from './types';
const mockResponseData = {
providerInfo: {
accessToken: 'ACCESS_TOKEN',
idToken: 'ID_TOKEN',
token: 'ID_TOKEN',
expiresInSeconds: 10,
scope: 'email',
},
@@ -216,7 +216,7 @@ describe('OAuthAdapter', () => {
...mockResponseData,
backstageIdentity: {
id: mockResponseData.backstageIdentity.id,
idToken: 'my-id-token',
token: 'my-id-token',
},
});
});
@@ -233,10 +233,12 @@ export class OAuthAdapter implements AuthProviderRouteHandlers {
return;
}
if (!identity.idToken) {
identity.idToken = await this.options.tokenIssuer.issueToken({
if (!(identity.token || identity.idToken)) {
identity.token = await this.options.tokenIssuer.issueToken({
claims: { sub: identity.id },
});
} else if (!identity.token && identity.idToken) {
identity.token = identity.idToken;
}
}