From 3b39323f2631862c690d5c1235395f9d389227a2 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 2 Dec 2021 11:04:33 +0100 Subject: [PATCH] chore: revert some of the provider changes are they are handled in the OAuthAdapter now Signed-off-by: blam --- .../src/providers/atlassian/provider.ts | 5 +- .../src/providers/github/provider.test.ts | 55 +++---------------- .../src/providers/github/provider.ts | 4 +- 3 files changed, 9 insertions(+), 55 deletions(-) diff --git a/plugins/auth-backend/src/providers/atlassian/provider.ts b/plugins/auth-backend/src/providers/atlassian/provider.ts index 99e1ebd2d8..e19f29a3a4 100644 --- a/plugins/auth-backend/src/providers/atlassian/provider.ts +++ b/plugins/auth-backend/src/providers/atlassian/provider.ts @@ -45,7 +45,6 @@ import express from 'express'; import { TokenIssuer } from '../../identity'; import { CatalogIdentityClient } from '../../lib/catalog'; import { Logger } from 'winston'; -import { decorateWithIdentity } from '../decorateWithIdentity'; export type AtlassianAuthProviderOptions = OAuthProviderOptions & { scopes: string; @@ -137,7 +136,7 @@ export class AtlassianAuthProvider implements OAuthHandlers { }; if (this.signInResolver) { - const resolverResponse = await this.signInResolver( + response.backstageIdentity = await this.signInResolver( { result, profile, @@ -148,8 +147,6 @@ export class AtlassianAuthProvider implements OAuthHandlers { logger: this.logger, }, ); - - response.backstageIdentity = decorateWithIdentity(resolverResponse); } return response; diff --git a/plugins/auth-backend/src/providers/github/provider.test.ts b/plugins/auth-backend/src/providers/github/provider.test.ts index 02c3367914..e418ab22c2 100644 --- a/plugins/auth-backend/src/providers/github/provider.test.ts +++ b/plugins/auth-backend/src/providers/github/provider.test.ts @@ -41,12 +41,7 @@ describe('GithubAuthProvider', () => { const tokenIssuer: TokenIssuer = { listPublicKeys: jest.fn(), async issueToken(params) { - const tokenContents = { - sub: params.claims.sub, - ent: params.claims.ent ?? [], - }; - - return `eyblob.${btoa(JSON.stringify(tokenContents))}.eyblob`; + return `token-for-${params.claims.sub}`; }, }; const catalogIdentityClient = { @@ -98,13 +93,7 @@ describe('GithubAuthProvider', () => { const expected = { backstageIdentity: { id: 'jimmymarkum', - token: - 'eyblob.eyJzdWIiOiJqaW1teW1hcmt1bSIsImVudCI6WyJ1c2VyOmRlZmF1bHQvamltbXltYXJrdW0iXX0=.eyblob', - identity: { - ownershipEntityRefs: ['user:default/jimmymarkum'], - type: 'user', - userEntityRef: 'jimmymarkum', - }, + token: 'token-for-jimmymarkum', }, providerInfo: { accessToken: '19xasczxcm9n7gacn9jdgm19me', @@ -149,13 +138,7 @@ describe('GithubAuthProvider', () => { const expected = { backstageIdentity: { id: 'jimmymarkum', - token: - 'eyblob.eyJzdWIiOiJqaW1teW1hcmt1bSIsImVudCI6WyJ1c2VyOmRlZmF1bHQvamltbXltYXJrdW0iXX0=.eyblob', - identity: { - type: 'user', - ownershipEntityRefs: ['user:default/jimmymarkum'], - userEntityRef: 'jimmymarkum', - }, + token: 'token-for-jimmymarkum', }, providerInfo: { accessToken: '19xasczxcm9n7gacn9jdgm19me', @@ -198,13 +181,7 @@ describe('GithubAuthProvider', () => { const expected = { backstageIdentity: { id: 'jimmymarkum', - token: - 'eyblob.eyJzdWIiOiJqaW1teW1hcmt1bSIsImVudCI6WyJ1c2VyOmRlZmF1bHQvamltbXltYXJrdW0iXX0=.eyblob', - identity: { - type: 'user', - ownershipEntityRefs: ['user:default/jimmymarkum'], - userEntityRef: 'jimmymarkum', - }, + token: 'token-for-jimmymarkum', }, providerInfo: { accessToken: '19xasczxcm9n7gacn9jdgm19me', @@ -247,13 +224,7 @@ describe('GithubAuthProvider', () => { const expected = { backstageIdentity: { id: 'daveboyle', - token: - 'eyblob.eyJzdWIiOiJkYXZlYm95bGUiLCJlbnQiOlsidXNlcjpkZWZhdWx0L2RhdmVib3lsZSJdfQ==.eyblob', - identity: { - type: 'user', - ownershipEntityRefs: ['user:default/daveboyle'], - userEntityRef: 'daveboyle', - }, + token: 'token-for-daveboyle', }, providerInfo: { accessToken: @@ -297,13 +268,7 @@ describe('GithubAuthProvider', () => { response: { backstageIdentity: { id: 'ipd12039', - token: - 'eyblob.eyJzdWIiOiJpcGQxMjAzOSIsImVudCI6WyJ1c2VyOmRlZmF1bHQvaXBkMTIwMzkiXX0=.eyblob', - identity: { - type: 'user', - ownershipEntityRefs: ['user:default/ipd12039'], - userEntityRef: 'ipd12039', - }, + token: 'token-for-ipd12039', }, providerInfo: { accessToken: 'a.b.c', @@ -356,13 +321,7 @@ describe('GithubAuthProvider', () => { expect(response).toEqual({ backstageIdentity: { id: 'mockuser', - token: - 'eyblob.eyJzdWIiOiJtb2NrdXNlciIsImVudCI6WyJ1c2VyOmRlZmF1bHQvbW9ja3VzZXIiXX0=.eyblob', - identity: { - type: 'user', - ownershipEntityRefs: ['user:default/mockuser'], - userEntityRef: 'mockuser', - }, + token: 'token-for-mockuser', }, profile: { displayName: 'Mocked User', diff --git a/plugins/auth-backend/src/providers/github/provider.ts b/plugins/auth-backend/src/providers/github/provider.ts index e9d019f4ac..c7e82cc5ff 100644 --- a/plugins/auth-backend/src/providers/github/provider.ts +++ b/plugins/auth-backend/src/providers/github/provider.ts @@ -45,7 +45,6 @@ import { } from '../../lib/oauth'; import { CatalogIdentityClient } from '../../lib/catalog'; import { TokenIssuer } from '../../identity'; -import { decorateWithIdentity } from '../decorateWithIdentity'; type PrivateInfo = { refreshToken?: string; @@ -168,7 +167,7 @@ export class GithubAuthProvider implements OAuthHandlers { }; if (this.signInResolver) { - const signInResolverResult = await this.signInResolver( + response.backstageIdentity = await this.signInResolver( { result, profile, @@ -179,7 +178,6 @@ export class GithubAuthProvider implements OAuthHandlers { logger: this.logger, }, ); - response.backstageIdentity = decorateWithIdentity(signInResolverResult); } return response;