Merge pull request #12120 from backstage/rugvip/auth-cleanup

auth-backend: remove deprecations
This commit is contained in:
Patrik Oldsberg
2022-06-21 17:03:08 +02:00
committed by GitHub
49 changed files with 109 additions and 1088 deletions
+3 -384
View File
@@ -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<RedirectInfo>;
}
// @public @deprecated (undocumented)
export type AtlassianProviderOptions = {
authHandler?: AuthHandler<OAuthResult>;
signIn?: {
resolver: SignInResolver<OAuthResult>;
};
};
// @public @deprecated (undocumented)
export type Auth0ProviderOptions = {
authHandler?: AuthHandler<OAuthResult>;
signIn?: {
resolver: SignInResolver<OAuthResult>;
};
};
// @public
export type AuthHandler<TAuthResult> = (
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<ProviderInfo> = {
backstageIdentity?: BackstageIdentityResponse;
};
// @public @deprecated (undocumented)
export type AwsAlbProviderOptions = {
authHandler?: AuthHandler<AwsAlbResult>;
signIn: {
resolver: SignInResolver<AwsAlbResult>;
};
};
// @public (undocumented)
export type AwsAlbResult = {
fullProfile: Profile;
@@ -206,20 +159,6 @@ export type BitbucketPassportProfile = Profile & {
};
};
// @public @deprecated (undocumented)
export type BitbucketProviderOptions = {
authHandler?: AuthHandler<OAuthResult>;
signIn?: {
resolver: SignInResolver<OAuthResult>;
};
};
// @public @deprecated (undocumented)
export const bitbucketUserIdSignInResolver: SignInResolver<OAuthResult>;
// @public @deprecated (undocumented)
export const bitbucketUsernameSignInResolver: SignInResolver<OAuthResult>;
// 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<OAuthResult> | undefined;
signIn?:
| {
resolver: SignInResolver<OAuthResult>;
}
| undefined;
}
| undefined,
) => AuthProviderFactory;
// @public @deprecated (undocumented)
export const createAuth0Provider: (
options?:
| {
authHandler?: AuthHandler<OAuthResult> | undefined;
signIn?:
| {
resolver: SignInResolver<OAuthResult>;
}
| undefined;
}
| undefined,
) => AuthProviderFactory;
// @public @deprecated (undocumented)
export const createAwsAlbProvider: (
options?:
| {
authHandler?: AuthHandler<AwsAlbResult> | undefined;
signIn: {
resolver: SignInResolver<AwsAlbResult>;
};
}
| undefined,
) => AuthProviderFactory;
// @public @deprecated (undocumented)
export const createBitbucketProvider: (
options?:
| {
authHandler?: AuthHandler<OAuthResult> | undefined;
signIn?:
| {
resolver: SignInResolver<OAuthResult>;
}
| undefined;
}
| undefined,
) => AuthProviderFactory;
// @public @deprecated (undocumented)
export const createGcpIapProvider: (options: {
authHandler?: AuthHandler<GcpIapResult> | undefined;
signIn: {
resolver: SignInResolver<GcpIapResult>;
};
}) => AuthProviderFactory;
// @public @deprecated (undocumented)
export const createGithubProvider: (
options?:
| {
authHandler?: AuthHandler<GithubOAuthResult> | undefined;
signIn?:
| {
resolver: SignInResolver<GithubOAuthResult>;
}
| undefined;
stateEncoder?: StateEncoder | undefined;
}
| undefined,
) => AuthProviderFactory;
// @public @deprecated (undocumented)
export const createGitlabProvider: (
options?:
| {
authHandler?: AuthHandler<OAuthResult> | undefined;
signIn?:
| {
resolver: SignInResolver<OAuthResult>;
}
| undefined;
}
| undefined,
) => AuthProviderFactory;
// @public @deprecated (undocumented)
export const createGoogleProvider: (
options?:
| {
authHandler?: AuthHandler<OAuthResult> | undefined;
signIn?:
| {
resolver: SignInResolver<OAuthResult>;
}
| undefined;
}
| undefined,
) => AuthProviderFactory;
// @public @deprecated (undocumented)
export const createMicrosoftProvider: (
options?:
| {
authHandler?: AuthHandler<OAuthResult> | undefined;
signIn?:
| {
resolver: SignInResolver<OAuthResult>;
}
| undefined;
}
| undefined,
) => AuthProviderFactory;
// @public @deprecated (undocumented)
export const createOAuth2Provider: (
options?:
| {
authHandler?: AuthHandler<OAuthResult> | undefined;
signIn?:
| {
resolver: SignInResolver<OAuthResult>;
}
| undefined;
}
| undefined,
) => AuthProviderFactory;
// @public @deprecated (undocumented)
export const createOauth2ProxyProvider: (options: {
authHandler?: AuthHandler<OAuth2ProxyResult<unknown>> | undefined;
signIn: {
resolver: SignInResolver<OAuth2ProxyResult<unknown>>;
};
}) => AuthProviderFactory;
// @public @deprecated (undocumented)
export const createOidcProvider: (
options?:
| {
authHandler?: AuthHandler<OidcAuthResult> | undefined;
signIn?:
| {
resolver: SignInResolver<OidcAuthResult>;
}
| undefined;
}
| undefined,
) => AuthProviderFactory;
// @public @deprecated (undocumented)
export const createOktaProvider: (
options?:
| {
authHandler?: AuthHandler<OAuthResult> | undefined;
signIn?:
| {
resolver: SignInResolver<OAuthResult>;
}
| undefined;
}
| undefined,
) => AuthProviderFactory;
// @public @deprecated (undocumented)
export const createOneLoginProvider: (
options?:
| {
authHandler?: AuthHandler<OAuthResult> | undefined;
signIn?:
| {
resolver: SignInResolver<OAuthResult>;
}
| 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<express.Router>;
// @public @deprecated (undocumented)
export const createSamlProvider: (
options?:
| {
authHandler?: AuthHandler<SamlAuthResult> | undefined;
signIn?:
| {
resolver: SignInResolver<SamlAuthResult>;
}
| 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<GcpIapResult>;
signIn: {
resolver: SignInResolver<GcpIapResult>;
};
};
// @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<GithubOAuthResult>;
signIn?: {
resolver: SignInResolver<GithubOAuthResult>;
};
stateEncoder?: StateEncoder;
};
// @public @deprecated (undocumented)
export type GitlabProviderOptions = {
authHandler?: AuthHandler<OAuthResult>;
signIn?: {
resolver: SignInResolver<OAuthResult>;
};
};
// @public @deprecated (undocumented)
export const googleEmailSignInResolver: SignInResolver<OAuthResult>;
// @public @deprecated (undocumented)
export type GoogleProviderOptions = {
authHandler?: AuthHandler<OAuthResult>;
signIn?: {
resolver: SignInResolver<OAuthResult>;
};
};
// @public @deprecated (undocumented)
export const microsoftEmailSignInResolver: SignInResolver<OAuthResult>;
// @public @deprecated (undocumented)
export type MicrosoftProviderOptions = {
authHandler?: AuthHandler<OAuthResult>;
signIn?: {
resolver: SignInResolver<OAuthResult>;
};
};
// @public @deprecated (undocumented)
export type OAuth2ProviderOptions = {
authHandler?: AuthHandler<OAuthResult>;
signIn?: {
resolver: SignInResolver<OAuthResult>;
};
};
// @public @deprecated (undocumented)
export type Oauth2ProxyProviderOptions<JWTPayload> = {
authHandler: AuthHandler<OAuth2ProxyResult<JWTPayload>>;
signIn: {
resolver: SignInResolver<OAuth2ProxyResult<JWTPayload>>;
};
};
// @public
export type OAuth2ProxyResult<JWTPayload = {}> = {
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<Options, 'providerId' | 'persistScopes' | 'callbackUrl'>,
): OAuthAdapter;
// (undocumented)
logout(req: express.Request, res: express.Response): Promise<void>;
@@ -703,33 +372,6 @@ export type OidcAuthResult = {
userinfo: UserinfoResponse;
};
// @public @deprecated (undocumented)
export type OidcProviderOptions = {
authHandler?: AuthHandler<OidcAuthResult>;
signIn?: {
resolver: SignInResolver<OidcAuthResult>;
};
};
// @public @deprecated (undocumented)
export const oktaEmailSignInResolver: SignInResolver<OAuthResult>;
// @public @deprecated (undocumented)
export type OktaProviderOptions = {
authHandler?: AuthHandler<OAuthResult>;
signIn?: {
resolver: SignInResolver<OAuthResult>;
};
};
// @public @deprecated (undocumented)
export type OneLoginProviderOptions = {
authHandler?: AuthHandler<OAuthResult>;
signIn?: {
resolver: SignInResolver<OAuthResult>;
};
};
// 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<SamlAuthResult>;
// @public @deprecated (undocumented)
export type SamlProviderOptions = {
authHandler?: AuthHandler<SamlAuthResult>;
signIn?: {
resolver: SignInResolver<SamlAuthResult>;
};
};
// @public
export type SignInInfo<TAuthResult> = {
profile: ProfileInfo;
@@ -1044,14 +675,6 @@ export type StateEncoder = (req: OAuthStartRequest) => Promise<{
encodedState: string;
}>;
// @public @deprecated
export type TokenIssuer = {
issueToken(params: TokenParams): Promise<string>;
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
```
+1 -1
View File
@@ -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';
@@ -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 = {
/**
+1 -1
View File
@@ -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
@@ -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],
};
}
@@ -15,4 +15,3 @@
*/
export { CatalogIdentityClient } from './CatalogIdentityClient';
export { getEntityClaims } from './helpers';
@@ -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<Options, 'providerId' | 'persistScopes' | 'callbackUrl'>,
): OAuthAdapter {
const { origin: appOrigin } = new URL(config.appUrl);
@@ -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';
@@ -14,8 +14,4 @@
* limitations under the License.
*/
export { createAtlassianProvider } from './provider';
export type {
AtlassianAuthProvider,
AtlassianProviderOptions,
} from './provider';
export { atlassian, AtlassianAuthProvider } from './provider';
@@ -58,6 +58,10 @@ export const atlassianDefaultAuthHandler: AuthHandler<OAuthResult> = 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<OAuthResult>;
@@ -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<OAuthResult>;
/**
* Configure sign-in for this provider, without it the provider can not be used to sign users in.
*/
signIn?: {
resolver: SignInResolver<OAuthResult>;
};
};
/**
* 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;
@@ -14,5 +14,4 @@
* limitations under the License.
*/
export { createAuth0Provider } from './provider';
export type { Auth0ProviderOptions } from './provider';
export { auth0 } from './provider';
@@ -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<OAuthResult>;
/**
* 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<OAuthResult>;
};
};
/**
* 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;
@@ -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';
@@ -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<AwsAlbResult>;
/**
* 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<AwsAlbResult>;
};
};
/**
* 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;
@@ -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';
@@ -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<OAuthResult>;
/**
* 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<OAuthResult>;
};
};
/**
* 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();
@@ -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(),
};
@@ -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';
@@ -117,9 +117,3 @@ export const gcpIap = createAuthProviderIntegration({
};
},
});
/**
* @public
* @deprecated Use `providers.gcpIap.create` instead
*/
export const createGcpIapProvider = gcpIap.create;
@@ -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<GcpIapProviderInfo>;
/**
* @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<GcpIapResult>;
/**
* Configures sign-in for this provider.
*/
signIn: {
/**
* Maps an auth result to a Backstage identity for the user.
*/
resolver: SignInResolver<GcpIapResult>;
};
};
@@ -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';
@@ -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<GithubOAuthResult>;
/**
* 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<GithubOAuthResult>;
};
/**
* 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;
@@ -14,5 +14,4 @@
* limitations under the License.
*/
export { createGitlabProvider } from './provider';
export type { GitlabProviderOptions } from './provider';
export { gitlab } from './provider';
@@ -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<OAuthResult>;
/**
* 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<OAuthResult>;
};
};
/**
* 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;
@@ -14,5 +14,4 @@
* limitations under the License.
*/
export { createGoogleProvider, googleEmailSignInResolver } from './provider';
export type { GoogleProviderOptions } from './provider';
export { google } from './provider';
@@ -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<OAuthResult>;
/**
* 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<OAuthResult>;
};
};
/**
* 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();
+12 -19
View File
@@ -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,
@@ -14,8 +14,4 @@
* limitations under the License.
*/
export {
createMicrosoftProvider,
microsoftEmailSignInResolver,
} from './provider';
export type { MicrosoftProviderOptions } from './provider';
export { microsoft } from './provider';
@@ -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<OAuthResult>;
/**
* 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<OAuthResult>;
};
};
/**
* 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();
@@ -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';
@@ -80,27 +80,6 @@ export type OAuth2ProxyResult<JWTPayload = {}> = {
getHeader(name: string): string | undefined;
};
/**
* @public
* @deprecated This type has been inlined into the create method and will be removed.
*/
export type Oauth2ProxyProviderOptions<JWTPayload> = {
/**
* Configure an auth handler to generate a profile for the user.
*/
authHandler: AuthHandler<OAuth2ProxyResult<JWTPayload>>;
/**
* 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<OAuth2ProxyResult<JWTPayload>>;
};
};
interface Options<JWTPayload> {
resolverContext: AuthResolverContext;
signInResolver: SignInResolver<OAuth2ProxyResult<JWTPayload>>;
@@ -231,9 +210,3 @@ export const oauth2Proxy = createAuthProviderIntegration({
};
},
});
/**
* @public
* @deprecated Use `providers.oauth2Proxy.create` instead
*/
export const createOauth2ProxyProvider = oauth2Proxy.create;
@@ -14,5 +14,4 @@
* limitations under the License.
*/
export { createOAuth2Provider } from './provider';
export type { OAuth2ProviderOptions } from './provider';
export { oauth2 } from './provider';
@@ -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<OAuthResult>;
signIn?: {
resolver: SignInResolver<OAuthResult>;
};
};
/**
* 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;
@@ -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';
@@ -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',
@@ -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<OidcAuthResult>;
signIn?: {
resolver: SignInResolver<OidcAuthResult>;
};
};
/**
* 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;
@@ -14,5 +14,4 @@
* limitations under the License.
*/
export { createOktaProvider, oktaEmailSignInResolver } from './provider';
export type { OktaProviderOptions } from './provider';
export { okta } from './provider';
@@ -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<OAuthResult>;
/**
* 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<OAuthResult>;
};
};
/**
* 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();
@@ -14,5 +14,4 @@
* limitations under the License.
*/
export { createOneLoginProvider } from './provider';
export type { OneLoginProviderOptions } from './provider';
export { onelogin } from './provider';
@@ -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<OAuthResult>;
/**
* 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<OAuthResult>;
};
};
/**
* 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;
+39 -15
View File
@@ -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(),
};
@@ -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';
@@ -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<SamlAuthResult>;
/**
* 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<SamlAuthResult>;
};
};
/**
* 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();
+3 -38
View File
@@ -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<void>;
}
/**
* @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 */
@@ -119,10 +119,6 @@ export async function createRouter(
},
config: providersConfig.getConfig(providerId),
logger,
tokenManager,
tokenIssuer,
discovery,
catalogApi,
resolverContext: CatalogAuthResolverContext.create({
logger,
catalogApi,