From c4d8ff9638490014307ca2e484bf7a50621ee2a8 Mon Sep 17 00:00:00 2001 From: Tim Hansen Date: Thu, 29 Jul 2021 15:43:09 -0600 Subject: [PATCH] Switch frontend identity to `token` instead of `idToken` Co-authored-by: Joe Porpeglia Signed-off-by: Tim Hansen --- .changeset/lucky-spiders-impress.md | 6 ++++++ .../core-components/src/layout/SignInPage/SignInPage.tsx | 2 +- .../src/layout/SignInPage/auth0Provider.tsx | 4 ++-- .../src/layout/SignInPage/commonProvider.tsx | 2 +- packages/core-plugin-api/src/apis/definitions/auth.ts | 8 +++++++- 5 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 .changeset/lucky-spiders-impress.md diff --git a/.changeset/lucky-spiders-impress.md b/.changeset/lucky-spiders-impress.md new file mode 100644 index 0000000000..270ecf7a7c --- /dev/null +++ b/.changeset/lucky-spiders-impress.md @@ -0,0 +1,6 @@ +--- +'@backstage/core-components': patch +'@backstage/core-plugin-api': patch +--- + +Switched frontend identity code to use `token` instead of the deprecated `idToken` field diff --git a/packages/core-components/src/layout/SignInPage/SignInPage.tsx b/packages/core-components/src/layout/SignInPage/SignInPage.tsx index 1ccce80e59..d19574999f 100644 --- a/packages/core-components/src/layout/SignInPage/SignInPage.tsx +++ b/packages/core-components/src/layout/SignInPage/SignInPage.tsx @@ -130,7 +130,7 @@ export const SingleSignInPage = ({ userId: identity!.id, profile: profile!, getIdToken: () => { - return authApi.getBackstageIdentity().then(i => i!.idToken); + return authApi.getBackstageIdentity().then(i => i!.token); }, signOut: async () => { await authApi.signOut(); diff --git a/packages/core-components/src/layout/SignInPage/auth0Provider.tsx b/packages/core-components/src/layout/SignInPage/auth0Provider.tsx index f105cd4716..2f5c8b5edb 100644 --- a/packages/core-components/src/layout/SignInPage/auth0Provider.tsx +++ b/packages/core-components/src/layout/SignInPage/auth0Provider.tsx @@ -40,7 +40,7 @@ const Component: ProviderComponent = ({ onResult }) => { userId: identity!.id, profile: profile!, getIdToken: () => - auth0AuthApi.getBackstageIdentity().then(i => i!.idToken), + auth0AuthApi.getBackstageIdentity().then(i => i!.token), signOut: async () => { await auth0AuthApi.signOut(); }, @@ -82,7 +82,7 @@ const loader: ProviderLoader = async apis => { return { userId: identity.id, profile: profile!, - getIdToken: () => auth0AuthApi.getBackstageIdentity().then(i => i!.idToken), + getIdToken: () => auth0AuthApi.getBackstageIdentity().then(i => i!.token), signOut: async () => { await auth0AuthApi.signOut(); }, diff --git a/packages/core-components/src/layout/SignInPage/commonProvider.tsx b/packages/core-components/src/layout/SignInPage/commonProvider.tsx index bd46e6fa58..6f8339bcf3 100644 --- a/packages/core-components/src/layout/SignInPage/commonProvider.tsx +++ b/packages/core-components/src/layout/SignInPage/commonProvider.tsx @@ -86,7 +86,7 @@ const loader: ProviderLoader = async (apis, apiRef) => { return { userId: identity.id, profile: profile!, - getIdToken: () => authApi.getBackstageIdentity().then(i => i!.idToken), + getIdToken: () => authApi.getBackstageIdentity().then(i => i!.token), signOut: async () => { await authApi.signOut(); }, diff --git a/packages/core-plugin-api/src/apis/definitions/auth.ts b/packages/core-plugin-api/src/apis/definitions/auth.ts index c786b43fc3..9e0a3a03e3 100644 --- a/packages/core-plugin-api/src/apis/definitions/auth.ts +++ b/packages/core-plugin-api/src/apis/definitions/auth.ts @@ -151,9 +151,15 @@ export type BackstageIdentity = { id: string; /** - * An ID token that can be used to authenticate the user within Backstage. + * This is deprecated, use `token` instead. + * @deprecated */ idToken: string; + + /** + * The token used to authenticate the user within Backstage. + */ + token: string; }; /**