diff --git a/.changeset/popular-pots-yell.md b/.changeset/popular-pots-yell.md new file mode 100644 index 0000000000..f0decc9fb8 --- /dev/null +++ b/.changeset/popular-pots-yell.md @@ -0,0 +1,11 @@ +--- +'@backstage/plugin-auth-backend': minor +--- + +**BREAKING**: Removed all directly exported auth provider factories, option types, and sign-in resolvers. For example: `AwsAlbProviderOptions`, `bitbucketUserIdSignInResolver`, `createGithubProvider`. These are all still accessible via the `providers` export. For example, use `providers.github.create()` rather than `createGithubProvider()`, and `providers.bitbucket.resolvers.userIdMatchingUserEntityAnnotation()` rather than `bitbucketUserIdSignInResolver`. + +**BREAKING**: Removed the exported `AuthProviderFactoryOptions` type as well as the deprecated option fields of the `AuthProviderFactory` callback. This includes the `tokenManager`, `tokenIssuer`, `discovery`, and `catalogApi` fields. Existing usage of these should be replaced with the new utilities in the `resolverContext` field. The deprecated `TokenIssuer` type is now also removed, since it is no longer used. + +**BREAKING**: Removed `getEntityClaims`, use `getDefaultOwnershipEntityRefs` instead. + +**DEPRECATION**: Deprecated `AtlassianAuthProvider` as it was unintentionally exported. diff --git a/contrib/docs/tutorials/aws-alb-aad-oidc-auth.md b/contrib/docs/tutorials/aws-alb-aad-oidc-auth.md index 2b3e02c18b..3cedf5634b 100644 --- a/contrib/docs/tutorials/aws-alb-aad-oidc-auth.md +++ b/contrib/docs/tutorials/aws-alb-aad-oidc-auth.md @@ -122,10 +122,7 @@ When using ALB auth you can configure it as described [here](https://backstage.i - replace the content of `packages/backend/plugin/auth.ts` with the below and tweak it according to your needs. ```ts -import { - createRouter, - createAwsAlbProvider, -} from '@backstage/plugin-auth-backend'; +import { createRouter, providers } from '@backstage/plugin-auth-backend'; import { DEFAULT_NAMESPACE, stringifyEntityRef, @@ -145,7 +142,7 @@ export default async function createPlugin({ database, discovery, providerFactories: { - awsalb: createAwsAlbProvider({ + awsalb: providers.awsAlb.create({ authHandler: async ({ fullProfile }) => { let email: string | undefined = undefined; if (fullProfile.emails && fullProfile.emails.length > 0) { diff --git a/docs/auth/bitbucket/provider.md b/docs/auth/bitbucket/provider.md index c54fb75ffa..36859dab45 100644 --- a/docs/auth/bitbucket/provider.md +++ b/docs/auth/bitbucket/provider.md @@ -57,7 +57,7 @@ In order to use the Bitbucket provider for sign-in, you must configure it with a `signIn.resolver`. See the [Sign-In Resolver documentation](../identity-resolver.md) for more details on how this is done. Note that for the Bitbucket provider, you'll want to use -`bitbucket` as the provider ID, and `createBitbucketProvider` for the provider +`bitbucket` as the provider ID, and `providers.bitbucket.create` for the provider factory. The `@backstage/plugin-auth-backend` plugin also comes with two built-in @@ -74,16 +74,14 @@ same way, but uses the Bitbucket user ID instead, and matches on the The following is an example of how to use one of the built-in resolvers: ```ts -import { - createBitbucketProvider, - bitbucketUsernameSignInResolver, -} from '@backstage/plugin-auth-backend'; +import { providers } from '@backstage/plugin-auth-backend'; // ... providerFactories: { - bitbucket: createBitbucketProvider({ + bitbucket: providers.bitbucket.create({ signIn: { - resolver: bitbucketUsernameSignInResolver, + resolver: + providers.bitbucket.resolvers.usernameMatchingUserEntityAnnotation(), }, }), }, diff --git a/docs/auth/identity-resolver.md b/docs/auth/identity-resolver.md index 8019739e14..06ada040e4 100644 --- a/docs/auth/identity-resolver.md +++ b/docs/auth/identity-resolver.md @@ -333,7 +333,7 @@ export default async function createPlugin( return await createRouter({ ... providerFactories: { - google: createGoogleProvider({ + google: providers.google.create({ authHandler: async ({ fullProfile // Type: passport.Profile, idToken // Type: (Optional) string, diff --git a/plugins/auth-backend/api-report.md b/plugins/auth-backend/api-report.md index bb25ff6d57..9e567cc6ab 100644 --- a/plugins/auth-backend/api-report.md +++ b/plugins/auth-backend/api-report.md @@ -23,9 +23,7 @@ import { TokenSet } from 'openid-client'; import { UserEntity } from '@backstage/catalog-model'; import { UserinfoResponse } from 'openid-client'; -// Warning: (ae-missing-release-tag) "AtlassianAuthProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) +// @public @deprecated (undocumented) export class AtlassianAuthProvider implements OAuthHandlers { // Warning: (ae-forgotten-export) The symbol "AtlassianAuthProviderOptions" needs to be exported by the entry point index.d.ts constructor(options: AtlassianAuthProviderOptions); @@ -45,22 +43,6 @@ export class AtlassianAuthProvider implements OAuthHandlers { start(req: OAuthStartRequest): Promise; } -// @public @deprecated (undocumented) -export type AtlassianProviderOptions = { - authHandler?: AuthHandler; - signIn?: { - resolver: SignInResolver; - }; -}; - -// @public @deprecated (undocumented) -export type Auth0ProviderOptions = { - authHandler?: AuthHandler; - signIn?: { - resolver: SignInResolver; - }; -}; - // @public export type AuthHandler = ( input: TAuthResult, @@ -89,26 +71,8 @@ export type AuthProviderFactory = (options: { config: Config; logger: Logger; resolverContext: AuthResolverContext; - tokenManager: TokenManager; - tokenIssuer: TokenIssuer; - discovery: PluginEndpointDiscovery; - catalogApi: CatalogApi; }) => AuthProviderRouteHandlers; -// Warning: (ae-missing-release-tag) "AuthProviderFactoryOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public @deprecated (undocumented) -export type AuthProviderFactoryOptions = { - providerId: string; - globalConfig: AuthProviderConfig; - config: Config; - logger: Logger; - tokenManager: TokenManager; - tokenIssuer: TokenIssuer; - discovery: PluginEndpointDiscovery; - catalogApi: CatalogApi; -}; - // Warning: (ae-missing-release-tag) "AuthProviderRouteHandlers" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @@ -139,9 +103,6 @@ export type AuthResolverCatalogUserQuery = // @public export type AuthResolverContext = { - logger: Logger; - tokenIssuer: TokenIssuer; - catalogIdentityClient: CatalogIdentityClient; issueToken(params: TokenParams): Promise<{ token: string; }>; @@ -160,14 +121,6 @@ export type AuthResponse = { backstageIdentity?: BackstageIdentityResponse; }; -// @public @deprecated (undocumented) -export type AwsAlbProviderOptions = { - authHandler?: AuthHandler; - signIn: { - resolver: SignInResolver; - }; -}; - // @public (undocumented) export type AwsAlbResult = { fullProfile: Profile; @@ -206,20 +159,6 @@ export type BitbucketPassportProfile = Profile & { }; }; -// @public @deprecated (undocumented) -export type BitbucketProviderOptions = { - authHandler?: AuthHandler; - signIn?: { - resolver: SignInResolver; - }; -}; - -// @public @deprecated (undocumented) -export const bitbucketUserIdSignInResolver: SignInResolver; - -// @public @deprecated (undocumented) -export const bitbucketUsernameSignInResolver: SignInResolver; - // Warning: (ae-missing-release-tag) "CatalogIdentityClient" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @@ -242,189 +181,6 @@ export type CookieConfigurer = (ctx: { secure: boolean; }; -// @public @deprecated (undocumented) -export const createAtlassianProvider: ( - options?: - | { - authHandler?: AuthHandler | undefined; - signIn?: - | { - resolver: SignInResolver; - } - | undefined; - } - | undefined, -) => AuthProviderFactory; - -// @public @deprecated (undocumented) -export const createAuth0Provider: ( - options?: - | { - authHandler?: AuthHandler | undefined; - signIn?: - | { - resolver: SignInResolver; - } - | undefined; - } - | undefined, -) => AuthProviderFactory; - -// @public @deprecated (undocumented) -export const createAwsAlbProvider: ( - options?: - | { - authHandler?: AuthHandler | undefined; - signIn: { - resolver: SignInResolver; - }; - } - | undefined, -) => AuthProviderFactory; - -// @public @deprecated (undocumented) -export const createBitbucketProvider: ( - options?: - | { - authHandler?: AuthHandler | undefined; - signIn?: - | { - resolver: SignInResolver; - } - | undefined; - } - | undefined, -) => AuthProviderFactory; - -// @public @deprecated (undocumented) -export const createGcpIapProvider: (options: { - authHandler?: AuthHandler | undefined; - signIn: { - resolver: SignInResolver; - }; -}) => AuthProviderFactory; - -// @public @deprecated (undocumented) -export const createGithubProvider: ( - options?: - | { - authHandler?: AuthHandler | undefined; - signIn?: - | { - resolver: SignInResolver; - } - | undefined; - stateEncoder?: StateEncoder | undefined; - } - | undefined, -) => AuthProviderFactory; - -// @public @deprecated (undocumented) -export const createGitlabProvider: ( - options?: - | { - authHandler?: AuthHandler | undefined; - signIn?: - | { - resolver: SignInResolver; - } - | undefined; - } - | undefined, -) => AuthProviderFactory; - -// @public @deprecated (undocumented) -export const createGoogleProvider: ( - options?: - | { - authHandler?: AuthHandler | undefined; - signIn?: - | { - resolver: SignInResolver; - } - | undefined; - } - | undefined, -) => AuthProviderFactory; - -// @public @deprecated (undocumented) -export const createMicrosoftProvider: ( - options?: - | { - authHandler?: AuthHandler | undefined; - signIn?: - | { - resolver: SignInResolver; - } - | undefined; - } - | undefined, -) => AuthProviderFactory; - -// @public @deprecated (undocumented) -export const createOAuth2Provider: ( - options?: - | { - authHandler?: AuthHandler | undefined; - signIn?: - | { - resolver: SignInResolver; - } - | undefined; - } - | undefined, -) => AuthProviderFactory; - -// @public @deprecated (undocumented) -export const createOauth2ProxyProvider: (options: { - authHandler?: AuthHandler> | undefined; - signIn: { - resolver: SignInResolver>; - }; -}) => AuthProviderFactory; - -// @public @deprecated (undocumented) -export const createOidcProvider: ( - options?: - | { - authHandler?: AuthHandler | undefined; - signIn?: - | { - resolver: SignInResolver; - } - | undefined; - } - | undefined, -) => AuthProviderFactory; - -// @public @deprecated (undocumented) -export const createOktaProvider: ( - options?: - | { - authHandler?: AuthHandler | undefined; - signIn?: - | { - resolver: SignInResolver; - } - | undefined; - } - | undefined, -) => AuthProviderFactory; - -// @public @deprecated (undocumented) -export const createOneLoginProvider: ( - options?: - | { - authHandler?: AuthHandler | undefined; - signIn?: - | { - resolver: SignInResolver; - } - | undefined; - } - | undefined, -) => AuthProviderFactory; - // Warning: (ae-missing-release-tag) "createOriginFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -435,23 +191,7 @@ export function createOriginFilter(config: Config): (origin: string) => boolean; // @public (undocumented) export function createRouter(options: RouterOptions): Promise; -// @public @deprecated (undocumented) -export const createSamlProvider: ( - options?: - | { - authHandler?: AuthHandler | undefined; - signIn?: - | { - resolver: SignInResolver; - } - | undefined; - } - | undefined, -) => AuthProviderFactory; - -// Warning: (ae-missing-release-tag) "factories" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) +// @public export const defaultAuthProviderFactories: { [providerId: string]: AuthProviderFactory; }; @@ -466,14 +206,6 @@ export const encodeState: (state: OAuthState) => string; // @public (undocumented) export const ensuresXRequestedWith: (req: express.Request) => boolean; -// @public @deprecated (undocumented) -export type GcpIapProviderOptions = { - authHandler?: AuthHandler; - signIn: { - resolver: SignInResolver; - }; -}; - // @public export type GcpIapResult = { iapToken: GcpIapTokenInfo; @@ -489,11 +221,6 @@ export type GcpIapTokenInfo = { // @public export function getDefaultOwnershipEntityRefs(entity: Entity): string[]; -// Warning: (ae-missing-release-tag) "getEntityClaims" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public @deprecated (undocumented) -export function getEntityClaims(entity: UserEntity): TokenParams['claims']; - // Warning: (ae-missing-release-tag) "GithubOAuthResult" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -508,61 +235,6 @@ export type GithubOAuthResult = { refreshToken?: string; }; -// @public @deprecated (undocumented) -export type GithubProviderOptions = { - authHandler?: AuthHandler; - signIn?: { - resolver: SignInResolver; - }; - stateEncoder?: StateEncoder; -}; - -// @public @deprecated (undocumented) -export type GitlabProviderOptions = { - authHandler?: AuthHandler; - signIn?: { - resolver: SignInResolver; - }; -}; - -// @public @deprecated (undocumented) -export const googleEmailSignInResolver: SignInResolver; - -// @public @deprecated (undocumented) -export type GoogleProviderOptions = { - authHandler?: AuthHandler; - signIn?: { - resolver: SignInResolver; - }; -}; - -// @public @deprecated (undocumented) -export const microsoftEmailSignInResolver: SignInResolver; - -// @public @deprecated (undocumented) -export type MicrosoftProviderOptions = { - authHandler?: AuthHandler; - signIn?: { - resolver: SignInResolver; - }; -}; - -// @public @deprecated (undocumented) -export type OAuth2ProviderOptions = { - authHandler?: AuthHandler; - signIn?: { - resolver: SignInResolver; - }; -}; - -// @public @deprecated (undocumented) -export type Oauth2ProxyProviderOptions = { - authHandler: AuthHandler>; - signIn: { - resolver: SignInResolver>; - }; -}; - // @public export type OAuth2ProxyResult = { fullProfile: JWTPayload; @@ -584,10 +256,7 @@ export class OAuthAdapter implements AuthProviderRouteHandlers { static fromConfig( config: AuthProviderConfig, handlers: OAuthHandlers, - options: Pick< - Options, - 'providerId' | 'persistScopes' | 'tokenIssuer' | 'callbackUrl' - >, + options: Pick, ): OAuthAdapter; // (undocumented) logout(req: express.Request, res: express.Response): Promise; @@ -703,33 +372,6 @@ export type OidcAuthResult = { userinfo: UserinfoResponse; }; -// @public @deprecated (undocumented) -export type OidcProviderOptions = { - authHandler?: AuthHandler; - signIn?: { - resolver: SignInResolver; - }; -}; - -// @public @deprecated (undocumented) -export const oktaEmailSignInResolver: SignInResolver; - -// @public @deprecated (undocumented) -export type OktaProviderOptions = { - authHandler?: AuthHandler; - signIn?: { - resolver: SignInResolver; - }; -}; - -// @public @deprecated (undocumented) -export type OneLoginProviderOptions = { - authHandler?: AuthHandler; - signIn?: { - resolver: SignInResolver; - }; -}; - // Warning: (ae-missing-release-tag) "postMessageResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -1016,17 +658,6 @@ export type SamlAuthResult = { fullProfile: any; }; -// @public @deprecated (undocumented) -export const samlNameIdEntityNameSignInResolver: SignInResolver; - -// @public @deprecated (undocumented) -export type SamlProviderOptions = { - authHandler?: AuthHandler; - signIn?: { - resolver: SignInResolver; - }; -}; - // @public export type SignInInfo = { profile: ProfileInfo; @@ -1044,14 +675,6 @@ export type StateEncoder = (req: OAuthStartRequest) => Promise<{ encodedState: string; }>; -// @public @deprecated -export type TokenIssuer = { - issueToken(params: TokenParams): Promise; - listPublicKeys(): Promise<{ - keys: AnyJWK[]; - }>; -}; - // @public export type TokenParams = { claims: { @@ -1077,8 +700,4 @@ export type WebMessageResponse = type: 'authorization_response'; error: Error; }; - -// Warnings were encountered during analysis: -// -// src/identity/types.d.ts:38:9 - (ae-forgotten-export) The symbol "AnyJWK" needs to be exported by the entry point index.d.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..4765b50d7d 100644 --- a/plugins/auth-backend/src/identity/types.ts +++ b/plugins/auth-backend/src/identity/types.ts @@ -37,12 +37,8 @@ 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. */ 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'; diff --git a/plugins/auth-backend/src/providers/atlassian/index.ts b/plugins/auth-backend/src/providers/atlassian/index.ts index cf3eb901d9..8dff0197a3 100644 --- a/plugins/auth-backend/src/providers/atlassian/index.ts +++ b/plugins/auth-backend/src/providers/atlassian/index.ts @@ -14,8 +14,4 @@ * limitations under the License. */ -export { createAtlassianProvider } from './provider'; -export type { - AtlassianAuthProvider, - AtlassianProviderOptions, -} from './provider'; +export { atlassian, AtlassianAuthProvider } from './provider'; diff --git a/plugins/auth-backend/src/providers/atlassian/provider.ts b/plugins/auth-backend/src/providers/atlassian/provider.ts index 2aa85dab96..b693d226a2 100644 --- a/plugins/auth-backend/src/providers/atlassian/provider.ts +++ b/plugins/auth-backend/src/providers/atlassian/provider.ts @@ -58,6 +58,10 @@ export const atlassianDefaultAuthHandler: AuthHandler = async ({ profile: makeProfileInfo(fullProfile, params.id_token), }); +/** + * @public + * @deprecated This export is deprecated and will be removed in the future. + */ export class AtlassianAuthProvider implements OAuthHandlers { private readonly _strategy: AtlassianStrategy; private readonly signInResolver?: SignInResolver; @@ -161,25 +165,6 @@ export class AtlassianAuthProvider implements OAuthHandlers { } } -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type AtlassianProviderOptions = { - /** - * The profile transformation function used to verify and convert the auth response - * into the profile that will be presented to the user. - */ - authHandler?: AuthHandler; - - /** - * Configure sign-in for this provider, without it the provider can not be used to sign users in. - */ - signIn?: { - resolver: SignInResolver; - }; -}; - /** * Auth provider integration for atlassian auth * @@ -230,9 +215,3 @@ export const atlassian = createAuthProviderIntegration({ }); }, }); - -/** - * @public - * @deprecated Use `providers.atlassian.create` instead - */ -export const createAtlassianProvider = atlassian.create; diff --git a/plugins/auth-backend/src/providers/auth0/index.ts b/plugins/auth-backend/src/providers/auth0/index.ts index b201177d69..94a08a5809 100644 --- a/plugins/auth-backend/src/providers/auth0/index.ts +++ b/plugins/auth-backend/src/providers/auth0/index.ts @@ -14,5 +14,4 @@ * limitations under the License. */ -export { createAuth0Provider } from './provider'; -export type { Auth0ProviderOptions } from './provider'; +export { auth0 } from './provider'; diff --git a/plugins/auth-backend/src/providers/auth0/provider.ts b/plugins/auth-backend/src/providers/auth0/provider.ts index 9ddd587508..a53f504f50 100644 --- a/plugins/auth-backend/src/providers/auth0/provider.ts +++ b/plugins/auth-backend/src/providers/auth0/provider.ts @@ -169,28 +169,6 @@ export class Auth0AuthProvider implements OAuthHandlers { } } -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type Auth0ProviderOptions = { - /** - * The profile transformation function used to verify and convert the auth response - * into the profile that will be presented to the user. - */ - authHandler?: AuthHandler; - - /** - * Configure sign-in for this provider, without it the provider can not be used to sign users in. - */ - signIn?: { - /** - * Maps an auth result to a Backstage identity for the user. - */ - resolver: SignInResolver; - }; -}; - /** * Auth provider integration for auth0 auth * @@ -249,9 +227,3 @@ export const auth0 = createAuthProviderIntegration({ }); }, }); - -/** - * @public - * @deprecated Use `providers.auth0.create` instead. - */ -export const createAuth0Provider = auth0.create; diff --git a/plugins/auth-backend/src/providers/aws-alb/index.ts b/plugins/auth-backend/src/providers/aws-alb/index.ts index 710d86ca3d..9b3e8920ac 100644 --- a/plugins/auth-backend/src/providers/aws-alb/index.ts +++ b/plugins/auth-backend/src/providers/aws-alb/index.ts @@ -14,5 +14,5 @@ * limitations under the License. */ -export { createAwsAlbProvider } from './provider'; -export type { AwsAlbProviderOptions, AwsAlbResult } from './provider'; +export { awsAlb } from './provider'; +export type { AwsAlbResult } from './provider'; diff --git a/plugins/auth-backend/src/providers/aws-alb/provider.ts b/plugins/auth-backend/src/providers/aws-alb/provider.ts index b8d43a11e6..5af606539e 100644 --- a/plugins/auth-backend/src/providers/aws-alb/provider.ts +++ b/plugins/auth-backend/src/providers/aws-alb/provider.ts @@ -211,28 +211,6 @@ export class AwsAlbAuthProvider implements AuthProviderRouteHandlers { }; } -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type AwsAlbProviderOptions = { - /** - * The profile transformation function used to verify and convert the auth response - * into the profile that will be presented to the user. - */ - authHandler?: AuthHandler; - - /** - * Configure sign-in for this provider, without it the provider can not be used to sign users in. - */ - signIn: { - /** - * Maps an auth result to a Backstage identity for the user. - */ - resolver: SignInResolver; - }; -}; - /** * Auth provider integration for AWS ALB auth * @@ -282,9 +260,3 @@ export const awsAlb = createAuthProviderIntegration({ }; }, }); - -/** - * @public - * @deprecated Use `providers.awsAlb.create` instead - */ -export const createAwsAlbProvider = awsAlb.create; diff --git a/plugins/auth-backend/src/providers/bitbucket/index.ts b/plugins/auth-backend/src/providers/bitbucket/index.ts index 55a5735655..9d82c1066c 100644 --- a/plugins/auth-backend/src/providers/bitbucket/index.ts +++ b/plugins/auth-backend/src/providers/bitbucket/index.ts @@ -14,13 +14,8 @@ * limitations under the License. */ -export { - createBitbucketProvider, - bitbucketUsernameSignInResolver, - bitbucketUserIdSignInResolver, -} from './provider'; +export { bitbucket } from './provider'; export type { - BitbucketProviderOptions, BitbucketPassportProfile, BitbucketOAuthResult, } from './provider'; diff --git a/plugins/auth-backend/src/providers/bitbucket/provider.ts b/plugins/auth-backend/src/providers/bitbucket/provider.ts index 5b9919764b..e3bd044466 100644 --- a/plugins/auth-backend/src/providers/bitbucket/provider.ts +++ b/plugins/auth-backend/src/providers/bitbucket/provider.ts @@ -190,28 +190,6 @@ export class BitbucketAuthProvider implements OAuthHandlers { } } -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type BitbucketProviderOptions = { - /** - * The profile transformation function used to verify and convert the auth response - * into the profile that will be presented to the user. - */ - authHandler?: AuthHandler; - - /** - * Configure sign-in for this provider, without it the provider can not be used to sign users in. - */ - signIn?: { - /** - * Maps an auth result to a Backstage identity for the user. - */ - resolver: SignInResolver; - }; -}; - /** * Auth provider integration for BitBucket auth * @@ -305,23 +283,3 @@ export const bitbucket = createAuthProviderIntegration({ }, }, }); - -/** - * @public - * @deprecated Use `providers.bitbucket.create` instead - */ -export const createBitbucketProvider = bitbucket.create; - -/** - * @public - * @deprecated Use `providers.bitbucket.resolvers.usernameMatchingUserEntityAnnotation()` instead. - */ -export const bitbucketUsernameSignInResolver = - bitbucket.resolvers.usernameMatchingUserEntityAnnotation(); - -/** - * @public - * @deprecated Use `providers.bitbucket.resolvers.userIdMatchingUserEntityAnnotation()` instead. - */ -export const bitbucketUserIdSignInResolver = - bitbucket.resolvers.userIdMatchingUserEntityAnnotation(); diff --git a/plugins/auth-backend/src/providers/factories.ts b/plugins/auth-backend/src/providers/factories.ts deleted file mode 100644 index 42d3569815..0000000000 --- a/plugins/auth-backend/src/providers/factories.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2020 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 { createGithubProvider } from './github'; -import { createGitlabProvider } from './gitlab'; -import { createGoogleProvider } from './google'; -import { createOAuth2Provider } from './oauth2'; -import { createOidcProvider } from './oidc'; -import { createOktaProvider } from './okta'; -import { createSamlProvider } from './saml'; -import { createAuth0Provider } from './auth0'; -import { createMicrosoftProvider } from './microsoft'; -import { createOneLoginProvider } from './onelogin'; -import { AuthProviderFactory } from './types'; -import { createAwsAlbProvider } from './aws-alb'; -import { createBitbucketProvider } from './bitbucket'; -import { createAtlassianProvider } from './atlassian'; - -export const factories: { [providerId: string]: AuthProviderFactory } = { - google: createGoogleProvider(), - github: createGithubProvider(), - gitlab: createGitlabProvider(), - saml: createSamlProvider(), - okta: createOktaProvider(), - auth0: createAuth0Provider(), - microsoft: createMicrosoftProvider(), - oauth2: createOAuth2Provider(), - oidc: createOidcProvider(), - onelogin: createOneLoginProvider(), - awsalb: createAwsAlbProvider(), - bitbucket: createBitbucketProvider(), - atlassian: createAtlassianProvider(), -}; diff --git a/plugins/auth-backend/src/providers/gcp-iap/index.ts b/plugins/auth-backend/src/providers/gcp-iap/index.ts index 97e31b0051..12f76ec142 100644 --- a/plugins/auth-backend/src/providers/gcp-iap/index.ts +++ b/plugins/auth-backend/src/providers/gcp-iap/index.ts @@ -14,9 +14,5 @@ * limitations under the License. */ -export { createGcpIapProvider } from './provider'; -export type { - GcpIapProviderOptions, - GcpIapResult, - GcpIapTokenInfo, -} from './types'; +export { gcpIap } from './provider'; +export type { GcpIapResult, GcpIapTokenInfo } from './types'; diff --git a/plugins/auth-backend/src/providers/gcp-iap/provider.ts b/plugins/auth-backend/src/providers/gcp-iap/provider.ts index cb5d5979cd..500b062d5b 100644 --- a/plugins/auth-backend/src/providers/gcp-iap/provider.ts +++ b/plugins/auth-backend/src/providers/gcp-iap/provider.ts @@ -117,9 +117,3 @@ export const gcpIap = createAuthProviderIntegration({ }; }, }); - -/** - * @public - * @deprecated Use `providers.gcpIap.create` instead - */ -export const createGcpIapProvider = gcpIap.create; diff --git a/plugins/auth-backend/src/providers/gcp-iap/types.ts b/plugins/auth-backend/src/providers/gcp-iap/types.ts index 6e5a022a3d..25828b7d51 100644 --- a/plugins/auth-backend/src/providers/gcp-iap/types.ts +++ b/plugins/auth-backend/src/providers/gcp-iap/types.ts @@ -15,7 +15,7 @@ */ import { JsonValue } from '@backstage/types'; -import { AuthHandler, AuthResponse, SignInResolver } from '../types'; +import { AuthResponse } from '../types'; /** * The header name used by the IAP. @@ -69,27 +69,3 @@ export type GcpIapProviderInfo = { * The shape of the response to return to callers. */ export type GcpIapResponse = AuthResponse; - -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type GcpIapProviderOptions = { - /** - * The profile transformation function used to verify and convert the auth - * response into the profile that will be presented to the user. The default - * implementation just provides the authenticated email that the IAP - * presented. - */ - authHandler?: AuthHandler; - - /** - * Configures sign-in for this provider. - */ - signIn: { - /** - * Maps an auth result to a Backstage identity for the user. - */ - resolver: SignInResolver; - }; -}; diff --git a/plugins/auth-backend/src/providers/github/index.ts b/plugins/auth-backend/src/providers/github/index.ts index a855b13b83..2f4bb1f6cd 100644 --- a/plugins/auth-backend/src/providers/github/index.ts +++ b/plugins/auth-backend/src/providers/github/index.ts @@ -14,5 +14,5 @@ * limitations under the License. */ -export { createGithubProvider } from './provider'; -export type { GithubOAuthResult, GithubProviderOptions } from './provider'; +export { github } from './provider'; +export type { GithubOAuthResult } from './provider'; diff --git a/plugins/auth-backend/src/providers/github/provider.ts b/plugins/auth-backend/src/providers/github/provider.ts index e018a6cf99..9c115b5eb8 100644 --- a/plugins/auth-backend/src/providers/github/provider.ts +++ b/plugins/auth-backend/src/providers/github/provider.ts @@ -227,46 +227,6 @@ export class GithubAuthProvider implements OAuthHandlers { } } -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type GithubProviderOptions = { - /** - * The profile transformation function used to verify and convert the auth response - * into the profile that will be presented to the user. - */ - authHandler?: AuthHandler; - - /** - * Configure sign-in for this provider, without it the provider can not be used to sign users in. - */ - signIn?: { - /** - * Maps an auth result to a Backstage identity for the user. - */ - resolver: SignInResolver; - }; - - /** - * The state encoder used to encode the 'state' parameter on the OAuth request. - * - * It should return a string that takes the state params (from the request), url encodes the params - * and finally base64 encodes them. - * - * Providing your own stateEncoder will allow you to add addition parameters to the state field. - * - * It is typed as follows: - * `export type StateEncoder = (input: OAuthState) => Promise<{encodedState: string}>;` - * - * Note: the stateEncoder must encode a 'nonce' value and an 'env' value. Without this, the OAuth flow will fail - * (These two values will be set by the req.state by default) - * - * For more information, please see the helper module in ../../oauth/helpers #readState - */ - stateEncoder?: StateEncoder; -}; - /** * Auth provider integration for GitHub auth * @@ -381,9 +341,3 @@ export const github = createAuthProviderIntegration({ }, }, }); - -/** - * @public - * @deprecated Use `providers.github.create` instead - */ -export const createGithubProvider = github.create; diff --git a/plugins/auth-backend/src/providers/gitlab/index.ts b/plugins/auth-backend/src/providers/gitlab/index.ts index 52ede48756..9b60d1f18a 100644 --- a/plugins/auth-backend/src/providers/gitlab/index.ts +++ b/plugins/auth-backend/src/providers/gitlab/index.ts @@ -14,5 +14,4 @@ * limitations under the License. */ -export { createGitlabProvider } from './provider'; -export type { GitlabProviderOptions } from './provider'; +export { gitlab } from './provider'; diff --git a/plugins/auth-backend/src/providers/gitlab/provider.ts b/plugins/auth-backend/src/providers/gitlab/provider.ts index 868357bcda..c24c2e128d 100644 --- a/plugins/auth-backend/src/providers/gitlab/provider.ts +++ b/plugins/auth-backend/src/providers/gitlab/provider.ts @@ -178,31 +178,6 @@ export class GitlabAuthProvider implements OAuthHandlers { } } -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type GitlabProviderOptions = { - /** - * The profile transformation function used to verify and convert the auth response - * into the profile that will be presented to the user. - */ - authHandler?: AuthHandler; - - /** - * Configure sign-in for this provider, without it the provider can not be used to sign users in. - */ - /** - * Maps an auth result to a Backstage identity for the user. - * - * Set to `'email'` to use the default email-based sign in resolver, which will search - * the catalog for a single user entity that has a matching `microsoft.com/email` annotation. - */ - signIn?: { - resolver: SignInResolver; - }; -}; - /** * Auth provider integration for GitLab auth * @@ -254,9 +229,3 @@ export const gitlab = createAuthProviderIntegration({ }); }, }); - -/** - * @public - * @deprecated Use `providers.gitlab.create` instead - */ -export const createGitlabProvider = gitlab.create; diff --git a/plugins/auth-backend/src/providers/google/index.ts b/plugins/auth-backend/src/providers/google/index.ts index 209484ad04..5e8c3236e4 100644 --- a/plugins/auth-backend/src/providers/google/index.ts +++ b/plugins/auth-backend/src/providers/google/index.ts @@ -14,5 +14,4 @@ * limitations under the License. */ -export { createGoogleProvider, googleEmailSignInResolver } from './provider'; -export type { GoogleProviderOptions } from './provider'; +export { google } from './provider'; diff --git a/plugins/auth-backend/src/providers/google/provider.ts b/plugins/auth-backend/src/providers/google/provider.ts index 2d58bc2aa6..f60d4e9947 100644 --- a/plugins/auth-backend/src/providers/google/provider.ts +++ b/plugins/auth-backend/src/providers/google/provider.ts @@ -168,28 +168,6 @@ export class GoogleAuthProvider implements OAuthHandlers { } } -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type GoogleProviderOptions = { - /** - * The profile transformation function used to verify and convert the auth response - * into the profile that will be presented to the user. - */ - authHandler?: AuthHandler; - - /** - * Configure sign-in for this provider, without it the provider can not be used to sign users in. - */ - signIn?: { - /** - * Maps an auth result to a Backstage identity for the user. - */ - resolver: SignInResolver; - }; -}; - /** * Auth provider integration for Google auth * @@ -272,16 +250,3 @@ export const google = createAuthProviderIntegration({ }, }, }); - -/** - * @public - * @deprecated Use `providers.google.create` instead. - */ -export const createGoogleProvider = google.create; - -/** - * @public - * @deprecated Use `providers.google.resolvers.emailMatchingUserEntityAnnotation()` instead. - */ -export const googleEmailSignInResolver = - google.resolvers.emailMatchingUserEntityAnnotation(); diff --git a/plugins/auth-backend/src/providers/index.ts b/plugins/auth-backend/src/providers/index.ts index 1f33a60e55..de410a9407 100644 --- a/plugins/auth-backend/src/providers/index.ts +++ b/plugins/auth-backend/src/providers/index.ts @@ -14,30 +14,23 @@ * limitations under the License. */ -export * from './atlassian'; -export * from './auth0'; -export * from './aws-alb'; -export * from './bitbucket'; -export * from './github'; -export * from './gitlab'; -export * from './google'; -export * from './microsoft'; -export * from './oauth2'; -export * from './oauth2-proxy'; -export * from './oidc'; -export * from './okta'; -export * from './onelogin'; -export * from './saml'; -export * from './gcp-iap'; +export { AtlassianAuthProvider } from './atlassian'; +export type { AwsAlbResult } from './aws-alb'; +export type { + BitbucketOAuthResult, + BitbucketPassportProfile, +} from './bitbucket'; +export type { GithubOAuthResult } from './github'; +export type { OAuth2ProxyResult } from './oauth2-proxy'; +export type { OidcAuthResult } from './oidc'; +export type { SamlAuthResult } from './saml'; +export type { GcpIapResult, GcpIapTokenInfo } from './gcp-iap'; -export { providers } from './providers'; - -export { factories as defaultAuthProviderFactories } from './factories'; +export { providers, defaultAuthProviderFactories } from './providers'; export type { AuthProviderConfig, AuthProviderRouteHandlers, - AuthProviderFactoryOptions, AuthProviderFactory, AuthHandler, AuthResolverCatalogUserQuery, diff --git a/plugins/auth-backend/src/providers/microsoft/index.ts b/plugins/auth-backend/src/providers/microsoft/index.ts index 3167de5d0d..16dadc3bb0 100644 --- a/plugins/auth-backend/src/providers/microsoft/index.ts +++ b/plugins/auth-backend/src/providers/microsoft/index.ts @@ -14,8 +14,4 @@ * limitations under the License. */ -export { - createMicrosoftProvider, - microsoftEmailSignInResolver, -} from './provider'; -export type { MicrosoftProviderOptions } from './provider'; +export { microsoft } from './provider'; diff --git a/plugins/auth-backend/src/providers/microsoft/provider.ts b/plugins/auth-backend/src/providers/microsoft/provider.ts index 0c58049619..db79dba225 100644 --- a/plugins/auth-backend/src/providers/microsoft/provider.ts +++ b/plugins/auth-backend/src/providers/microsoft/provider.ts @@ -190,28 +190,6 @@ export class MicrosoftAuthProvider implements OAuthHandlers { } } -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type MicrosoftProviderOptions = { - /** - * The profile transformation function used to verify and convert the auth response - * into the profile that will be presented to the user. - */ - authHandler?: AuthHandler; - - /** - * Configure sign-in for this provider, without it the provider can not be used to sign users in. - */ - signIn?: { - /** - * Maps an auth result to a Backstage identity for the user. - */ - resolver: SignInResolver; - }; -}; - /** * Auth provider integration for Microsoft auth * @@ -301,16 +279,3 @@ export const microsoft = createAuthProviderIntegration({ }, }, }); - -/** - * @public - * @deprecated Use `providers.microsoft.create` instead - */ -export const createMicrosoftProvider = microsoft.create; - -/** - * @public - * @deprecated Use `providers.microsoft.resolvers.emailMatchingUserEntityAnnotation()` instead. - */ -export const microsoftEmailSignInResolver = - microsoft.resolvers.emailMatchingUserEntityAnnotation(); diff --git a/plugins/auth-backend/src/providers/oauth2-proxy/index.ts b/plugins/auth-backend/src/providers/oauth2-proxy/index.ts index 62304b1d1f..d3004f31e4 100644 --- a/plugins/auth-backend/src/providers/oauth2-proxy/index.ts +++ b/plugins/auth-backend/src/providers/oauth2-proxy/index.ts @@ -14,5 +14,5 @@ * limitations under the License. */ -export { createOauth2ProxyProvider } from './provider'; -export type { Oauth2ProxyProviderOptions, OAuth2ProxyResult } from './provider'; +export { oauth2Proxy } from './provider'; +export type { OAuth2ProxyResult } from './provider'; diff --git a/plugins/auth-backend/src/providers/oauth2-proxy/provider.ts b/plugins/auth-backend/src/providers/oauth2-proxy/provider.ts index 625c9e3d62..3ac7d09000 100644 --- a/plugins/auth-backend/src/providers/oauth2-proxy/provider.ts +++ b/plugins/auth-backend/src/providers/oauth2-proxy/provider.ts @@ -80,27 +80,6 @@ export type OAuth2ProxyResult = { getHeader(name: string): string | undefined; }; -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type Oauth2ProxyProviderOptions = { - /** - * Configure an auth handler to generate a profile for the user. - */ - authHandler: AuthHandler>; - - /** - * Configure sign-in for this provider, without it the provider can not be used to sign users in. - */ - signIn: { - /** - * Maps an auth result to a Backstage identity for the user. - */ - resolver: SignInResolver>; - }; -}; - interface Options { resolverContext: AuthResolverContext; signInResolver: SignInResolver>; @@ -231,9 +210,3 @@ export const oauth2Proxy = createAuthProviderIntegration({ }; }, }); - -/** - * @public - * @deprecated Use `providers.oauth2Proxy.create` instead - */ -export const createOauth2ProxyProvider = oauth2Proxy.create; diff --git a/plugins/auth-backend/src/providers/oauth2/index.ts b/plugins/auth-backend/src/providers/oauth2/index.ts index d68208a148..14485e04ff 100644 --- a/plugins/auth-backend/src/providers/oauth2/index.ts +++ b/plugins/auth-backend/src/providers/oauth2/index.ts @@ -14,5 +14,4 @@ * limitations under the License. */ -export { createOAuth2Provider } from './provider'; -export type { OAuth2ProviderOptions } from './provider'; +export { oauth2 } from './provider'; diff --git a/plugins/auth-backend/src/providers/oauth2/provider.ts b/plugins/auth-backend/src/providers/oauth2/provider.ts index 6b4787e985..6fa649c421 100644 --- a/plugins/auth-backend/src/providers/oauth2/provider.ts +++ b/plugins/auth-backend/src/providers/oauth2/provider.ts @@ -192,18 +192,6 @@ export class OAuth2AuthProvider implements OAuthHandlers { } } -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type OAuth2ProviderOptions = { - authHandler?: AuthHandler; - - signIn?: { - resolver: SignInResolver; - }; -}; - /** * Auth provider integration for generic OAuth2 auth * @@ -260,9 +248,3 @@ export const oauth2 = createAuthProviderIntegration({ }); }, }); - -/** - * @public - * @deprecated Use `providers.oauth2.create` instead - */ -export const createOAuth2Provider = oauth2.create; diff --git a/plugins/auth-backend/src/providers/oidc/index.ts b/plugins/auth-backend/src/providers/oidc/index.ts index e63c9920df..6b2282411c 100644 --- a/plugins/auth-backend/src/providers/oidc/index.ts +++ b/plugins/auth-backend/src/providers/oidc/index.ts @@ -14,5 +14,5 @@ * limitations under the License. */ -export type { OidcAuthResult, OidcProviderOptions } from './provider'; -export { createOidcProvider } from './provider'; +export { oidc } from './provider'; +export type { OidcAuthResult } from './provider'; diff --git a/plugins/auth-backend/src/providers/oidc/provider.test.ts b/plugins/auth-backend/src/providers/oidc/provider.test.ts index 59a717f132..ee8aa50b01 100644 --- a/plugins/auth-backend/src/providers/oidc/provider.test.ts +++ b/plugins/auth-backend/src/providers/oidc/provider.test.ts @@ -23,7 +23,7 @@ import { rest } from 'msw'; import { setupServer } from 'msw/node'; import { ClientMetadata, IssuerMetadata } from 'openid-client'; import { OAuthAdapter } from '../../lib/oauth'; -import { createOidcProvider, OidcAuthProvider, Options } from './provider'; +import { oidc, OidcAuthProvider, Options } from './provider'; import { AuthResolverContext } from '../types'; const issuerMetadata = { @@ -155,7 +155,7 @@ describe('OidcAuthProvider', () => { expect(requestSequence).toEqual([0, 1, 2].map(i => requests[i].url)); }); - it('createOidcProvider', async () => { + it('oidc.create', async () => { const handler = jest.fn((_req, res, ctx) => { return res( ctx.status(200), @@ -172,7 +172,7 @@ describe('OidcAuthProvider', () => { metadataUrl: 'https://oidc.test/.well-known/openid-configuration', }, } as any); - const provider = createOidcProvider()({ + const provider = oidc.create()({ globalConfig: { appUrl: 'https://oidc.test', baseUrl: 'https://oidc.test', diff --git a/plugins/auth-backend/src/providers/oidc/provider.ts b/plugins/auth-backend/src/providers/oidc/provider.ts index 69a65d1cae..eb963a3711 100644 --- a/plugins/auth-backend/src/providers/oidc/provider.ts +++ b/plugins/auth-backend/src/providers/oidc/provider.ts @@ -198,18 +198,6 @@ export class OidcAuthProvider implements OAuthHandlers { } } -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type OidcProviderOptions = { - authHandler?: AuthHandler; - - signIn?: { - resolver: SignInResolver; - }; -}; - /** * Auth provider integration for generic OpenID Connect auth * @@ -268,9 +256,3 @@ export const oidc = createAuthProviderIntegration({ }); }, }); - -/** - * @public - * @deprecated Use `providers.oidc.create` instead - */ -export const createOidcProvider = oidc.create; diff --git a/plugins/auth-backend/src/providers/okta/index.ts b/plugins/auth-backend/src/providers/okta/index.ts index fd9ebf46da..3387fa3668 100644 --- a/plugins/auth-backend/src/providers/okta/index.ts +++ b/plugins/auth-backend/src/providers/okta/index.ts @@ -14,5 +14,4 @@ * limitations under the License. */ -export { createOktaProvider, oktaEmailSignInResolver } from './provider'; -export type { OktaProviderOptions } from './provider'; +export { okta } from './provider'; diff --git a/plugins/auth-backend/src/providers/okta/provider.ts b/plugins/auth-backend/src/providers/okta/provider.ts index 98cec6df3a..de9d128641 100644 --- a/plugins/auth-backend/src/providers/okta/provider.ts +++ b/plugins/auth-backend/src/providers/okta/provider.ts @@ -192,28 +192,6 @@ export class OktaAuthProvider implements OAuthHandlers { } } -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type OktaProviderOptions = { - /** - * The profile transformation function used to verify and convert the auth response - * into the profile that will be presented to the user. - */ - authHandler?: AuthHandler; - - /** - * Configure sign-in for this provider, without it the provider can not be used to sign users in. - */ - signIn?: { - /** - * Maps an auth result to a Backstage identity for the user. - */ - resolver: SignInResolver; - }; -}; - /** * Auth provider integration for Okta auth * @@ -305,16 +283,3 @@ export const okta = createAuthProviderIntegration({ }, }, }); - -/** - * @public - * @deprecated Use `providers.okta.create` instead - */ -export const createOktaProvider = okta.create; - -/** - * @public - * @deprecated Use `providers.okta.resolvers.emailMatchingUserEntityAnnotation()` instead. - */ -export const oktaEmailSignInResolver = - okta.resolvers.emailMatchingUserEntityAnnotation(); diff --git a/plugins/auth-backend/src/providers/onelogin/index.ts b/plugins/auth-backend/src/providers/onelogin/index.ts index 63cf0be3cd..3f356029fb 100644 --- a/plugins/auth-backend/src/providers/onelogin/index.ts +++ b/plugins/auth-backend/src/providers/onelogin/index.ts @@ -14,5 +14,4 @@ * limitations under the License. */ -export { createOneLoginProvider } from './provider'; -export type { OneLoginProviderOptions } from './provider'; +export { onelogin } from './provider'; diff --git a/plugins/auth-backend/src/providers/onelogin/provider.ts b/plugins/auth-backend/src/providers/onelogin/provider.ts index d81eb3d83c..59b57b3851 100644 --- a/plugins/auth-backend/src/providers/onelogin/provider.ts +++ b/plugins/auth-backend/src/providers/onelogin/provider.ts @@ -166,28 +166,6 @@ export class OneLoginProvider implements OAuthHandlers { } } -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type OneLoginProviderOptions = { - /** - * The profile transformation function used to verify and convert the auth response - * into the profile that will be presented to the user. - */ - authHandler?: AuthHandler; - - /** - * Configure sign-in for this provider, without it the provider can not be used to sign users in. - */ - signIn?: { - /** - * Maps an auth result to a Backstage identity for the user. - */ - resolver: SignInResolver; - }; -}; - /** * Auth provider integration for OneLogin auth * @@ -244,9 +222,3 @@ export const onelogin = createAuthProviderIntegration({ }); }, }); - -/** - * @public - * @deprecated Use `providers.onelogin.create` instead - */ -export const createOneLoginProvider = onelogin.create; diff --git a/plugins/auth-backend/src/providers/providers.ts b/plugins/auth-backend/src/providers/providers.ts index 3d49e2bbbb..71df8223ef 100644 --- a/plugins/auth-backend/src/providers/providers.ts +++ b/plugins/auth-backend/src/providers/providers.ts @@ -14,21 +14,22 @@ * limitations under the License. */ -import { atlassian } from './atlassian/provider'; -import { auth0 } from './auth0/provider'; -import { awsAlb } from './aws-alb/provider'; -import { bitbucket } from './bitbucket/provider'; -import { gcpIap } from './gcp-iap/provider'; -import { github } from './github/provider'; -import { gitlab } from './gitlab/provider'; -import { google } from './google/provider'; -import { microsoft } from './microsoft/provider'; -import { oauth2 } from './oauth2/provider'; -import { oauth2Proxy } from './oauth2-proxy/provider'; -import { oidc } from './oidc/provider'; -import { okta } from './okta/provider'; -import { onelogin } from './onelogin/provider'; -import { saml } from './saml/provider'; +import { atlassian } from './atlassian'; +import { auth0 } from './auth0'; +import { awsAlb } from './aws-alb'; +import { bitbucket } from './bitbucket'; +import { gcpIap } from './gcp-iap'; +import { github } from './github'; +import { gitlab } from './gitlab'; +import { google } from './google'; +import { microsoft } from './microsoft'; +import { oauth2 } from './oauth2'; +import { oauth2Proxy } from './oauth2-proxy'; +import { oidc } from './oidc'; +import { okta } from './okta'; +import { onelogin } from './onelogin'; +import { saml } from './saml'; +import { AuthProviderFactory } from './types'; /** * All built-in auth provider integrations. @@ -52,3 +53,26 @@ export const providers = Object.freeze({ onelogin, saml, }); + +/** + * All auth provider factories that are installed by default. + * + * @public + */ +export const defaultAuthProviderFactories: { + [providerId: string]: AuthProviderFactory; +} = { + google: google.create(), + github: github.create(), + gitlab: gitlab.create(), + saml: saml.create(), + okta: okta.create(), + auth0: auth0.create(), + microsoft: microsoft.create(), + oauth2: oauth2.create(), + oidc: oidc.create(), + onelogin: onelogin.create(), + awsalb: awsAlb.create(), + bitbucket: bitbucket.create(), + atlassian: atlassian.create(), +}; diff --git a/plugins/auth-backend/src/providers/saml/index.ts b/plugins/auth-backend/src/providers/saml/index.ts index 8d36e17d29..d59f7bf0a7 100644 --- a/plugins/auth-backend/src/providers/saml/index.ts +++ b/plugins/auth-backend/src/providers/saml/index.ts @@ -14,8 +14,5 @@ * limitations under the License. */ -export { - createSamlProvider, - samlNameIdEntityNameSignInResolver, -} from './provider'; -export type { SamlProviderOptions, SamlAuthResult } from './provider'; +export { saml } from './provider'; +export type { SamlAuthResult } from './provider'; diff --git a/plugins/auth-backend/src/providers/saml/provider.ts b/plugins/auth-backend/src/providers/saml/provider.ts index 4f5076b410..3d35f46628 100644 --- a/plugins/auth-backend/src/providers/saml/provider.ts +++ b/plugins/auth-backend/src/providers/saml/provider.ts @@ -132,28 +132,6 @@ export class SamlAuthProvider implements AuthProviderRouteHandlers { type SignatureAlgorithm = 'sha1' | 'sha256' | 'sha512'; -/** - * @public - * @deprecated This type has been inlined into the create method and will be removed. - */ -export type SamlProviderOptions = { - /** - * The profile transformation function used to verify and convert the auth response - * into the profile that will be presented to the user. - */ - authHandler?: AuthHandler; - - /** - * Configure sign-in for this provider, without it the provider can not be used to sign users in. - */ - signIn?: { - /** - * Maps an auth result to a Backstage identity for the user. - */ - resolver: SignInResolver; - }; -}; - /** * Auth provider integration for SAML auth * @@ -230,16 +208,3 @@ export const saml = createAuthProviderIntegration({ }, }, }); - -/** - * @public - * @deprecated Use `providers.saml.create` instead - */ -export const createSamlProvider = saml.create; - -/** - * @public - * @deprecated Use `providers.saml.resolvers.nameIdMatchingUserEntityName()` instead. - */ -export const samlNameIdEntityNameSignInResolver = - saml.resolvers.nameIdMatchingUserEntityName(); diff --git a/plugins/auth-backend/src/providers/types.ts b/plugins/auth-backend/src/providers/types.ts index 128dea12ef..c99bdfbadb 100644 --- a/plugins/auth-backend/src/providers/types.ts +++ b/plugins/auth-backend/src/providers/types.ts @@ -14,11 +14,8 @@ * limitations under the License. */ -import { - PluginEndpointDiscovery, - TokenManager, -} from '@backstage/backend-common'; -import { CatalogApi, GetEntitiesRequest } from '@backstage/catalog-client'; +import { GetEntitiesRequest } from '@backstage/catalog-client'; +import { Entity } from '@backstage/catalog-model'; import { Config } from '@backstage/config'; import { BackstageIdentityResponse, @@ -26,10 +23,8 @@ import { } from '@backstage/plugin-auth-node'; import express from 'express'; import { Logger } from 'winston'; -import { TokenIssuer, TokenParams } from '../identity/types'; +import { TokenParams } from '../identity/types'; import { OAuthStartRequest } from '../lib/oauth/types'; -import { CatalogIdentityClient } from '../lib/catalog'; -import { Entity } from '@backstage/catalog-model'; /** * A query for a single user in the catalog. @@ -69,13 +64,6 @@ export type AuthResolverCatalogUserQuery = * @public */ export type AuthResolverContext = { - /** @deprecated Will be removed from the context, access it via a closure instead if needed */ - logger: Logger; - /** @deprecated Use the `issueToken` method instead */ - tokenIssuer: TokenIssuer; - /** @deprecated Use the `findCatalogUser` and `signInWithCatalogUser` methods instead, and the `getDefaultOwnershipEntityRefs` helper */ - catalogIdentityClient: CatalogIdentityClient; - /** * Issues a Backstage token using the provided parameters. */ @@ -204,35 +192,12 @@ export interface AuthProviderRouteHandlers { logout?(req: express.Request, res: express.Response): Promise; } -/** - * @deprecated This type is deprecated and will be removed in a future release. - */ -export type AuthProviderFactoryOptions = { - providerId: string; - globalConfig: AuthProviderConfig; - config: Config; - logger: Logger; - tokenManager: TokenManager; - tokenIssuer: TokenIssuer; - discovery: PluginEndpointDiscovery; - catalogApi: CatalogApi; -}; - export type AuthProviderFactory = (options: { providerId: string; globalConfig: AuthProviderConfig; config: Config; logger: Logger; resolverContext: AuthResolverContext; - - /** @deprecated This field has been deprecated and needs to be passed directly to the auth provider instead */ - tokenManager: TokenManager; - /** @deprecated This field has been deprecated and needs to be passed directly to the auth provider instead */ - tokenIssuer: TokenIssuer; - /** @deprecated This field has been deprecated and needs to be passed directly to the auth provider instead */ - discovery: PluginEndpointDiscovery; - /** @deprecated This field has been deprecated and needs to be passed directly to the auth provider instead */ - catalogApi: CatalogApi; }) => AuthProviderRouteHandlers; /** @public */ diff --git a/plugins/auth-backend/src/service/router.ts b/plugins/auth-backend/src/service/router.ts index 80b8a24022..50577ece53 100644 --- a/plugins/auth-backend/src/service/router.ts +++ b/plugins/auth-backend/src/service/router.ts @@ -119,10 +119,6 @@ export async function createRouter( }, config: providersConfig.getConfig(providerId), logger, - tokenManager, - tokenIssuer, - discovery, - catalogApi, resolverContext: CatalogAuthResolverContext.create({ logger, catalogApi,