From 36e4377480aff6b2939fa8a7dcb6f48328855b82 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 17 Jun 2022 12:17:29 +0200 Subject: [PATCH] auth-backend: remove deprecated identity exports Signed-off-by: Patrik Oldsberg --- plugins/auth-backend/src/identity/index.ts | 2 +- plugins/auth-backend/src/identity/types.ts | 4 +- plugins/auth-backend/src/index.ts | 2 +- .../auth-backend/src/lib/catalog/helpers.ts | 41 ------------------- plugins/auth-backend/src/lib/catalog/index.ts | 1 - .../src/lib/oauth/OAuthAdapter.ts | 8 +--- .../resolvers/CatalogAuthResolverContext.ts | 3 +- 7 files changed, 5 insertions(+), 56 deletions(-) delete mode 100644 plugins/auth-backend/src/lib/catalog/helpers.ts diff --git a/plugins/auth-backend/src/identity/index.ts b/plugins/auth-backend/src/identity/index.ts index cb2f369668..a5e0dd4b80 100644 --- a/plugins/auth-backend/src/identity/index.ts +++ b/plugins/auth-backend/src/identity/index.ts @@ -20,4 +20,4 @@ export { DatabaseKeyStore } from './DatabaseKeyStore'; export { MemoryKeyStore } from './MemoryKeyStore'; export { FirestoreKeyStore } from './FirestoreKeyStore'; export { KeyStores } from './KeyStores'; -export type { KeyStore, TokenIssuer, TokenParams } from './types'; +export type { KeyStore, TokenParams } from './types'; diff --git a/plugins/auth-backend/src/identity/types.ts b/plugins/auth-backend/src/identity/types.ts index 5a350284e5..f0959e90bd 100644 --- a/plugins/auth-backend/src/identity/types.ts +++ b/plugins/auth-backend/src/identity/types.ts @@ -37,12 +37,10 @@ export type TokenParams = { }; }; -// TODO(Rugvip): This should at least be made internal /** * A TokenIssuer is able to issue verifiable ID Tokens on demand. * - * @public - * @deprecated This interface is deprecated and will be removed in a future release. + * @internal */ export type TokenIssuer = { /** diff --git a/plugins/auth-backend/src/index.ts b/plugins/auth-backend/src/index.ts index d51cb3f1eb..f8a8580359 100644 --- a/plugins/auth-backend/src/index.ts +++ b/plugins/auth-backend/src/index.ts @@ -21,7 +21,7 @@ */ export * from './service/router'; -export type { TokenIssuer, TokenParams } from './identity'; +export type { TokenParams } from './identity'; export * from './providers'; // flow package provides 2 functions diff --git a/plugins/auth-backend/src/lib/catalog/helpers.ts b/plugins/auth-backend/src/lib/catalog/helpers.ts deleted file mode 100644 index 3ff1b5da05..0000000000 --- a/plugins/auth-backend/src/lib/catalog/helpers.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2021 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { - RELATION_MEMBER_OF, - stringifyEntityRef, - UserEntity, -} from '@backstage/catalog-model'; -import { TokenParams } from '../../identity'; - -/** - * @deprecated use {@link getDefaultOwnershipEntityRefs} instead - */ -export function getEntityClaims(entity: UserEntity): TokenParams['claims'] { - const userRef = stringifyEntityRef(entity); - - const membershipRefs = - entity.relations - ?.filter( - r => r.type === RELATION_MEMBER_OF && r.targetRef.startsWith('group:'), - ) - .map(r => r.targetRef) ?? []; - - return { - sub: userRef, - ent: [userRef, ...membershipRefs], - }; -} diff --git a/plugins/auth-backend/src/lib/catalog/index.ts b/plugins/auth-backend/src/lib/catalog/index.ts index 0d1aa4a6f7..f0f5b10808 100644 --- a/plugins/auth-backend/src/lib/catalog/index.ts +++ b/plugins/auth-backend/src/lib/catalog/index.ts @@ -15,4 +15,3 @@ */ export { CatalogIdentityClient } from './CatalogIdentityClient'; -export { getEntityClaims } from './helpers'; diff --git a/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts b/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts index 5be4b7e3c0..9c28ed8fad 100644 --- a/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts +++ b/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts @@ -31,7 +31,6 @@ import { isError, NotAllowedError, } from '@backstage/errors'; -import { TokenIssuer } from '../../identity/types'; import { defaultCookieConfigurer, readState, verifyNonce } from './helpers'; import { postMessageResponse, ensuresXRequestedWith } from '../flow'; import { @@ -52,8 +51,6 @@ export type Options = { cookieDomain: string; cookiePath: string; appOrigin: string; - /** @deprecated This option is no longer needed */ - tokenIssuer?: TokenIssuer; isOriginAllowed: (origin: string) => boolean; callbackUrl: string; }; @@ -61,10 +58,7 @@ export class OAuthAdapter implements AuthProviderRouteHandlers { static fromConfig( config: AuthProviderConfig, handlers: OAuthHandlers, - options: Pick< - Options, - 'providerId' | 'persistScopes' | 'tokenIssuer' | 'callbackUrl' - >, + options: Pick, ): OAuthAdapter { const { origin: appOrigin } = new URL(config.appUrl); diff --git a/plugins/auth-backend/src/lib/resolvers/CatalogAuthResolverContext.ts b/plugins/auth-backend/src/lib/resolvers/CatalogAuthResolverContext.ts index 1a1fdd7a36..cbc2439563 100644 --- a/plugins/auth-backend/src/lib/resolvers/CatalogAuthResolverContext.ts +++ b/plugins/auth-backend/src/lib/resolvers/CatalogAuthResolverContext.ts @@ -25,8 +25,7 @@ import { } from '@backstage/catalog-model'; import { ConflictError, InputError, NotFoundError } from '@backstage/errors'; import { Logger } from 'winston'; -import { TokenIssuer } from '../..'; -import { TokenParams } from '../../identity'; +import { TokenIssuer, TokenParams } from '../../identity/types'; import { AuthResolverContext } from '../../providers'; import { AuthResolverCatalogUserQuery } from '../../providers/types'; import { CatalogIdentityClient } from '../catalog';