diff --git a/packages/core-plugin-api/api-report.md b/packages/core-plugin-api/api-report.md index 9245f039df..ad7d0b80a9 100644 --- a/packages/core-plugin-api/api-report.md +++ b/packages/core-plugin-api/api-report.md @@ -237,7 +237,7 @@ export type AuthRequestOptions = { instantPopup?: boolean; }; -// @public @deprecated (undocumented) +// @public @deprecated export type BackstageIdentity = BackstageIdentityResponse; // @public diff --git a/packages/core-plugin-api/src/apis/definitions/auth.ts b/packages/core-plugin-api/src/apis/definitions/auth.ts index e093a6b29b..37308ec29b 100644 --- a/packages/core-plugin-api/src/apis/definitions/auth.ts +++ b/packages/core-plugin-api/src/apis/definitions/auth.ts @@ -212,6 +212,8 @@ export type BackstageIdentityResponse = { }; /** + * The old exported symbol for {@link BackstageIdentityResponse}. + * * @public * @deprecated use {@link BackstageIdentityResponse} instead. */ diff --git a/plugins/auth-backend/api-report.md b/plugins/auth-backend/api-report.md index 7d776986a7..41c017ef6b 100644 --- a/plugins/auth-backend/api-report.md +++ b/plugins/auth-backend/api-report.md @@ -116,13 +116,24 @@ export type AwsAlbProviderOptions = { }; }; +// @public @deprecated +export type BackstageIdentity = BackstageSignInResult; + // @public -export type BackstageIdentityResponse = { - id: string; - entity?: Entity; - token: string; +export interface BackstageIdentityResponse extends BackstageSignInResult { identity: BackstageUserIdentity; -}; +} + +// Warning: (ae-missing-release-tag) "BackstageSignInResult" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface BackstageSignInResult { + // @deprecated + entity?: Entity; + // @deprecated + id: string; + token: string; +} // @public export type BackstageUserIdentity = { @@ -504,11 +515,10 @@ export type OAuthRefreshRequest = express.Request<{}> & { // Warning: (ae-missing-release-tag) "OAuthResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export type OAuthResponse = Omit< - AuthResponse, - 'backstageIdentity' -> & { - backstageIdentity?: Omit; +export type OAuthResponse = { + profile: ProfileInfo; + providerInfo: OAuthProviderInfo; + backstageIdentity?: BackstageSignInResult; }; // Warning: (ae-missing-release-tag) "OAuthResult" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) diff --git a/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts b/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts index b6c6473031..bb0bbf9dbd 100644 --- a/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts +++ b/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts @@ -21,6 +21,7 @@ import { AuthProviderRouteHandlers, AuthProviderConfig, BackstageIdentityResponse, + BackstageSignInResult, } from '../../providers/types'; import { AuthenticationError, @@ -232,7 +233,7 @@ export class OAuthAdapter implements AuthProviderRouteHandlers { * make sure it's populated with all the information we can derive from the user ID. */ private async populateIdentity( - identity?: Omit, + identity?: BackstageSignInResult, ): Promise { if (!identity) { return undefined; diff --git a/plugins/auth-backend/src/lib/oauth/types.ts b/plugins/auth-backend/src/lib/oauth/types.ts index f1ff9e763d..48e3ffe6ea 100644 --- a/plugins/auth-backend/src/lib/oauth/types.ts +++ b/plugins/auth-backend/src/lib/oauth/types.ts @@ -17,10 +17,11 @@ import express from 'express'; import { Profile as PassportProfile } from 'passport'; import { - AuthResponse, RedirectInfo, - BackstageIdentityResponse, + BackstageSignInResult, + ProfileInfo, } from '../../providers/types'; + /** * Common options for passport.js-based OAuth providers */ @@ -50,11 +51,10 @@ export type OAuthResult = { refreshToken?: string; }; -export type OAuthResponse = Omit< - AuthResponse, - 'backstageIdentity' -> & { - backstageIdentity?: Omit; +export type OAuthResponse = { + profile: ProfileInfo; + providerInfo: OAuthProviderInfo; + backstageIdentity?: BackstageSignInResult; }; export type OAuthProviderInfo = { diff --git a/plugins/auth-backend/src/providers/index.ts b/plugins/auth-backend/src/providers/index.ts index 34c2ff06c2..9fe77fe593 100644 --- a/plugins/auth-backend/src/providers/index.ts +++ b/plugins/auth-backend/src/providers/index.ts @@ -40,8 +40,10 @@ export type { // to the frontend export type { AuthResponse, + BackstageIdentity, BackstageUserIdentity, BackstageIdentityResponse, + BackstageSignInResult, ProfileInfo, } from './types'; diff --git a/plugins/auth-backend/src/providers/types.ts b/plugins/auth-backend/src/providers/types.ts index 919cbe42b4..9f93e6fa21 100644 --- a/plugins/auth-backend/src/providers/types.ts +++ b/plugins/auth-backend/src/providers/types.ts @@ -164,11 +164,7 @@ export type BackstageUserIdentity = { ownershipEntityRefs: string[]; }; -/** - * Response object containing the {@link BackstageUserIdentity} and the token from the authentication provider. - * @public - */ -export type BackstageIdentityResponse = { +export interface BackstageSignInResult { /** * An opaque ID that uniquely identifies the user within Backstage. * @@ -192,12 +188,25 @@ export type BackstageIdentityResponse = { * The token used to authenticate the user within Backstage. */ token: string; +} +/** + * The old exported symbol for {@link BackstageSignInResult}. + * @public + * @deprecated Use the `BackstageSignInResult` type instead. + */ +export type BackstageIdentity = BackstageSignInResult; + +/** + * Response object containing the {@link BackstageUserIdentity} and the token from the authentication provider. + * @public + */ +export interface BackstageIdentityResponse extends BackstageSignInResult { /** * A plaintext description of the identity that is encapsulated within the token. */ identity: BackstageUserIdentity; -}; +} /** * Used to display login information to user, i.e. sidebar popup. @@ -242,7 +251,7 @@ export type SignInResolver = ( catalogIdentityClient: CatalogIdentityClient; logger: Logger; }, -) => Promise>; +) => Promise; export type AuthHandlerResult = { profile: ProfileInfo };