diff --git a/.changeset/smart-frogs-help.md b/.changeset/smart-frogs-help.md new file mode 100644 index 0000000000000..9c65c267bd566 --- /dev/null +++ b/.changeset/smart-frogs-help.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-auth-backend': patch +--- + +Internal refactor to no longer use deprecated types diff --git a/plugins/auth-backend/api-report.md b/plugins/auth-backend/api-report.md index 40e5facbbda17..8d81751b394dc 100644 --- a/plugins/auth-backend/api-report.md +++ b/plugins/auth-backend/api-report.md @@ -42,12 +42,12 @@ import { WebMessageResponse as WebMessageResponse_2 } from '@backstage/plugin-au // @public @deprecated export type AuthHandler = ( input: TAuthResult, - context: AuthResolverContext, + context: AuthResolverContext_2, ) => Promise; // @public @deprecated export type AuthHandlerResult = { - profile: ProfileInfo; + profile: ProfileInfo_2; }; // @public @@ -168,13 +168,13 @@ export type CookieConfigurer = CookieConfigurer_2; export function createAuthProviderIntegration< TCreateOptions extends unknown[], TResolvers extends { - [name in string]: (...args: any[]) => SignInResolver; + [name in string]: (...args: any[]) => SignInResolver_2; }, >(config: { - create: (...args: TCreateOptions) => AuthProviderFactory; + create: (...args: TCreateOptions) => AuthProviderFactory_2; resolvers?: TResolvers; }): Readonly<{ - create: (...args: TCreateOptions) => AuthProviderFactory; + create: (...args: TCreateOptions) => AuthProviderFactory_2; resolvers: Readonly; }>; @@ -186,7 +186,7 @@ export function createRouter(options: RouterOptions): Promise; // @public export const defaultAuthProviderFactories: { - [providerId: string]: AuthProviderFactory; + [providerId: string]: AuthProviderFactory_2; }; // @public (undocumented) @@ -226,13 +226,13 @@ export type GithubOAuthResult = { export type OAuth2ProxyResult = OAuth2ProxyResult_2; // @public @deprecated (undocumented) -export class OAuthAdapter implements AuthProviderRouteHandlers { +export class OAuthAdapter implements AuthProviderRouteHandlers_2 { constructor(handlers: OAuthHandlers, options: OAuthAdapterOptions); // (undocumented) frameHandler(req: express.Request, res: express.Response): Promise; // (undocumented) static fromConfig( - config: AuthProviderConfig, + config: AuthProviderConfig_2, handlers: OAuthHandlers, options: Pick< OAuthAdapterOptions, @@ -253,7 +253,7 @@ export type OAuthAdapterOptions = { persistScopes?: boolean; appOrigin: string; baseUrl: string; - cookieConfigurer: CookieConfigurer; + cookieConfigurer: CookieConfigurer_2; isOriginAllowed: (origin: string) => boolean; callbackUrl: string; }; @@ -303,7 +303,7 @@ export type OAuthRefreshRequest = express.Request<{}> & { // @public @deprecated (undocumented) export type OAuthResponse = { - profile: ProfileInfo; + profile: ProfileInfo_2; providerInfo: OAuthProviderInfo; backstageIdentity?: BackstageSignInResult; }; @@ -354,7 +354,7 @@ export type ProfileInfo = ProfileInfo_2; // @public (undocumented) export type ProviderFactories = { - [s: string]: AuthProviderFactory; + [s: string]: AuthProviderFactory_2; }; // @public @@ -366,7 +366,7 @@ export const providers: Readonly<{ authHandler?: AuthHandler | undefined; signIn?: | { - resolver: SignInResolver; + resolver: SignInResolver_2; } | undefined; } @@ -381,7 +381,7 @@ export const providers: Readonly<{ authHandler?: AuthHandler | undefined; signIn?: | { - resolver: SignInResolver; + resolver: SignInResolver_2; } | undefined; } @@ -395,7 +395,7 @@ export const providers: Readonly<{ | { authHandler?: AuthHandler | undefined; signIn: { - resolver: SignInResolver; + resolver: SignInResolver_2; }; } | undefined, @@ -409,15 +409,15 @@ export const providers: Readonly<{ authHandler?: AuthHandler | undefined; signIn?: | { - resolver: SignInResolver; + resolver: SignInResolver_2; } | undefined; } | undefined, ) => AuthProviderFactory_2; resolvers: Readonly<{ - usernameMatchingUserEntityAnnotation(): SignInResolver; - userIdMatchingUserEntityAnnotation(): SignInResolver; + usernameMatchingUserEntityAnnotation(): SignInResolver_2; + userIdMatchingUserEntityAnnotation(): SignInResolver_2; }>; }>; bitbucketServer: Readonly<{ @@ -427,33 +427,33 @@ export const providers: Readonly<{ authHandler?: AuthHandler | undefined; signIn?: | { - resolver: SignInResolver; + resolver: SignInResolver_2; } | undefined; } | undefined, ) => AuthProviderFactory_2; resolvers: Readonly<{ - emailMatchingUserEntityProfileEmail: () => SignInResolver; + emailMatchingUserEntityProfileEmail: () => SignInResolver_2; }>; }>; cfAccess: Readonly<{ create: (options: { authHandler?: AuthHandler | undefined; signIn: { - resolver: SignInResolver; + resolver: SignInResolver_2; }; cache?: CacheService | undefined; }) => AuthProviderFactory_2; resolvers: Readonly<{ - emailMatchingUserEntityProfileEmail: () => SignInResolver; + emailMatchingUserEntityProfileEmail: () => SignInResolver_2; }>; }>; gcpIap: Readonly<{ create: (options: { authHandler?: AuthHandler | undefined; signIn: { - resolver: SignInResolver; + resolver: SignInResolver_2; }; }) => AuthProviderFactory_2; resolvers: never; @@ -483,7 +483,7 @@ export const providers: Readonly<{ authHandler?: AuthHandler | undefined; signIn?: | { - resolver: SignInResolver; + resolver: SignInResolver_2; } | undefined; } @@ -498,7 +498,7 @@ export const providers: Readonly<{ authHandler?: AuthHandler | undefined; signIn?: | { - resolver: SignInResolver; + resolver: SignInResolver_2; } | undefined; } @@ -517,7 +517,7 @@ export const providers: Readonly<{ authHandler?: AuthHandler | undefined; signIn?: | { - resolver: SignInResolver; + resolver: SignInResolver_2; } | undefined; } @@ -536,7 +536,7 @@ export const providers: Readonly<{ authHandler?: AuthHandler | undefined; signIn?: | { - resolver: SignInResolver; + resolver: SignInResolver_2; } | undefined; } @@ -548,7 +548,7 @@ export const providers: Readonly<{ create: (options: { authHandler?: AuthHandler | undefined; signIn: { - resolver: SignInResolver; + resolver: SignInResolver_2; }; }) => AuthProviderFactory_2; resolvers: never; @@ -560,15 +560,15 @@ export const providers: Readonly<{ authHandler?: AuthHandler | undefined; signIn?: | { - resolver: SignInResolver; + resolver: SignInResolver_2; } | undefined; } | undefined, ) => AuthProviderFactory_2; resolvers: Readonly<{ - emailLocalPartMatchingUserEntityName: () => SignInResolver; - emailMatchingUserEntityProfileEmail: () => SignInResolver; + emailLocalPartMatchingUserEntityName: () => SignInResolver_2; + emailMatchingUserEntityProfileEmail: () => SignInResolver_2; }>; }>; okta: Readonly<{ @@ -578,16 +578,16 @@ export const providers: Readonly<{ authHandler?: AuthHandler | undefined; signIn?: | { - resolver: SignInResolver; + resolver: SignInResolver_2; } | undefined; } | undefined, ) => AuthProviderFactory_2; resolvers: Readonly<{ - emailLocalPartMatchingUserEntityName: () => SignInResolver; - emailMatchingUserEntityProfileEmail: () => SignInResolver; - emailMatchingUserEntityAnnotation(): SignInResolver; + emailLocalPartMatchingUserEntityName: () => SignInResolver_2; + emailMatchingUserEntityProfileEmail: () => SignInResolver_2; + emailMatchingUserEntityAnnotation(): SignInResolver_2; }>; }>; onelogin: Readonly<{ @@ -597,7 +597,7 @@ export const providers: Readonly<{ authHandler?: AuthHandler | undefined; signIn?: | { - resolver: SignInResolver; + resolver: SignInResolver_2; } | undefined; } @@ -612,14 +612,14 @@ export const providers: Readonly<{ authHandler?: AuthHandler | undefined; signIn?: | { - resolver: SignInResolver; + resolver: SignInResolver_2; } | undefined; } | undefined, ) => AuthProviderFactory_2; resolvers: Readonly<{ - nameIdMatchingUserEntityName(): SignInResolver; + nameIdMatchingUserEntityName(): SignInResolver_2; }>; }>; easyAuth: Readonly<{ @@ -628,7 +628,7 @@ export const providers: Readonly<{ | { authHandler?: AuthHandler | undefined; signIn: { - resolver: SignInResolver; + resolver: SignInResolver_2; }; } | undefined, diff --git a/plugins/auth-backend/src/identity/StaticTokenIssuer.ts b/plugins/auth-backend/src/identity/StaticTokenIssuer.ts index 41dc96e71c45d..17fbe1b180d3d 100644 --- a/plugins/auth-backend/src/identity/StaticTokenIssuer.ts +++ b/plugins/auth-backend/src/identity/StaticTokenIssuer.ts @@ -13,12 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { AnyJWK, TokenIssuer, TokenParams } from './types'; + +import { AnyJWK, TokenIssuer } from './types'; import { SignJWT, importJWK, JWK } from 'jose'; import { parseEntityRef } from '@backstage/catalog-model'; import { AuthenticationError } from '@backstage/errors'; import { LoggerService } from '@backstage/backend-plugin-api'; import { StaticKeyStore } from './StaticKeyStore'; +import { TokenParams } from '@backstage/plugin-auth-node'; const MS_IN_S = 1000; diff --git a/plugins/auth-backend/src/identity/TokenFactory.ts b/plugins/auth-backend/src/identity/TokenFactory.ts index f77807726787b..4c2e7bac7ae84 100644 --- a/plugins/auth-backend/src/identity/TokenFactory.ts +++ b/plugins/auth-backend/src/identity/TokenFactory.ts @@ -13,14 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { parseEntityRef } from '@backstage/catalog-model'; import { AuthenticationError } from '@backstage/errors'; import { exportJWK, generateKeyPair, importJWK, JWK, SignJWT } from 'jose'; import { DateTime } from 'luxon'; import { v4 as uuid } from 'uuid'; import { LoggerService } from '@backstage/backend-plugin-api'; - -import { AnyJWK, KeyStore, TokenIssuer, TokenParams } from './types'; +import { TokenParams } from '@backstage/plugin-auth-node'; +import { AnyJWK, KeyStore, TokenIssuer } from './types'; const MS_IN_S = 1000; const MAX_TOKEN_LENGTH = 32768; // At 64 bytes per entity ref this still leaves room for about 500 entities diff --git a/plugins/auth-backend/src/identity/types.ts b/plugins/auth-backend/src/identity/types.ts index fcfc0345cc6cc..059b9fca848bc 100644 --- a/plugins/auth-backend/src/identity/types.ts +++ b/plugins/auth-backend/src/identity/types.ts @@ -37,7 +37,7 @@ export type TokenIssuer = { /** * Issues a new ID Token */ - issueToken(params: TokenParams): Promise; + issueToken(params: _TokenParams): Promise; /** * List all public keys that are currently being used to sign tokens, or have been used diff --git a/plugins/auth-backend/src/lib/oauth/OAuthAdapter.test.ts b/plugins/auth-backend/src/lib/oauth/OAuthAdapter.test.ts index 1b6653d97e42d..48163e6e82911 100644 --- a/plugins/auth-backend/src/lib/oauth/OAuthAdapter.test.ts +++ b/plugins/auth-backend/src/lib/oauth/OAuthAdapter.test.ts @@ -17,8 +17,8 @@ import express from 'express'; import { THOUSAND_DAYS_MS, TEN_MINUTES_MS, OAuthAdapter } from './OAuthAdapter'; import { encodeState } from './helpers'; -import { OAuthHandlers, OAuthLogoutRequest, OAuthState } from './types'; -import { CookieConfigurer } from '../../providers/types'; +import { OAuthHandlers, OAuthLogoutRequest } from './types'; +import { CookieConfigurer, OAuthState } from '@backstage/plugin-auth-node'; const mockResponseData = { providerInfo: { diff --git a/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts b/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts index 9b4afb4b2b228..b5c3642024211 100644 --- a/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts +++ b/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts @@ -18,14 +18,13 @@ import express, { CookieOptions } from 'express'; import crypto from 'crypto'; import { URL } from 'url'; import { + AuthProviderConfig, + AuthProviderRouteHandlers, BackstageIdentityResponse, BackstageSignInResult, -} from '@backstage/plugin-auth-node'; -import { - AuthProviderRouteHandlers, - AuthProviderConfig, CookieConfigurer, -} from '../../providers/types'; + OAuthState, +} from '@backstage/plugin-auth-node'; import { AuthenticationError, InputError, @@ -42,7 +41,6 @@ import { OAuthHandlers, OAuthStartRequest, OAuthRefreshRequest, - OAuthState, OAuthLogoutRequest, } from './types'; import { prepareBackstageIdentityResponse } from '../../providers/prepareBackstageIdentityResponse'; diff --git a/plugins/auth-backend/src/lib/oauth/helpers.ts b/plugins/auth-backend/src/lib/oauth/helpers.ts index 5e67b072e33b9..fef6dd04aeeb4 100644 --- a/plugins/auth-backend/src/lib/oauth/helpers.ts +++ b/plugins/auth-backend/src/lib/oauth/helpers.ts @@ -15,9 +15,9 @@ */ import express from 'express'; -import { OAuthState } from './types'; -import { CookieConfigurer } from '../../providers/types'; import { + CookieConfigurer, + OAuthState, decodeOAuthState, encodeOAuthState, } from '@backstage/plugin-auth-node'; diff --git a/plugins/auth-backend/src/lib/oauth/types.ts b/plugins/auth-backend/src/lib/oauth/types.ts index b7205c9b85807..76689abcdca4f 100644 --- a/plugins/auth-backend/src/lib/oauth/types.ts +++ b/plugins/auth-backend/src/lib/oauth/types.ts @@ -18,9 +18,10 @@ import express from 'express'; import { Profile as PassportProfile } from 'passport'; import { BackstageSignInResult, + ProfileInfo, OAuthState as _OAuthState, } from '@backstage/plugin-auth-node'; -import { OAuthStartResponse, ProfileInfo } from '../../providers/types'; +import { OAuthStartResponse } from '../../providers/types'; /** * Common options for passport.js-based OAuth providers diff --git a/plugins/auth-backend/src/lib/passport/PassportStrategyHelper.ts b/plugins/auth-backend/src/lib/passport/PassportStrategyHelper.ts index 44feb916c5b38..88d3dbfa04d0b 100644 --- a/plugins/auth-backend/src/lib/passport/PassportStrategyHelper.ts +++ b/plugins/auth-backend/src/lib/passport/PassportStrategyHelper.ts @@ -18,9 +18,9 @@ import express from 'express'; import passport from 'passport'; import { decodeJwt } from 'jose'; import { InternalOAuthError } from 'passport-oauth2'; - +import { ProfileInfo } from '@backstage/plugin-auth-node'; import { PassportProfile } from './types'; -import { ProfileInfo, OAuthStartResponse } from '../../providers/types'; +import { OAuthStartResponse } from '../../providers/types'; export type PassportDoneCallback = ( err?: Error, diff --git a/plugins/auth-backend/src/lib/resolvers/CatalogAuthResolverContext.ts b/plugins/auth-backend/src/lib/resolvers/CatalogAuthResolverContext.ts index 7d22526193213..a7e02c1c31a18 100644 --- a/plugins/auth-backend/src/lib/resolvers/CatalogAuthResolverContext.ts +++ b/plugins/auth-backend/src/lib/resolvers/CatalogAuthResolverContext.ts @@ -25,10 +25,13 @@ import { } from '@backstage/catalog-model'; import { ConflictError, InputError, NotFoundError } from '@backstage/errors'; import { LoggerService } from '@backstage/backend-plugin-api'; -import { TokenIssuer, TokenParams } from '../../identity/types'; -import { AuthResolverContext } from '../../providers'; -import { AuthResolverCatalogUserQuery } from '../../providers/types'; +import { TokenIssuer } from '../../identity/types'; import { CatalogIdentityClient } from '../catalog'; +import { + AuthResolverCatalogUserQuery, + AuthResolverContext, + TokenParams, +} from '@backstage/plugin-auth-node'; /** * Uses the default ownership resolution logic to return an array diff --git a/plugins/auth-backend/src/providers/atlassian/provider.ts b/plugins/auth-backend/src/providers/atlassian/provider.ts index a142d1de90a48..0cd95e19d7b0b 100644 --- a/plugins/auth-backend/src/providers/atlassian/provider.ts +++ b/plugins/auth-backend/src/providers/atlassian/provider.ts @@ -14,10 +14,13 @@ * limitations under the License. */ -import { SignInResolver, AuthHandler } from '../types'; +import { AuthHandler } from '../types'; import { OAuthResult } from '../../lib/oauth'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; -import { createOAuthProviderFactory } from '@backstage/plugin-auth-node'; +import { + SignInResolver, + createOAuthProviderFactory, +} from '@backstage/plugin-auth-node'; import { adaptLegacyOAuthHandler, adaptLegacyOAuthSignInResolver, diff --git a/plugins/auth-backend/src/providers/auth0/provider.ts b/plugins/auth-backend/src/providers/auth0/provider.ts index 95e83d2cce656..c399eb08c4ff4 100644 --- a/plugins/auth-backend/src/providers/auth0/provider.ts +++ b/plugins/auth-backend/src/providers/auth0/provider.ts @@ -36,14 +36,13 @@ import { makeProfileInfo, PassportDoneCallback, } from '../../lib/passport'; -import { - OAuthStartResponse, - AuthHandler, - SignInResolver, - AuthResolverContext, -} from '../types'; +import { OAuthStartResponse, AuthHandler } from '../types'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; import { StateStore } from 'passport-oauth2'; +import { + AuthResolverContext, + SignInResolver, +} from '@backstage/plugin-auth-node'; type PrivateInfo = { refreshToken: string; diff --git a/plugins/auth-backend/src/providers/aws-alb/provider.ts b/plugins/auth-backend/src/providers/aws-alb/provider.ts index 3883bbc88ce05..c09f307e96ed0 100644 --- a/plugins/auth-backend/src/providers/aws-alb/provider.ts +++ b/plugins/auth-backend/src/providers/aws-alb/provider.ts @@ -18,8 +18,11 @@ import { AwsAlbResult, awsAlbAuthenticator, } from '@backstage/plugin-auth-backend-module-aws-alb-provider'; -import { createProxyAuthProviderFactory } from '@backstage/plugin-auth-node'; -import { AuthHandler, SignInResolver } from '../types'; +import { + SignInResolver, + createProxyAuthProviderFactory, +} from '@backstage/plugin-auth-node'; +import { AuthHandler } from '../types'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; /** diff --git a/plugins/auth-backend/src/providers/azure-easyauth/provider.test.ts b/plugins/auth-backend/src/providers/azure-easyauth/provider.test.ts index 1b7c51263ce4a..f6a418b6332dd 100644 --- a/plugins/auth-backend/src/providers/azure-easyauth/provider.test.ts +++ b/plugins/auth-backend/src/providers/azure-easyauth/provider.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { AuthHandler, AuthResolverContext } from '../types'; +import { AuthHandler } from '../types'; import { makeProfileInfo } from '../../lib/passport'; import { easyAuth, @@ -26,6 +26,7 @@ import { import { Request, Response } from 'express'; import { SignJWT, JWTPayload, errors as JoseErrors } from 'jose'; import { randomBytes } from 'crypto'; +import { AuthResolverContext } from '@backstage/plugin-auth-node'; const jwtSecret = randomBytes(48); diff --git a/plugins/auth-backend/src/providers/azure-easyauth/provider.ts b/plugins/auth-backend/src/providers/azure-easyauth/provider.ts index ca8cacf892d23..6f6fe72307108 100644 --- a/plugins/auth-backend/src/providers/azure-easyauth/provider.ts +++ b/plugins/auth-backend/src/providers/azure-easyauth/provider.ts @@ -14,13 +14,7 @@ * limitations under the License. */ -import { - AuthHandler, - AuthProviderRouteHandlers, - AuthResolverContext, - AuthResponse, - SignInResolver, -} from '../types'; +import { AuthHandler } from '../types'; import { Request, Response } from 'express'; import { makeProfileInfo } from '../../lib/passport'; import { AuthenticationError } from '@backstage/errors'; @@ -28,6 +22,12 @@ import { prepareBackstageIdentityResponse } from '../prepareBackstageIdentityRes import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; import { Profile } from 'passport'; import { decodeJwt } from 'jose'; +import { + AuthProviderRouteHandlers, + AuthResolverContext, + ClientAuthResponse, + SignInResolver, +} from '@backstage/plugin-auth-node'; export const ID_TOKEN_HEADER = 'x-ms-token-aad-id-token'; export const ACCESS_TOKEN_HEADER = 'x-ms-token-aad-access-token'; @@ -44,7 +44,7 @@ export type EasyAuthResult = { accessToken?: string; }; -export type EasyAuthResponse = AuthResponse<{}>; +export type EasyAuthResponse = ClientAuthResponse<{}>; export class EasyAuthAuthProvider implements AuthProviderRouteHandlers { private readonly resolverContext: AuthResolverContext; diff --git a/plugins/auth-backend/src/providers/bitbucket/provider.test.ts b/plugins/auth-backend/src/providers/bitbucket/provider.test.ts index 503eccffbdec2..66a8f6e396e5d 100644 --- a/plugins/auth-backend/src/providers/bitbucket/provider.test.ts +++ b/plugins/auth-backend/src/providers/bitbucket/provider.test.ts @@ -16,7 +16,7 @@ import { BitbucketAuthProvider, BitbucketOAuthResult } from './provider'; import * as helpers from '../../lib/passport/PassportStrategyHelper'; -import { AuthResolverContext } from '../types'; +import { AuthResolverContext } from '@backstage/plugin-auth-node'; const mockFrameHandler = jest.spyOn( helpers, diff --git a/plugins/auth-backend/src/providers/bitbucket/provider.ts b/plugins/auth-backend/src/providers/bitbucket/provider.ts index cfa30e9a73f0c..4a7f3770a4a7c 100644 --- a/plugins/auth-backend/src/providers/bitbucket/provider.ts +++ b/plugins/auth-backend/src/providers/bitbucket/provider.ts @@ -37,12 +37,11 @@ import { PassportDoneCallback, } from '../../lib/passport'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; +import { AuthHandler, OAuthStartResponse } from '../types'; import { - AuthHandler, - OAuthStartResponse, - SignInResolver, AuthResolverContext, -} from '../types'; + SignInResolver, +} from '@backstage/plugin-auth-node'; type PrivateInfo = { refreshToken: string; diff --git a/plugins/auth-backend/src/providers/bitbucketServer/provider.test.ts b/plugins/auth-backend/src/providers/bitbucketServer/provider.test.ts index f31d653b99bc1..187c3b09a5f55 100644 --- a/plugins/auth-backend/src/providers/bitbucketServer/provider.test.ts +++ b/plugins/auth-backend/src/providers/bitbucketServer/provider.test.ts @@ -16,7 +16,6 @@ import * as helpers from '../../lib/passport/PassportStrategyHelper'; import { makeProfileInfo } from '../../lib/passport'; -import { AuthResolverContext } from '../types'; import { bitbucketServer, BitbucketServerAuthProvider, @@ -25,6 +24,7 @@ import { import { setupServer } from 'msw/node'; import { setupRequestMockHandlers } from '@backstage/backend-test-utils'; import { rest } from 'msw'; +import { AuthResolverContext } from '@backstage/plugin-auth-node'; jest.mock('../../lib/passport/PassportStrategyHelper', () => { return { diff --git a/plugins/auth-backend/src/providers/bitbucketServer/provider.ts b/plugins/auth-backend/src/providers/bitbucketServer/provider.ts index 220f6db5cdc62..d66f7f33c0087 100644 --- a/plugins/auth-backend/src/providers/bitbucketServer/provider.ts +++ b/plugins/auth-backend/src/providers/bitbucketServer/provider.ts @@ -32,17 +32,16 @@ import { executeRefreshTokenStrategy, makeProfileInfo, } from '../../lib/passport'; -import { - AuthHandler, - AuthResolverContext, - OAuthStartResponse, - SignInResolver, -} from '../types'; +import { AuthHandler, OAuthStartResponse } from '../types'; import express from 'express'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; import { Profile as PassportProfile } from 'passport'; import { commonByEmailResolver } from '../resolvers'; import fetch from 'node-fetch'; +import { + AuthResolverContext, + SignInResolver, +} from '@backstage/plugin-auth-node'; type PrivateInfo = { refreshToken: string; diff --git a/plugins/auth-backend/src/providers/cloudflare-access/provider.test.ts b/plugins/auth-backend/src/providers/cloudflare-access/provider.test.ts index 1abca4bdf4431..95e4b0901ba3a 100644 --- a/plugins/auth-backend/src/providers/cloudflare-access/provider.test.ts +++ b/plugins/auth-backend/src/providers/cloudflare-access/provider.test.ts @@ -21,8 +21,8 @@ import { CF_AUTH_IDENTITY, CloudflareAccessAuthProvider, } from './provider'; -import { AuthResolverContext } from '../types'; import fetch from 'node-fetch'; +import { AuthResolverContext } from '@backstage/plugin-auth-node'; const jwtMock = jwtVerify as jest.Mocked; const mockJwt = diff --git a/plugins/auth-backend/src/providers/cloudflare-access/provider.ts b/plugins/auth-backend/src/providers/cloudflare-access/provider.ts index 6313276508399..fe271f905879d 100644 --- a/plugins/auth-backend/src/providers/cloudflare-access/provider.ts +++ b/plugins/auth-backend/src/providers/cloudflare-access/provider.ts @@ -13,13 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { - AuthHandler, - AuthProviderRouteHandlers, - AuthResolverContext, - AuthResponse, - SignInResolver, -} from '../types'; + +import { AuthHandler } from '../types'; import fetch, { Headers } from 'node-fetch'; import express from 'express'; import * as _ from 'lodash'; @@ -33,6 +28,12 @@ import { CacheClient } from '@backstage/backend-common'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; import { prepareBackstageIdentityResponse } from '../prepareBackstageIdentityResponse'; import { commonByEmailResolver } from '../resolvers'; +import { + AuthProviderRouteHandlers, + AuthResolverContext, + ClientAuthResponse, + SignInResolver, +} from '@backstage/plugin-auth-node'; // JWT Web Token definitions are in the URL below // https://developers.cloudflare.com/cloudflare-one/identity/users/validating-json/ @@ -174,7 +175,7 @@ export type CloudflareAccessProviderInfo = { }; export type CloudflareAccessResponse = - AuthResponse; + ClientAuthResponse; export class CloudflareAccessAuthProvider implements AuthProviderRouteHandlers { private readonly teamName: string; diff --git a/plugins/auth-backend/src/providers/createAuthProviderIntegration.ts b/plugins/auth-backend/src/providers/createAuthProviderIntegration.ts index 9143d63143733..9846bb8bf9572 100644 --- a/plugins/auth-backend/src/providers/createAuthProviderIntegration.ts +++ b/plugins/auth-backend/src/providers/createAuthProviderIntegration.ts @@ -14,7 +14,10 @@ * limitations under the License. */ -import { AuthProviderFactory, SignInResolver } from './types'; +import { + AuthProviderFactory, + SignInResolver, +} from '@backstage/plugin-auth-node'; /** * Creates a standardized representation of an integration with a third-party diff --git a/plugins/auth-backend/src/providers/gcp-iap/provider.ts b/plugins/auth-backend/src/providers/gcp-iap/provider.ts index db4d9195b2aa4..e0c5b62d47595 100644 --- a/plugins/auth-backend/src/providers/gcp-iap/provider.ts +++ b/plugins/auth-backend/src/providers/gcp-iap/provider.ts @@ -15,9 +15,12 @@ */ import { gcpIapAuthenticator } from '@backstage/plugin-auth-backend-module-gcp-iap-provider'; -import { createProxyAuthProviderFactory } from '@backstage/plugin-auth-node'; +import { + SignInResolver, + createProxyAuthProviderFactory, +} from '@backstage/plugin-auth-node'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; -import { AuthHandler, SignInResolver } from '../types'; +import { AuthHandler } from '../types'; import { GcpIapResult } from './types'; /** diff --git a/plugins/auth-backend/src/providers/gitlab/provider.ts b/plugins/auth-backend/src/providers/gitlab/provider.ts index 2551d334ecb11..899338adce03c 100644 --- a/plugins/auth-backend/src/providers/gitlab/provider.ts +++ b/plugins/auth-backend/src/providers/gitlab/provider.ts @@ -14,10 +14,13 @@ * limitations under the License. */ -import { SignInResolver, AuthHandler } from '../types'; +import { AuthHandler } from '../types'; import { OAuthResult } from '../../lib/oauth'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; -import { createOAuthProviderFactory } from '@backstage/plugin-auth-node'; +import { + SignInResolver, + createOAuthProviderFactory, +} from '@backstage/plugin-auth-node'; import { adaptLegacyOAuthHandler, adaptLegacyOAuthSignInResolver, diff --git a/plugins/auth-backend/src/providers/google/provider.ts b/plugins/auth-backend/src/providers/google/provider.ts index d467977094708..b5e6e7127ce4d 100644 --- a/plugins/auth-backend/src/providers/google/provider.ts +++ b/plugins/auth-backend/src/providers/google/provider.ts @@ -19,6 +19,7 @@ import { googleSignInResolvers, } from '@backstage/plugin-auth-backend-module-google-provider'; import { + SignInResolver, commonSignInResolvers, createOAuthProviderFactory, } from '@backstage/plugin-auth-node'; @@ -29,7 +30,7 @@ import { } from '../../lib/legacy'; import { OAuthResult } from '../../lib/oauth'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; -import { AuthHandler, SignInResolver } from '../types'; +import { AuthHandler } from '../types'; /** * Auth provider integration for Google auth diff --git a/plugins/auth-backend/src/providers/microsoft/provider.ts b/plugins/auth-backend/src/providers/microsoft/provider.ts index b004cb96514ca..f6a3a83bcbc12 100644 --- a/plugins/auth-backend/src/providers/microsoft/provider.ts +++ b/plugins/auth-backend/src/providers/microsoft/provider.ts @@ -14,10 +14,11 @@ * limitations under the License. */ -import { SignInResolver, AuthHandler } from '../types'; +import { AuthHandler } from '../types'; import { OAuthResult } from '../../lib/oauth'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; import { + SignInResolver, commonSignInResolvers, createOAuthProviderFactory, } from '@backstage/plugin-auth-node'; diff --git a/plugins/auth-backend/src/providers/oauth2-proxy/provider.ts b/plugins/auth-backend/src/providers/oauth2-proxy/provider.ts index 5d75167e84dd9..4200355c1a2f4 100644 --- a/plugins/auth-backend/src/providers/oauth2-proxy/provider.ts +++ b/plugins/auth-backend/src/providers/oauth2-proxy/provider.ts @@ -14,8 +14,11 @@ * limitations under the License. */ -import { createProxyAuthProviderFactory } from '@backstage/plugin-auth-node'; -import { AuthHandler, SignInResolver } from '../types'; +import { + SignInResolver, + createProxyAuthProviderFactory, +} from '@backstage/plugin-auth-node'; +import { AuthHandler } from '../types'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; import { type OAuth2ProxyResult, diff --git a/plugins/auth-backend/src/providers/oauth2/provider.ts b/plugins/auth-backend/src/providers/oauth2/provider.ts index de6e7b1cfafa7..3a00de1f95ee0 100644 --- a/plugins/auth-backend/src/providers/oauth2/provider.ts +++ b/plugins/auth-backend/src/providers/oauth2/provider.ts @@ -15,13 +15,16 @@ */ import { OAuthResult } from '../../lib/oauth'; -import { AuthHandler, SignInResolver } from '../types'; +import { AuthHandler } from '../types'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; import { adaptLegacyOAuthHandler, adaptLegacyOAuthSignInResolver, } from '../../lib/legacy'; -import { createOAuthProviderFactory } from '@backstage/plugin-auth-node'; +import { + SignInResolver, + createOAuthProviderFactory, +} from '@backstage/plugin-auth-node'; import { oauth2Authenticator } from '@backstage/plugin-auth-backend-module-oauth2-provider'; /** diff --git a/plugins/auth-backend/src/providers/oidc/provider.ts b/plugins/auth-backend/src/providers/oidc/provider.ts index 9bc78c48d2371..40e837b0b03a8 100644 --- a/plugins/auth-backend/src/providers/oidc/provider.ts +++ b/plugins/auth-backend/src/providers/oidc/provider.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { AuthHandler, SignInResolver } from '../types'; +import { AuthHandler } from '../types'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; import { createOAuthProviderFactory, @@ -22,6 +22,7 @@ import { BackstageSignInResult, OAuthAuthenticatorResult, SignInInfo, + SignInResolver, } from '@backstage/plugin-auth-node'; import { oidcAuthenticator, diff --git a/plugins/auth-backend/src/providers/okta/provider.ts b/plugins/auth-backend/src/providers/okta/provider.ts index 669914e7fc13c..463afc2bf4f57 100644 --- a/plugins/auth-backend/src/providers/okta/provider.ts +++ b/plugins/auth-backend/src/providers/okta/provider.ts @@ -14,11 +14,14 @@ * limitations under the License. */ -import { AuthHandler, SignInResolver } from '../types'; +import { AuthHandler } from '../types'; import { OAuthResult } from '../../lib/oauth'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; -import { createOAuthProviderFactory } from '@backstage/plugin-auth-node'; +import { + SignInResolver, + createOAuthProviderFactory, +} from '@backstage/plugin-auth-node'; import { adaptLegacyOAuthHandler, adaptLegacyOAuthSignInResolver, diff --git a/plugins/auth-backend/src/providers/onelogin/provider.ts b/plugins/auth-backend/src/providers/onelogin/provider.ts index ac636f92cc28c..c5ba57f0909d8 100644 --- a/plugins/auth-backend/src/providers/onelogin/provider.ts +++ b/plugins/auth-backend/src/providers/onelogin/provider.ts @@ -36,13 +36,12 @@ import { executeFetchUserProfileStrategy, PassportDoneCallback, } from '../../lib/passport'; +import { OAuthStartResponse, AuthHandler } from '../types'; +import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; import { - OAuthStartResponse, - AuthHandler, - SignInResolver, AuthResolverContext, -} from '../types'; -import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; + SignInResolver, +} from '@backstage/plugin-auth-node'; type PrivateInfo = { refreshToken: string; diff --git a/plugins/auth-backend/src/providers/providers.ts b/plugins/auth-backend/src/providers/providers.ts index 36a24f4f6cde9..76ac51f6626eb 100644 --- a/plugins/auth-backend/src/providers/providers.ts +++ b/plugins/auth-backend/src/providers/providers.ts @@ -30,9 +30,9 @@ import { oidc } from './oidc'; import { okta } from './okta'; import { onelogin } from './onelogin'; import { saml } from './saml'; -import { AuthProviderFactory } from './types'; import { bitbucketServer } from './bitbucketServer'; import { easyAuth } from './azure-easyauth'; +import { AuthProviderFactory } from '@backstage/plugin-auth-node'; /** * All built-in auth provider integrations. diff --git a/plugins/auth-backend/src/providers/resolvers.ts b/plugins/auth-backend/src/providers/resolvers.ts index 129c29c5e4078..54c78ff182525 100644 --- a/plugins/auth-backend/src/providers/resolvers.ts +++ b/plugins/auth-backend/src/providers/resolvers.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { SignInResolver } from './types'; +import { SignInResolver } from '@backstage/plugin-auth-node'; /** * A common sign-in resolver that looks up the user using the local part of diff --git a/plugins/auth-backend/src/providers/saml/provider.ts b/plugins/auth-backend/src/providers/saml/provider.ts index 0da55ed3e4921..d922034e2f667 100644 --- a/plugins/auth-backend/src/providers/saml/provider.ts +++ b/plugins/auth-backend/src/providers/saml/provider.ts @@ -25,17 +25,17 @@ import { executeFrameHandlerStrategy, executeRedirectStrategy, } from '../../lib/passport'; -import { - AuthProviderRouteHandlers, - AuthHandler, - SignInResolver, - AuthResponse, - AuthResolverContext, -} from '../types'; +import { AuthHandler } from '../types'; import { postMessageResponse } from '../../lib/flow'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; import { AuthenticationError, isError } from '@backstage/errors'; import { prepareBackstageIdentityResponse } from '../prepareBackstageIdentityResponse'; +import { + AuthProviderRouteHandlers, + AuthResolverContext, + ClientAuthResponse, + SignInResolver, +} from '@backstage/plugin-auth-node'; /** @public */ export type SamlAuthResult = { @@ -93,7 +93,7 @@ export class SamlAuthProvider implements AuthProviderRouteHandlers { const { profile } = await this.authHandler(result, this.resolverContext); - const response: AuthResponse<{}> = { + const response: ClientAuthResponse<{}> = { profile, providerInfo: {}, }; diff --git a/plugins/auth-backend/src/providers/types.ts b/plugins/auth-backend/src/providers/types.ts index 354387153caa1..40c693506ea2f 100644 --- a/plugins/auth-backend/src/providers/types.ts +++ b/plugins/auth-backend/src/providers/types.ts @@ -110,7 +110,7 @@ export type SignInResolver = _SignInResolver; * @public * @deprecated Use `createOAuthRouteHandlers` from `@backstage/plugin-auth-node` instead */ -export type AuthHandlerResult = { profile: ProfileInfo }; +export type AuthHandlerResult = { profile: _ProfileInfo }; /** * The AuthHandler function is called every time the user authenticates using @@ -128,7 +128,7 @@ export type AuthHandlerResult = { profile: ProfileInfo }; */ export type AuthHandler = ( input: TAuthResult, - context: AuthResolverContext, + context: _AuthResolverContext, ) => Promise; /** diff --git a/plugins/auth-backend/src/service/router.ts b/plugins/auth-backend/src/service/router.ts index 44861207edf34..a8876a7559ba0 100644 --- a/plugins/auth-backend/src/service/router.ts +++ b/plugins/auth-backend/src/service/router.ts @@ -18,10 +18,7 @@ import express from 'express'; import Router from 'express-promise-router'; import cookieParser from 'cookie-parser'; import { LoggerService } from '@backstage/backend-plugin-api'; -import { - defaultAuthProviderFactories, - AuthProviderFactory, -} from '../providers'; +import { defaultAuthProviderFactories } from '../providers'; import { PluginDatabaseManager, PluginEndpointDiscovery, @@ -41,6 +38,7 @@ import { TokenIssuer } from '../identity/types'; import { StaticTokenIssuer } from '../identity/StaticTokenIssuer'; import { StaticKeyStore } from '../identity/StaticKeyStore'; import { Config } from '@backstage/config'; +import { AuthProviderFactory } from '@backstage/plugin-auth-node'; /** @public */ export type ProviderFactories = { [s: string]: AuthProviderFactory };