From 95f81d56a887a588a2780d9c11f23232d46bbaac Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Mon, 19 Sep 2022 16:31:54 +0200 Subject: [PATCH 01/35] Provide custom links in EntityRefLinks Signed-off-by: bnechyporenko --- .../src/components/EntityRefLink/EntityRefLinks.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx index 30dda011d4..054dd0350c 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx @@ -1,5 +1,5 @@ /* - * Copyright 2020 The Backstage Authors + * Copyright 2022 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import { Entity, CompoundEntityRef } from '@backstage/catalog-model'; import React from 'react'; import { EntityRefLink } from './EntityRefLink'; @@ -27,6 +26,7 @@ import { LinkProps } from '@backstage/core-components'; export type EntityRefLinksProps = { entityRefs: (string | Entity | CompoundEntityRef)[]; defaultKind?: string; + titleFn?: (r: string | Entity | CompoundEntityRef) => string; } & Omit; /** @@ -35,7 +35,7 @@ export type EntityRefLinksProps = { * @public */ export function EntityRefLinks(props: EntityRefLinksProps) { - const { entityRefs, defaultKind, ...linkProps } = props; + const { entityRefs, defaultKind, titleFn, ...linkProps } = props; return ( <> {entityRefs.map((r, i) => ( @@ -45,6 +45,7 @@ export function EntityRefLinks(props: EntityRefLinksProps) { {...linkProps} entityRef={r} defaultKind={defaultKind} + title={titleFn ? titleFn(r) : undefined} /> ))} From aeb0d0227696147887f2b10cdee181cba319a5ee Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Mon, 19 Sep 2022 16:43:46 +0200 Subject: [PATCH 02/35] Updated api-report.md Signed-off-by: bnechyporenko --- plugins/catalog-react/api-report.md | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index ee43a0a5c1..49dd7843c0 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -285,6 +285,7 @@ export function EntityRefLinks(props: EntityRefLinksProps): JSX.Element; export type EntityRefLinksProps = { entityRefs: (string | Entity | CompoundEntityRef)[]; defaultKind?: string; + titleFn?: (r: string | Entity | CompoundEntityRef) => string; } & Omit; // @public From 7939e743f58e2485b789ee382b5777aed0f46a0f Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Mon, 19 Sep 2022 16:56:49 +0200 Subject: [PATCH 03/35] Added a release note Signed-off-by: bnechyporenko --- .changeset/calm-pianos-burn.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/calm-pianos-burn.md diff --git a/.changeset/calm-pianos-burn.md b/.changeset/calm-pianos-burn.md new file mode 100644 index 0000000000..a7860ca4b7 --- /dev/null +++ b/.changeset/calm-pianos-burn.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-react': patch +--- + +Provide custom displayed text in EntityRefLinks From f4c67c3eca7c78addcb2c96dd3566f09dedd5679 Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Mon, 19 Sep 2022 18:19:22 +0200 Subject: [PATCH 04/35] Incorporated the feedback Signed-off-by: bnechyporenko --- plugins/catalog-react/api-report.md | 2 +- .../EntityRefLink/EntityRefLinks.tsx | 35 ++++++++++++------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index 49dd7843c0..711e1935c1 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -285,7 +285,7 @@ export function EntityRefLinks(props: EntityRefLinksProps): JSX.Element; export type EntityRefLinksProps = { entityRefs: (string | Entity | CompoundEntityRef)[]; defaultKind?: string; - titleFn?: (r: string | Entity | CompoundEntityRef) => string; + getTitle?: (cer: CompoundEntityRef) => string; } & Omit; // @public diff --git a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx index 054dd0350c..0434dfb525 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx @@ -26,7 +26,7 @@ import { LinkProps } from '@backstage/core-components'; export type EntityRefLinksProps = { entityRefs: (string | Entity | CompoundEntityRef)[]; defaultKind?: string; - titleFn?: (r: string | Entity | CompoundEntityRef) => string; + getTitle?: (cer: CompoundEntityRef) => string; } & Omit; /** @@ -35,20 +35,29 @@ export type EntityRefLinksProps = { * @public */ export function EntityRefLinks(props: EntityRefLinksProps) { - const { entityRefs, defaultKind, titleFn, ...linkProps } = props; + const { entityRefs, defaultKind, getTitle, ...linkProps } = props; return ( <> - {entityRefs.map((r, i) => ( - - {i > 0 && ', '} - - - ))} + {entityRefs.map((r, i) => { + const isCompoundEntityRef = + getTitle && typeof r !== 'string' && !('metadata' in r && getTitle); + + const title = isCompoundEntityRef + ? getTitle(r as CompoundEntityRef) + : undefined; + + return ( + + {i > 0 && ', '} + + + ); + })} ); } From aa6372c0bb2ddb716cb2b9c04cd6fede7ca88848 Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Mon, 19 Sep 2022 18:21:23 +0200 Subject: [PATCH 05/35] Incorporated the feedback Signed-off-by: bnechyporenko --- .../src/components/EntityRefLink/EntityRefLinks.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx index 0434dfb525..b1a0c39558 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx @@ -40,7 +40,7 @@ export function EntityRefLinks(props: EntityRefLinksProps) { <> {entityRefs.map((r, i) => { const isCompoundEntityRef = - getTitle && typeof r !== 'string' && !('metadata' in r && getTitle); + getTitle && typeof r !== 'string' && !('metadata' in r); const title = isCompoundEntityRef ? getTitle(r as CompoundEntityRef) From 4b4e8975aa85140c2cd147f1292b445be12fdb4a Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Mon, 19 Sep 2022 18:39:54 +0200 Subject: [PATCH 06/35] Incorporated the feedback Signed-off-by: bnechyporenko --- plugins/catalog-react/api-report.md | 2 +- .../src/components/EntityRefLink/EntityRefLinks.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index 711e1935c1..bb19e2a5b8 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -285,7 +285,7 @@ export function EntityRefLinks(props: EntityRefLinksProps): JSX.Element; export type EntityRefLinksProps = { entityRefs: (string | Entity | CompoundEntityRef)[]; defaultKind?: string; - getTitle?: (cer: CompoundEntityRef) => string; + getTitle?: (cer: CompoundEntityRef) => string | undefined; } & Omit; // @public diff --git a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx index b1a0c39558..cf18a2d643 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx @@ -26,7 +26,7 @@ import { LinkProps } from '@backstage/core-components'; export type EntityRefLinksProps = { entityRefs: (string | Entity | CompoundEntityRef)[]; defaultKind?: string; - getTitle?: (cer: CompoundEntityRef) => string; + getTitle?: (cer: CompoundEntityRef) => string | undefined; } & Omit; /** From e19bcd165361260ebd716a55afdaf813613dcce3 Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Mon, 26 Sep 2022 17:19:29 +0200 Subject: [PATCH 07/35] Incorporated the feedback Signed-off-by: bnechyporenko --- .../EntityRefLink/EntityRefLinks.tsx | 51 +++++--- .../EntityRefLink/FetchedEntityRefLinks.tsx | 115 ++++++++++++++++++ 2 files changed, 149 insertions(+), 17 deletions(-) create mode 100644 plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx diff --git a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx index cf18a2d643..9f66fffd7a 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx @@ -17,43 +17,60 @@ import { Entity, CompoundEntityRef } from '@backstage/catalog-model'; import React from 'react'; import { EntityRefLink } from './EntityRefLink'; import { LinkProps } from '@backstage/core-components'; +import { FetchedEntityRefLinks } from './FetchedEntityRefLinks'; /** * Props for {@link EntityRefLink}. * * @public */ -export type EntityRefLinksProps = { - entityRefs: (string | Entity | CompoundEntityRef)[]; - defaultKind?: string; - getTitle?: (cer: CompoundEntityRef) => string | undefined; -} & Omit; +export type EntityRefLinksProps< + TRef extends string | CompoundEntityRef | Entity, +> = + | { + defaultKind?: string; + entityRefs: TRef[]; + fetchEntities?: false; + getTitle?(entity: TRef): string | undefined; + } + | ({ + defaultKind?: string; + entityRefs: TRef[]; + fetchEntities: true; + getTitle?(entity: Entity): string | undefined; + } & Omit); /** * Shows a list of clickable links to entities. * * @public */ -export function EntityRefLinks(props: EntityRefLinksProps) { - const { entityRefs, defaultKind, getTitle, ...linkProps } = props; +export function EntityRefLinks< + TRef extends string | CompoundEntityRef | Entity, +>(props: EntityRefLinksProps) { + const { entityRefs, defaultKind, fetchEntities, getTitle, ...linkProps } = + props; + + if (fetchEntities) { + return ( + + ); + } + return ( <> - {entityRefs.map((r, i) => { - const isCompoundEntityRef = - getTitle && typeof r !== 'string' && !('metadata' in r); - - const title = isCompoundEntityRef - ? getTitle(r as CompoundEntityRef) - : undefined; - + {entityRefs.map((r: TRef, i: number) => { return ( {i > 0 && ', '} ); diff --git a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx new file mode 100644 index 0000000000..5dbe429496 --- /dev/null +++ b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx @@ -0,0 +1,115 @@ +/* + * Copyright 2022 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 { Entity, CompoundEntityRef } from '@backstage/catalog-model'; +import React from 'react'; +import { EntityRefLink } from './EntityRefLink'; +import { ErrorPanel, LinkProps, Progress } from '@backstage/core-components'; +import useAsync from 'react-use/lib/useAsync'; +import { catalogApiRef } from '../../api'; +import { useApi } from '@backstage/core-plugin-api'; + +/** + * Props for {@link EntityRefLink}. + * + * @public + */ +export type FetchedEntityRefLinksProps< + TRef extends string | CompoundEntityRef | Entity, +> = { + defaultKind?: string; + entityRefs: TRef[]; + fetchEntities: true; + getTitle?(entity: Entity): string | undefined; +} & Omit; + +/** + * Shows a list of clickable links to entities with auto-fetching of entities + * for customising a displayed text via title attribute. + * + * @public + */ +export function FetchedEntityRefLinks< + TRef extends string | CompoundEntityRef | Entity, +>(props: FetchedEntityRefLinksProps) { + const { entityRefs, defaultKind, fetchEntities, getTitle, ...linkProps } = + props; + + const catalogApi = useApi(catalogApiRef); + + const { + value: refToEntity = new Map(), + loading, + error, + } = useAsync( + () => + entityRefs.reduce( + async (promisedAcc: Promise>, entityRef: TRef) => { + const acc = await promisedAcc; + const entity: Entity | undefined = + 'metadata' in entityRef + ? (entityRef as Entity) + : await catalogApi.getEntityByRef( + entityRef as string | CompoundEntityRef, + ); + if (entity) { + acc.set(entityRef, entity); + } + return acc; + }, + Promise.resolve(new Map()), + ), + [catalogApi, entityRefs], + ); + + if (loading) { + return ; + } + + if (error) { + return ( + <> + + + ); + } + + return ( + <> + {entityRefs.map((r: TRef, i) => { + let title: string | undefined; + + if (typeof r === 'string' || !('metadata' in r)) { + const entity = refToEntity.get(r); + title = getTitle && entity ? getTitle(entity) : undefined; + } else { + title = getTitle ? getTitle(r as Entity) : undefined; + } + + return ( + + {i > 0 && ', '} + + + ); + })} + + ); +} From bc3f2c1f20fdbaf7ce3fbdbcf21f4a02db181c2e Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Tue, 27 Sep 2022 09:11:30 +0200 Subject: [PATCH 08/35] Incorporated partially the feedback Signed-off-by: bnechyporenko --- .../EntityRefLink/EntityRefLinks.tsx | 4 +- .../EntityRefLink/FetchedEntityRefLinks.tsx | 60 ++++++------------- 2 files changed, 22 insertions(+), 42 deletions(-) diff --git a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx index 9f66fffd7a..bb8950041a 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx @@ -54,8 +54,10 @@ export function EntityRefLinks< if (fetchEntities) { return ( ); } diff --git a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx index 5dbe429496..6b6ead7872 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx @@ -13,7 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Entity, CompoundEntityRef } from '@backstage/catalog-model'; +import { + Entity, + CompoundEntityRef, + parseEntityRef, +} from '@backstage/catalog-model'; import React from 'react'; import { EntityRefLink } from './EntityRefLink'; import { ErrorPanel, LinkProps, Progress } from '@backstage/core-components'; @@ -31,7 +35,6 @@ export type FetchedEntityRefLinksProps< > = { defaultKind?: string; entityRefs: TRef[]; - fetchEntities: true; getTitle?(entity: Entity): string | undefined; } & Omit; @@ -44,60 +47,35 @@ export type FetchedEntityRefLinksProps< export function FetchedEntityRefLinks< TRef extends string | CompoundEntityRef | Entity, >(props: FetchedEntityRefLinksProps) { - const { entityRefs, defaultKind, fetchEntities, getTitle, ...linkProps } = - props; + const { entityRefs, defaultKind, getTitle, ...linkProps } = props; const catalogApi = useApi(catalogApiRef); const { - value: refToEntity = new Map(), + value: entities = new Array(), loading, error, - } = useAsync( - () => - entityRefs.reduce( - async (promisedAcc: Promise>, entityRef: TRef) => { - const acc = await promisedAcc; - const entity: Entity | undefined = - 'metadata' in entityRef - ? (entityRef as Entity) - : await catalogApi.getEntityByRef( - entityRef as string | CompoundEntityRef, - ); - if (entity) { - acc.set(entityRef, entity); - } - return acc; - }, - Promise.resolve(new Map()), - ), - [catalogApi, entityRefs], - ); + } = useAsync(async () => { + const refs = entityRefs.reduce((acc, current) => { + return 'metadata' in current ? acc : [...acc, parseEntityRef(current)]; + }, new Array()); + + return refs + ? (await catalogApi.getEntities({ filter: refs })).items + : (entityRefs as Array); + }, [entityRefs]); if (loading) { return ; } if (error) { - return ( - <> - - - ); + return ; } return ( <> - {entityRefs.map((r: TRef, i) => { - let title: string | undefined; - - if (typeof r === 'string' || !('metadata' in r)) { - const entity = refToEntity.get(r); - title = getTitle && entity ? getTitle(entity) : undefined; - } else { - title = getTitle ? getTitle(r as Entity) : undefined; - } - + {entities.map((r: Entity, i) => { return ( {i > 0 && ', '} @@ -105,7 +83,7 @@ export function FetchedEntityRefLinks< {...linkProps} defaultKind={defaultKind} entityRef={r} - title={title} + title={getTitle ? getTitle(r as Entity) : undefined} /> ); From 02ba465d072e9437f9703375da667a370a4cdf19 Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Tue, 27 Sep 2022 15:23:53 +0200 Subject: [PATCH 09/35] Added a test for FetchedEntityRefLinks.tsx Signed-off-by: bnechyporenko --- .../EntityRefLink/EntityRefLinks.tsx | 2 +- .../FetchedEntityRefLinks.test.tsx | 84 +++++++++++++++++++ .../EntityRefLink/FetchedEntityRefLinks.tsx | 4 +- 3 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.test.tsx diff --git a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx index bb8950041a..71a60f3a15 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx @@ -37,7 +37,7 @@ export type EntityRefLinksProps< defaultKind?: string; entityRefs: TRef[]; fetchEntities: true; - getTitle?(entity: Entity): string | undefined; + getTitle(entity: Entity): string | undefined; } & Omit); /** diff --git a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.test.tsx b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.test.tsx new file mode 100644 index 0000000000..0a3ea1003e --- /dev/null +++ b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.test.tsx @@ -0,0 +1,84 @@ +/* + * Copyright 2022 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 { FetchedEntityRefLinks } from './FetchedEntityRefLinks'; +import { entityRouteRef } from '../../routes'; +import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; +import { Entity } from '@backstage/catalog-model'; +import React from 'react'; +import { JsonObject } from '@backstage/types'; +import { catalogApiRef } from '../../api'; +import { CatalogApi } from '@backstage/catalog-client'; + +describe('', () => { + it('should fetch entities and render the custom display text', async () => { + const entityRefs = [ + { + kind: 'Component', + namespace: 'default', + name: 'software', + }, + { + kind: 'API', + namespace: 'default', + name: 'interface', + }, + ]; + + const catalogApi: Partial = { + getEntities: () => + Promise.resolve({ + items: entityRefs.map(ref => ({ + apiVersion: 'backstage.io/v1alpha1', + kind: ref.kind, + metadata: { + name: ref.name, + namespace: ref.namespace, + }, + spec: { + profile: { + displayName: ref.name.toLocaleUpperCase('en-US'), + }, + type: 'organization', + }, + })), + }), + }; + + const getTitle = (e: Entity): string => + (e.spec?.profile!! as JsonObject).displayName!!.toString()!!; + + const rendered = await renderInTestApp( + + + , + { + mountedRoutes: { + '/catalog/:namespace/:kind/:name/*': entityRouteRef, + }, + }, + ); + + expect(rendered.getByText('SOFTWARE')).toHaveAttribute( + 'href', + '/catalog/default/component/software', + ); + + expect(rendered.getByText('INTERFACE')).toHaveAttribute( + 'href', + '/catalog/default/api/interface', + ); + }); +}); diff --git a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx index 6b6ead7872..629306014f 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx @@ -35,7 +35,7 @@ export type FetchedEntityRefLinksProps< > = { defaultKind?: string; entityRefs: TRef[]; - getTitle?(entity: Entity): string | undefined; + getTitle(entity: Entity): string | undefined; } & Omit; /** @@ -83,7 +83,7 @@ export function FetchedEntityRefLinks< {...linkProps} defaultKind={defaultKind} entityRef={r} - title={getTitle ? getTitle(r as Entity) : undefined} + title={getTitle(r as Entity)} /> ); From 2bc50cff236ed9ee2fc00377813d6241efd467ec Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Tue, 27 Sep 2022 15:26:05 +0200 Subject: [PATCH 10/35] Fixed a wrong annotation Signed-off-by: bnechyporenko --- .../src/components/EntityRefLink/FetchedEntityRefLinks.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx index 629306014f..17c0a9de37 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx @@ -26,7 +26,7 @@ import { catalogApiRef } from '../../api'; import { useApi } from '@backstage/core-plugin-api'; /** - * Props for {@link EntityRefLink}. + * Props for {@link FetchedEntityRefLinks}. * * @public */ From 8bb14a6ae6818a3f6334d78d9b3117653600e52e Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Tue, 27 Sep 2022 15:57:53 +0200 Subject: [PATCH 11/35] Fixed a problem in definition of EntityRefLinksProps Signed-off-by: bnechyporenko --- .../src/components/EntityRefLink/EntityRefLinks.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx index 71a60f3a15..2502fbbb6e 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx @@ -26,19 +26,21 @@ import { FetchedEntityRefLinks } from './FetchedEntityRefLinks'; */ export type EntityRefLinksProps< TRef extends string | CompoundEntityRef | Entity, -> = +> = ( | { defaultKind?: string; entityRefs: TRef[]; fetchEntities?: false; getTitle?(entity: TRef): string | undefined; } - | ({ + | { defaultKind?: string; entityRefs: TRef[]; fetchEntities: true; getTitle(entity: Entity): string | undefined; - } & Omit); + } +) & + Omit; /** * Shows a list of clickable links to entities. From d3ae8eed67461d617fc6f2ff49b9bb074072fb7e Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Tue, 27 Sep 2022 16:28:14 +0200 Subject: [PATCH 12/35] Fixed a problem in definition of EntityRefLinksProps Signed-off-by: bnechyporenko --- plugins/catalog-react/api-report.md | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index bb19e2a5b8..9e7a07c08b 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -279,14 +279,28 @@ export type EntityRefLinkProps = { } & Omit; // @public -export function EntityRefLinks(props: EntityRefLinksProps): JSX.Element; +export function EntityRefLinks< + TRef extends string | CompoundEntityRef | Entity, +>(props: EntityRefLinksProps): JSX.Element; // @public -export type EntityRefLinksProps = { - entityRefs: (string | Entity | CompoundEntityRef)[]; - defaultKind?: string; - getTitle?: (cer: CompoundEntityRef) => string | undefined; -} & Omit; +export type EntityRefLinksProps< + TRef extends string | CompoundEntityRef | Entity, +> = ( + | { + defaultKind?: string; + entityRefs: TRef[]; + fetchEntities?: false; + getTitle?(entity: TRef): string | undefined; + } + | { + defaultKind?: string; + entityRefs: TRef[]; + fetchEntities: true; + getTitle(entity: Entity): string | undefined; + } +) & + Omit; // @public export function entityRouteParams(entity: Entity): { From 9e6b3c3adc52426230bda742877996b71c21fe2d Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Tue, 27 Sep 2022 17:44:53 +0200 Subject: [PATCH 13/35] Fixed an issue in filter in FetchedEntityRefLinks.tsx Signed-off-by: bnechyporenko --- .../components/EntityRefLink/FetchedEntityRefLinks.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx index 17c0a9de37..72c9aa5125 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx @@ -61,7 +61,15 @@ export function FetchedEntityRefLinks< }, new Array()); return refs - ? (await catalogApi.getEntities({ filter: refs })).items + ? ( + await catalogApi.getEntities({ + filter: refs.map(ref => ({ + kind: ref.kind, + 'metadata.namespace': ref.namespace, + 'metadata.name': ref.name, + })), + }) + ).items : (entityRefs as Array); }, [entityRefs]); From cca379385193e72ecfcce84f419dfeea3cb18249 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 28 Sep 2022 08:29:37 +0000 Subject: [PATCH 14/35] Update dependency @types/express to v4.17.14 Signed-off-by: Renovate Bot --- yarn.lock | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index 3bc5b112a2..c4bdcc4714 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3872,7 +3872,7 @@ __metadata: "@backstage/backend-common": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" - "@types/express": "*" + "@types/express": ^4.17.6 "@types/http-proxy-middleware": ^0.19.3 "@types/supertest": ^2.0.8 express: ^4.17.1 @@ -4184,7 +4184,7 @@ __metadata: "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" "@backstage/errors": "workspace:^" - "@types/express": "*" + "@types/express": ^4.17.6 express: ^4.17.1 jose: ^4.6.0 lodash: ^4.17.21 @@ -6212,7 +6212,7 @@ __metadata: "@backstage/backend-common": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" - "@types/express": "*" + "@types/express": ^4.17.6 "@types/supertest": ^2.0.8 express: ^4.17.1 express-promise-router: ^4.1.0 @@ -6267,7 +6267,7 @@ __metadata: "@backstage/plugin-auth-node": "workspace:^" "@backstage/plugin-permission-common": "workspace:^" "@backstage/plugin-permission-node": "workspace:^" - "@types/express": "*" + "@types/express": ^4.17.6 "@types/lodash": ^4.14.151 "@types/supertest": ^2.0.8 dataloader: ^2.0.0 @@ -6385,7 +6385,7 @@ __metadata: "@backstage/plugin-permission-common": "workspace:^" "@backstage/plugin-permission-node": "workspace:^" "@backstage/plugin-playlist-common": "workspace:^" - "@types/express": "*" + "@types/express": ^4.17.6 "@types/supertest": ^2.0.8 express: ^4.17.1 express-promise-router: ^4.1.0 @@ -6985,7 +6985,7 @@ __metadata: "@backstage/config": "workspace:^" "@backstage/errors": "workspace:^" "@backstage/test-utils": "workspace:^" - "@types/express": "*" + "@types/express": ^4.17.6 "@types/supertest": ^2.0.12 express: ^4.18.1 express-promise-router: ^4.1.0 @@ -7604,7 +7604,7 @@ __metadata: "@backstage/config": "workspace:^" "@backstage/errors": "workspace:^" "@types/compression": ^1.7.2 - "@types/express": "*" + "@types/express": ^4.17.6 "@types/supertest": ^2.0.8 compression: ^1.7.4 cors: ^2.8.5 @@ -13463,7 +13463,7 @@ __metadata: languageName: node linkType: hard -"@types/express@npm:*, @types/express@npm:4.17.13, @types/express@npm:^4.17.13, @types/express@npm:^4.17.6": +"@types/express@npm:*, @types/express@npm:4.17.13, @types/express@npm:^4.17.13": version: 4.17.13 resolution: "@types/express@npm:4.17.13" dependencies: @@ -13475,6 +13475,18 @@ __metadata: languageName: node linkType: hard +"@types/express@npm:^4.17.6": + version: 4.17.14 + resolution: "@types/express@npm:4.17.14" + dependencies: + "@types/body-parser": "*" + "@types/express-serve-static-core": ^4.17.18 + "@types/qs": "*" + "@types/serve-static": "*" + checksum: 15c1af46d02de834e4a225eccaa9d85c0370fdbb3ed4e1bc2d323d24872309961542b993ae236335aeb3e278630224a6ea002078d39e651d78a3b0356b1eaa79 + languageName: node + linkType: hard + "@types/fs-extra@npm:^9.0.1, @types/fs-extra@npm:^9.0.3, @types/fs-extra@npm:^9.0.5, @types/fs-extra@npm:^9.0.6": version: 9.0.13 resolution: "@types/fs-extra@npm:9.0.13" From 5b8f8b5be15e9c1407c293bc1b25fcb9f936a2e3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Sep 2022 12:24:05 +0000 Subject: [PATCH 15/35] Update dependency @swc/jest to v0.2.23 Signed-off-by: Renovate Bot --- yarn.lock | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 66cc98ff33..59295a0e25 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12634,13 +12634,14 @@ __metadata: linkType: hard "@swc/jest@npm:^0.2.22": - version: 0.2.22 - resolution: "@swc/jest@npm:0.2.22" + version: 0.2.23 + resolution: "@swc/jest@npm:0.2.23" dependencies: "@jest/create-cache-key-function": ^27.4.2 + jsonc-parser: ^3.2.0 peerDependencies: "@swc/core": "*" - checksum: c624cfcc9325a719fc7d811536011c4bde0c63c808827b47d7bbcc57621323146cb3891d8702fd01c1bebfc54a9148692f772af4db8e839eb2c6ccd7850fa5f5 + checksum: 1c7db1f6995916ad77369311be078e9d33f2c6a586be9c87927f6a36d124dcd49c29d8c596758cd9dbf4e388ec30f41989e70e574eb59bef3fb41d3131629763 languageName: node linkType: hard @@ -27233,6 +27234,13 @@ __metadata: languageName: node linkType: hard +"jsonc-parser@npm:^3.2.0": + version: 3.2.0 + resolution: "jsonc-parser@npm:3.2.0" + checksum: 946dd9a5f326b745aa326d48a7257e3f4a4b62c5e98ec8e49fa2bdd8d96cef7e6febf1399f5c7016114fd1f68a1c62c6138826d5d90bc650448e3cf0951c53c7 + languageName: node + linkType: hard + "jsonfile@npm:^4.0.0": version: 4.0.0 resolution: "jsonfile@npm:4.0.0" From c59e05111bfec4fcf31273a339f15f028cafb774 Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Thu, 29 Sep 2022 14:39:06 +0200 Subject: [PATCH 16/35] Fixed an incorrect condition for an empty array Signed-off-by: bnechyporenko --- .../src/components/EntityRefLink/FetchedEntityRefLinks.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx index 72c9aa5125..88b92b4689 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx @@ -60,7 +60,7 @@ export function FetchedEntityRefLinks< return 'metadata' in current ? acc : [...acc, parseEntityRef(current)]; }, new Array()); - return refs + return refs.length > 0 ? ( await catalogApi.getEntities({ filter: refs.map(ref => ({ From 94431456d46d93896407806d79f235abc7a108a9 Mon Sep 17 00:00:00 2001 From: Bogdan Nechyporenko Date: Thu, 29 Sep 2022 14:39:48 +0200 Subject: [PATCH 17/35] Update .changeset/calm-pianos-burn.md Co-authored-by: Patrik Oldsberg Signed-off-by: Bogdan Nechyporenko --- .changeset/calm-pianos-burn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/calm-pianos-burn.md b/.changeset/calm-pianos-burn.md index a7860ca4b7..6a44d42cfe 100644 --- a/.changeset/calm-pianos-burn.md +++ b/.changeset/calm-pianos-burn.md @@ -2,4 +2,4 @@ '@backstage/plugin-catalog-react': patch --- -Provide custom displayed text in EntityRefLinks +Added two new `EntityRefLinks` props, the first being `getTitle` that allows for customization of the title used for each link. The second one is `fetchEntities`, which triggers a fetching of all entities so that the full entity definition is available in the `getTitle` callback. From 4a7dd7865e924e68beb3e531c15b54b8e4045748 Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Thu, 29 Sep 2022 15:22:37 +0200 Subject: [PATCH 18/35] Added a test case which covers the case when the array of entities was provided to entityRefs Signed-off-by: bnechyporenko --- .../FetchedEntityRefLinks.test.tsx | 57 ++++++++++++++++++- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.test.tsx b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.test.tsx index 0a3ea1003e..c416adcfbd 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.test.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.test.tsx @@ -23,6 +23,9 @@ import { catalogApiRef } from '../../api'; import { CatalogApi } from '@backstage/catalog-client'; describe('', () => { + const getTitle = (e: Entity): string => + (e.spec?.profile!! as JsonObject).displayName!!.toString()!!; + it('should fetch entities and render the custom display text', async () => { const entityRefs = [ { @@ -57,9 +60,6 @@ describe('', () => { }), }; - const getTitle = (e: Entity): string => - (e.spec?.profile!! as JsonObject).displayName!!.toString()!!; - const rendered = await renderInTestApp( @@ -81,4 +81,55 @@ describe('', () => { '/catalog/default/api/interface', ); }); + + it('should use entities as they are provided and render the custom display text', async () => { + const entityRefs = [ + { + kind: 'Component', + namespace: 'default', + name: 'tool', + }, + { + kind: 'API', + namespace: 'default', + name: 'implementation', + }, + ].map(ref => ({ + apiVersion: 'backstage.io/v1alpha1', + kind: ref.kind, + metadata: { + name: ref.name, + namespace: ref.namespace, + }, + spec: { + profile: { + displayName: ref.name.toLocaleUpperCase('en-US'), + }, + type: 'organization', + }, + })); + + const catalogApi: Partial = {}; + + const rendered = await renderInTestApp( + + + , + { + mountedRoutes: { + '/catalog/:namespace/:kind/:name/*': entityRouteRef, + }, + }, + ); + + expect(rendered.getByText('TOOL')).toHaveAttribute( + 'href', + '/catalog/default/component/tool', + ); + + expect(rendered.getByText('IMPLEMENTATION')).toHaveAttribute( + 'href', + '/catalog/default/api/implementation', + ); + }); }); From 359efe7db9fd5416d7cb6c745e309d2096877e46 Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Thu, 29 Sep 2022 15:32:26 +0200 Subject: [PATCH 19/35] Added a test case which covers the case when the array of entities was provided to entityRefs Signed-off-by: bnechyporenko --- .../FetchedEntityRefLinks.test.tsx | 83 +++++++++++++++++++ .../EntityRefLink/FetchedEntityRefLinks.tsx | 27 +++--- 2 files changed, 100 insertions(+), 10 deletions(-) diff --git a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.test.tsx b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.test.tsx index c416adcfbd..36e2c0450d 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.test.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.test.tsx @@ -132,4 +132,87 @@ describe('', () => { '/catalog/default/api/implementation', ); }); + + it('should handle heterogeneous array of values to render the custom display text', async () => { + const entityRefs = [ + ...[ + { + kind: 'Component', + namespace: 'default', + name: 'tool', + }, + { + kind: 'API', + namespace: 'default', + name: 'implementation', + }, + ].map(ref => ({ + apiVersion: 'backstage.io/v1alpha1', + kind: ref.kind, + metadata: { + name: ref.name, + namespace: ref.namespace, + }, + spec: { + profile: { + displayName: ref.name.toLocaleUpperCase('en-US'), + }, + type: 'organization', + }, + })), + { + kind: 'Component', + namespace: 'default', + name: 'interface', + }, + ]; + + const catalogApi: Partial = { + getEntities: () => + Promise.resolve({ + items: [ + { + apiVersion: 'backstage.io/v1alpha1', + kind: 'Component', + metadata: { + name: 'interface', + namespace: 'default', + }, + spec: { + profile: { + displayName: 'INTERFACE', + }, + type: 'organization', + }, + }, + ], + }), + }; + + const rendered = await renderInTestApp( + + + , + { + mountedRoutes: { + '/catalog/:namespace/:kind/:name/*': entityRouteRef, + }, + }, + ); + + expect(rendered.getByText('TOOL')).toHaveAttribute( + 'href', + '/catalog/default/component/tool', + ); + + expect(rendered.getByText('IMPLEMENTATION')).toHaveAttribute( + 'href', + '/catalog/default/api/implementation', + ); + + expect(rendered.getByText('INTERFACE')).toHaveAttribute( + 'href', + '/catalog/default/component/interface', + ); + }); }); diff --git a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx index 88b92b4689..ea4a32b511 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/FetchedEntityRefLinks.tsx @@ -60,17 +60,24 @@ export function FetchedEntityRefLinks< return 'metadata' in current ? acc : [...acc, parseEntityRef(current)]; }, new Array()); + const pureEntities = entityRefs.filter( + ref => 'metadata' in ref, + ) as Array; + return refs.length > 0 - ? ( - await catalogApi.getEntities({ - filter: refs.map(ref => ({ - kind: ref.kind, - 'metadata.namespace': ref.namespace, - 'metadata.name': ref.name, - })), - }) - ).items - : (entityRefs as Array); + ? [ + ...( + await catalogApi.getEntities({ + filter: refs.map(ref => ({ + kind: ref.kind, + 'metadata.namespace': ref.namespace, + 'metadata.name': ref.name, + })), + }) + ).items, + ...pureEntities, + ] + : pureEntities; }, [entityRefs]); if (loading) { From 12ba13cf6947f03dc6b878b0f98eeab9da3c57f7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Sep 2022 14:36:59 +0000 Subject: [PATCH 20/35] Update dependency luxon to v3.0.4 Signed-off-by: Renovate Bot --- yarn.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/yarn.lock b/yarn.lock index cfe337f337..868272680a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5600,7 +5600,7 @@ __metadata: "@types/node": "*" "@types/react": ^16.13.1 || ^17.0.0 cross-fetch: ^3.1.5 - luxon: ^2.4.0 + luxon: ^3.0.0 msw: ^0.47.0 octokit: ^2.0.4 react-use: ^17.4.0 @@ -13842,13 +13842,20 @@ __metadata: languageName: node linkType: hard -"@types/luxon@npm:*, @types/luxon@npm:^3.0.0": +"@types/luxon@npm:*": version: 3.0.0 resolution: "@types/luxon@npm:3.0.0" checksum: 7738d3f4b91097a8139eca966ab53c6b40bb417b2cc2014c3bbd0aee033d6ff54af14c62046c2eb042434923b6bf796874f24b2af90e07ef422e6d841463d4b2 languageName: node linkType: hard +"@types/luxon@npm:^3.0.0": + version: 3.0.1 + resolution: "@types/luxon@npm:3.0.1" + checksum: a81444f9b474ea9b3063ab4cc68b917a2634e38b4e229f86c78c35023a32bf5e8d1044d7c229c011291662c976cb6c4cf109dc3d2077c571790a31779a554178 + languageName: node + linkType: hard + "@types/markdown-it@npm:^12.2.3": version: 12.2.3 resolution: "@types/markdown-it@npm:12.2.3" @@ -28434,17 +28441,10 @@ __metadata: languageName: node linkType: hard -"luxon@npm:^2.4.0": - version: 2.5.0 - resolution: "luxon@npm:2.5.0" - checksum: 2fccce6bbdfc8f13c5a8c148ff045ab3b10f4f80cac28dd92575588fffce9b2d7197096d7fedcc61a6245b59f4233507797f530e63f22b9ae4c425dff2909ae3 - languageName: node - linkType: hard - "luxon@npm:^3.0.0": - version: 3.0.1 - resolution: "luxon@npm:3.0.1" - checksum: aa966eb919bf95b1bd819cda784d1f6f66e3fb65bd9ec7bf68b6a978eeb4e3e14f7e2275021b473f93b15b6b7ba2e5a30471e53add3929a7e695fcfd6dd40ec8 + version: 3.0.4 + resolution: "luxon@npm:3.0.4" + checksum: d0908c3951da2a10ccf23040210ead23b0da5366a9d0954e7d5db3560189a7bd703d8af1e00084f197effc9cd7158d1bddf32886d98a70d59ce9bc3fe88bbce0 languageName: node linkType: hard From 8c7bff2bb4311193219aec8aa2219fe0733f6fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Thu, 29 Sep 2022 16:52:40 +0200 Subject: [PATCH 21/35] fixup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/odd-pandas-suffer.md | 5 +++++ plugins/github-issues/package.json | 2 +- yarn.lock | 9 +-------- 3 files changed, 7 insertions(+), 9 deletions(-) create mode 100644 .changeset/odd-pandas-suffer.md diff --git a/.changeset/odd-pandas-suffer.md b/.changeset/odd-pandas-suffer.md new file mode 100644 index 0000000000..ce562a9a89 --- /dev/null +++ b/.changeset/odd-pandas-suffer.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-github-issues': patch +--- + +Updated the `luxon` dependency to 3.x diff --git a/plugins/github-issues/package.json b/plugins/github-issues/package.json index 52e4672380..6690b517f8 100644 --- a/plugins/github-issues/package.json +++ b/plugins/github-issues/package.json @@ -32,7 +32,7 @@ "@material-ui/core": "^4.12.4", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "^4.0.0-alpha.61", - "luxon": "^2.4.0", + "luxon": "^3.0.0", "octokit": "^2.0.4", "react-use": "^17.4.0" }, diff --git a/yarn.lock b/yarn.lock index 868272680a..e5104413f4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13842,14 +13842,7 @@ __metadata: languageName: node linkType: hard -"@types/luxon@npm:*": - version: 3.0.0 - resolution: "@types/luxon@npm:3.0.0" - checksum: 7738d3f4b91097a8139eca966ab53c6b40bb417b2cc2014c3bbd0aee033d6ff54af14c62046c2eb042434923b6bf796874f24b2af90e07ef422e6d841463d4b2 - languageName: node - linkType: hard - -"@types/luxon@npm:^3.0.0": +"@types/luxon@npm:*, @types/luxon@npm:^3.0.0": version: 3.0.1 resolution: "@types/luxon@npm:3.0.1" checksum: a81444f9b474ea9b3063ab4cc68b917a2634e38b4e229f86c78c35023a32bf5e8d1044d7c229c011291662c976cb6c4cf109dc3d2077c571790a31779a554178 From f6783ecf8200dfaf83b90a9e6a799c842130d690 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Sep 2022 14:54:15 +0000 Subject: [PATCH 22/35] Update dependency openid-client to v5.1.10 Signed-off-by: Renovate Bot --- yarn.lock | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 962913d2ec..233bc8c089 100644 --- a/yarn.lock +++ b/yarn.lock @@ -30825,7 +30825,19 @@ __metadata: languageName: node linkType: hard -"openid-client@npm:^5.1.3, openid-client@npm:^5.1.6": +"openid-client@npm:^5.1.3": + version: 5.1.10 + resolution: "openid-client@npm:5.1.10" + dependencies: + jose: ^4.1.4 + lru-cache: ^6.0.0 + object-hash: ^2.0.1 + oidc-token-hash: ^5.0.1 + checksum: 38a4bf08ea4ee4576043968307cf53f0369df224bd025c1bc348b295152df36c47d2a836dfe1505d15c6b79c05f86aadefad798bd3ea3ccbe90834be01f2245c + languageName: node + linkType: hard + +"openid-client@npm:^5.1.6": version: 5.1.9 resolution: "openid-client@npm:5.1.9" dependencies: From 54ed0d1e7b21ad2881e0422cb5b47bdbfb8077ff Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Sep 2022 15:11:08 +0000 Subject: [PATCH 23/35] Update dependency swagger-ui-react to v4.14.1 Signed-off-by: Renovate Bot --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6e01230bbc..801b3b1331 100644 --- a/yarn.lock +++ b/yarn.lock @@ -36949,8 +36949,8 @@ __metadata: linkType: hard "swagger-ui-react@npm:^4.11.1": - version: 4.14.0 - resolution: "swagger-ui-react@npm:4.14.0" + version: 4.14.1 + resolution: "swagger-ui-react@npm:4.14.1" dependencies: "@babel/runtime-corejs3": ^7.18.9 "@braintree/sanitize-url": =6.0.0 @@ -36988,7 +36988,7 @@ __metadata: peerDependencies: react: ">=17.0.0" react-dom: ">=17.0.0" - checksum: dbd6ce54bd8d2665aa8cd8b983c7cfd4407a710a6fc662ef61e611d54383abc082f15e55730f70ae214481d8e0c0ddeba100091747315edd5d455657c9fdf346 + checksum: 256c38e8c1a0540784eff38d712e97ad4c43558b6c22fb3c8d6bf2f2adb6bf340c527aa16c2a8f8ff64c14483de37d2922d802244e5b6f59bb9a32f097505b21 languageName: node linkType: hard From ae2bf82ca7a35df08cc2bde8e7c7479a558b0869 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Sep 2022 15:12:34 +0000 Subject: [PATCH 24/35] Update dependency typescript to v4.8.4 Signed-off-by: Renovate Bot --- cypress/yarn.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cypress/yarn.lock b/cypress/yarn.lock index dd9856750c..d55c96a984 100644 --- a/cypress/yarn.lock +++ b/cypress/yarn.lock @@ -1415,22 +1415,22 @@ __metadata: linkType: hard "typescript@npm:^4.1.3": - version: 4.8.2 - resolution: "typescript@npm:4.8.2" + version: 4.8.4 + resolution: "typescript@npm:4.8.4" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 7f5b81d0d558c9067f952c7af52ab7f19c2e70a916817929e4a5b256c93990bf3178eccb1ac8a850bc75df35f6781b6f4cb3370ce20d8b1ded92ed462348f628 + checksum: 3e4f061658e0c8f36c820802fa809e0fd812b85687a9a2f5430bc3d0368e37d1c9605c3ce9b39df9a05af2ece67b1d844f9f6ea8ff42819f13bcb80f85629af0 languageName: node linkType: hard "typescript@patch:typescript@^4.1.3#~builtin": - version: 4.8.2 - resolution: "typescript@patch:typescript@npm%3A4.8.2#~builtin::version=4.8.2&hash=a1c5e5" + version: 4.8.4 + resolution: "typescript@patch:typescript@npm%3A4.8.4#~builtin::version=4.8.4&hash=a1c5e5" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 5cb0f02f414f5405f4b0e7ee1fd7fa9177b6a8783c9017b6cad85f56ce4c4f93e0e6f2ce37e863cb597d44227cd009474c9fbd85bf7a50004e5557426cb58079 + checksum: 563a0ef47abae6df27a9a3ab38f75fc681f633ccf1a3502b1108e252e187787893de689220f4544aaf95a371a4eb3141e4a337deb9895de5ac3c1ca76430e5f0 languageName: node linkType: hard From 18af9c7971d883f7563aadf9c79d32d623e73db0 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Thu, 29 Sep 2022 17:53:41 +0200 Subject: [PATCH 25/35] Use latest mkdocs and mkdocs-techdocs-core in e2e tests Signed-off-by: Eric Peterson --- .github/workflows/verify_e2e-techdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify_e2e-techdocs.yml b/.github/workflows/verify_e2e-techdocs.yml index 4ed406f52e..e1bb2246dc 100644 --- a/.github/workflows/verify_e2e-techdocs.yml +++ b/.github/workflows/verify_e2e-techdocs.yml @@ -39,7 +39,7 @@ jobs: run: yarn build - name: Install mkdocs & techdocs-core - run: python -m pip install mkdocs-techdocs-core==1.1.6 mkdocs==1.3.1 + run: python -m pip install mkdocs-techdocs-core==1.1.7 mkdocs==1.4.0 - name: techdocs-cli e2e test working-directory: packages/techdocs-cli From 6cd7b96e0b88c77d094aeee3ac99fbe47438ff71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Thu, 29 Sep 2022 18:30:30 +0200 Subject: [PATCH 26/35] fixup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- yarn.lock | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/yarn.lock b/yarn.lock index c4bdcc4714..35789bbcf8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3872,7 +3872,7 @@ __metadata: "@backstage/backend-common": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" - "@types/express": ^4.17.6 + "@types/express": "*" "@types/http-proxy-middleware": ^0.19.3 "@types/supertest": ^2.0.8 express: ^4.17.1 @@ -4184,7 +4184,7 @@ __metadata: "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" "@backstage/errors": "workspace:^" - "@types/express": ^4.17.6 + "@types/express": "*" express: ^4.17.1 jose: ^4.6.0 lodash: ^4.17.21 @@ -6212,7 +6212,7 @@ __metadata: "@backstage/backend-common": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" - "@types/express": ^4.17.6 + "@types/express": "*" "@types/supertest": ^2.0.8 express: ^4.17.1 express-promise-router: ^4.1.0 @@ -6267,7 +6267,7 @@ __metadata: "@backstage/plugin-auth-node": "workspace:^" "@backstage/plugin-permission-common": "workspace:^" "@backstage/plugin-permission-node": "workspace:^" - "@types/express": ^4.17.6 + "@types/express": "*" "@types/lodash": ^4.14.151 "@types/supertest": ^2.0.8 dataloader: ^2.0.0 @@ -6385,7 +6385,7 @@ __metadata: "@backstage/plugin-permission-common": "workspace:^" "@backstage/plugin-permission-node": "workspace:^" "@backstage/plugin-playlist-common": "workspace:^" - "@types/express": ^4.17.6 + "@types/express": "*" "@types/supertest": ^2.0.8 express: ^4.17.1 express-promise-router: ^4.1.0 @@ -6985,7 +6985,7 @@ __metadata: "@backstage/config": "workspace:^" "@backstage/errors": "workspace:^" "@backstage/test-utils": "workspace:^" - "@types/express": ^4.17.6 + "@types/express": "*" "@types/supertest": ^2.0.12 express: ^4.18.1 express-promise-router: ^4.1.0 @@ -7604,7 +7604,7 @@ __metadata: "@backstage/config": "workspace:^" "@backstage/errors": "workspace:^" "@types/compression": ^1.7.2 - "@types/express": ^4.17.6 + "@types/express": "*" "@types/supertest": ^2.0.8 compression: ^1.7.4 cors: ^2.8.5 @@ -13463,19 +13463,7 @@ __metadata: languageName: node linkType: hard -"@types/express@npm:*, @types/express@npm:4.17.13, @types/express@npm:^4.17.13": - version: 4.17.13 - resolution: "@types/express@npm:4.17.13" - dependencies: - "@types/body-parser": "*" - "@types/express-serve-static-core": ^4.17.18 - "@types/qs": "*" - "@types/serve-static": "*" - checksum: 12a2a0e6c4b993fc0854bec665906788aea0d8ee4392389d7a98a5de1eefdd33c9e1e40a91f3afd274011119c506f7b4126acb97fae62ae20b654974d44cba12 - languageName: node - linkType: hard - -"@types/express@npm:^4.17.6": +"@types/express@npm:*, @types/express@npm:4.17.13, @types/express@npm:^4.17.13, @types/express@npm:^4.17.6": version: 4.17.14 resolution: "@types/express@npm:4.17.14" dependencies: From 8220f2fd832bbc421a28473fcf58da25d0234820 Mon Sep 17 00:00:00 2001 From: Phil Kuang Date: Thu, 29 Sep 2022 12:53:48 -0400 Subject: [PATCH 27/35] fix(dryRunEditor): render custom layouts Signed-off-by: Phil Kuang --- .changeset/dry-shirts-attack.md | 5 +++++ .../src/components/TemplateEditorPage/TemplateEditorForm.tsx | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/dry-shirts-attack.md diff --git a/.changeset/dry-shirts-attack.md b/.changeset/dry-shirts-attack.md new file mode 100644 index 0000000000..ba6c7379f5 --- /dev/null +++ b/.changeset/dry-shirts-attack.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder': patch +--- + +Support custom layouts in dry run editor diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditorForm.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditorForm.tsx index 3e5de0e02d..192a9696cf 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditorForm.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditorForm.tsx @@ -207,7 +207,7 @@ export function TemplateEditorFormDirectoryEditorDryRun( 'setErrorText' | 'fieldExtensions' | 'layouts' >, ) { - const { setErrorText, fieldExtensions = [] } = props; + const { setErrorText, fieldExtensions = [], layouts } = props; const dryRun = useDryRun(); const directoryEditor = useDirectoryEditor(); @@ -246,6 +246,7 @@ export function TemplateEditorFormDirectoryEditorDryRun( content={content} data={data} onUpdate={setData} + layouts={layouts} /> ); } From 88ce53d9eef255934a0db76e9011572093f5186d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Sep 2022 17:15:09 +0000 Subject: [PATCH 28/35] Update dependency @google-cloud/firestore to v6.3.0 Signed-off-by: Renovate Bot --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index a4d6c9425c..644805c7f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8411,14 +8411,14 @@ __metadata: linkType: hard "@google-cloud/firestore@npm:^6.0.0": - version: 6.2.0 - resolution: "@google-cloud/firestore@npm:6.2.0" + version: 6.3.0 + resolution: "@google-cloud/firestore@npm:6.3.0" dependencies: fast-deep-equal: ^3.1.1 functional-red-black-tree: ^1.0.1 google-gax: ^3.5.1 protobufjs: ^7.0.0 - checksum: fce0d729d63b5722df0dcedb78c8b494b2876de128128de8c8dc7d9add1ff7e00a8df1d04e7e2210a71331e623877e67149593341f714d2b0f92b6fef73dfcbd + checksum: 50f52dc06746fe3af1e9abb1063244015f968b71387104f65bd752ce6522406fe987291791c40fd40e84a11033c993e7847e5b8619173b7202c70382e55e853b languageName: node linkType: hard From d18c9079f201c1b8509a8647f6dd0fc39036c6ad Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Sep 2022 17:16:05 +0000 Subject: [PATCH 29/35] Update dependency @graphql-codegen/cli to v2.13.1 Signed-off-by: Renovate Bot --- yarn.lock | 71 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/yarn.lock b/yarn.lock index a4d6c9425c..b6c9fd1246 100644 --- a/yarn.lock +++ b/yarn.lock @@ -705,6 +705,17 @@ __metadata: languageName: node linkType: hard +"@babel/generator@npm:^7.18.13": + version: 7.19.3 + resolution: "@babel/generator@npm:7.19.3" + dependencies: + "@babel/types": ^7.19.3 + "@jridgewell/gen-mapping": ^0.3.2 + jsesc: ^2.5.1 + checksum: b1585e398f6c37f442a2fdac964a326b348fbc8fb99a6aaf4f72bbe993adb0ca792bc0a9c65e59930b2a2e55eb5aa3aab360ceb678d3d40692eb0cda2b7b6aa6 + languageName: node + linkType: hard + "@babel/generator@npm:^7.18.9": version: 7.18.9 resolution: "@babel/generator@npm:7.18.9" @@ -1219,6 +1230,13 @@ __metadata: languageName: node linkType: hard +"@babel/helper-validator-identifier@npm:^7.19.1": + version: 7.19.1 + resolution: "@babel/helper-validator-identifier@npm:7.19.1" + checksum: 0eca5e86a729162af569b46c6c41a63e18b43dbe09fda1d2a3c8924f7d617116af39cac5e4cd5d431bb760b4dca3c0970e0c444789b1db42bcf1fa41fbad0a3a + languageName: node + linkType: hard + "@babel/helper-validator-option@npm:^7.16.7": version: 7.16.7 resolution: "@babel/helper-validator-option@npm:7.16.7" @@ -2936,6 +2954,17 @@ __metadata: languageName: node linkType: hard +"@babel/types@npm:^7.18.13, @babel/types@npm:^7.19.3": + version: 7.19.3 + resolution: "@babel/types@npm:7.19.3" + dependencies: + "@babel/helper-string-parser": ^7.18.10 + "@babel/helper-validator-identifier": ^7.19.1 + to-fast-properties: ^2.0.0 + checksum: 34a5b3db3b99a1a80ec2a784c2bb0e48769a38f1526dc377a5753a3ac5e5704663c405a393117ecc7a9df9da07b01625be7c4c3fee43ae46aba23b0c40928d77 + languageName: node + linkType: hard + "@babel/types@npm:^7.18.4, @babel/types@npm:^7.18.6, @babel/types@npm:^7.18.9": version: 7.18.9 resolution: "@babel/types@npm:7.18.9" @@ -8506,11 +8535,14 @@ __metadata: linkType: hard "@graphql-codegen/cli@npm:^2.3.1": - version: 2.12.2 - resolution: "@graphql-codegen/cli@npm:2.12.2" + version: 2.13.1 + resolution: "@graphql-codegen/cli@npm:2.13.1" dependencies: + "@babel/generator": ^7.18.13 + "@babel/template": ^7.18.10 + "@babel/types": ^7.18.13 "@graphql-codegen/core": 2.6.2 - "@graphql-codegen/plugin-helpers": ^2.7.1 + "@graphql-codegen/plugin-helpers": ^2.6.2 "@graphql-tools/apollo-engine-loader": ^7.3.6 "@graphql-tools/code-file-loader": ^7.3.1 "@graphql-tools/git-loader": ^7.2.1 @@ -8521,12 +8553,12 @@ __metadata: "@graphql-tools/prisma-loader": ^7.2.7 "@graphql-tools/url-loader": ^7.13.2 "@graphql-tools/utils": ^8.9.0 - "@whatwg-node/fetch": ^0.4.0 + "@whatwg-node/fetch": ^0.3.0 ansi-escapes: ^4.3.1 chalk: ^4.1.0 chokidar: ^3.5.2 cosmiconfig: ^7.0.0 - cosmiconfig-typescript-loader: ^4.0.0 + cosmiconfig-typescript-loader: 4.0.0 debounce: ^1.2.0 detect-indent: ^6.0.0 graphql-config: ^4.3.5 @@ -8548,7 +8580,7 @@ __metadata: graphql-code-generator: cjs/bin.js graphql-codegen: cjs/bin.js graphql-codegen-esm: esm/bin.js - checksum: 38262533b4bfcdacab25a3ce874082895ca3da164313466c531ac012d868f748c2f764f50dd4e98f03d3d5a5253c397488dde7c164b59677659eb8838459e518 + checksum: 750c2a5f598def903842b8b91bbc4a4493703c1f0a2a2300af88b35cffce21128ccb4896e10a789dcdc9ed8076b89144a463da4772ccecf72d44645fc0ab67fe languageName: node linkType: hard @@ -8598,22 +8630,6 @@ __metadata: languageName: node linkType: hard -"@graphql-codegen/plugin-helpers@npm:^2.7.1": - version: 2.7.1 - resolution: "@graphql-codegen/plugin-helpers@npm:2.7.1" - dependencies: - "@graphql-tools/utils": ^8.8.0 - change-case-all: 1.0.14 - common-tags: 1.8.2 - import-from: 4.0.0 - lodash: ~4.17.0 - tslib: ~2.4.0 - peerDependencies: - graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 - checksum: fffb801ccccee36d729c134caa79cc5eb6a1b3717253646cd1759e2dd0e754bccb6b0b6b5341a649fd18794f8b0b970776b71907d5a7b15048521ea9eb283180 - languageName: node - linkType: hard - "@graphql-codegen/schema-ast@npm:^2.5.1": version: 2.5.1 resolution: "@graphql-codegen/schema-ast@npm:2.5.1" @@ -15270,19 +15286,20 @@ __metadata: languageName: node linkType: hard -"@whatwg-node/fetch@npm:^0.4.0": - version: 0.4.4 - resolution: "@whatwg-node/fetch@npm:0.4.4" +"@whatwg-node/fetch@npm:^0.3.0": + version: 0.3.2 + resolution: "@whatwg-node/fetch@npm:0.3.2" dependencies: "@peculiar/webcrypto": ^1.4.0 abort-controller: ^3.0.0 busboy: ^1.6.0 + event-target-polyfill: ^0.0.3 form-data-encoder: ^1.7.1 formdata-node: ^4.3.1 node-fetch: ^2.6.7 undici: ^5.8.0 web-streams-polyfill: ^3.2.0 - checksum: f91ebad3c07f1244dec0c57b1bdc4d70e8e2b0eccd237407f649439eb091e1e8a23dfb8e13159468c727537c5ebf6f66f20f5659ca682495cd1a0752de2c2fad + checksum: d9cb1b1293694edf0d61889512e5b5a0b8b69db2cf8c4cca4acdbbe652f899742456d10954312ef96a8f7257a898d6275b50df03cc481e5a97740cb301930892 languageName: node linkType: hard @@ -18788,7 +18805,7 @@ __metadata: languageName: node linkType: hard -"cosmiconfig-typescript-loader@npm:^4.0.0": +"cosmiconfig-typescript-loader@npm:4.0.0, cosmiconfig-typescript-loader@npm:^4.0.0": version: 4.0.0 resolution: "cosmiconfig-typescript-loader@npm:4.0.0" peerDependencies: From 705585930a16dbbb2d823f6e939d176ff80667b8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Sep 2022 18:17:17 +0000 Subject: [PATCH 30/35] Update dependency swagger-ui-react to v4.14.2 Signed-off-by: Renovate Bot --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4ba8e92e93..35c393d9a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -36979,8 +36979,8 @@ __metadata: linkType: hard "swagger-ui-react@npm:^4.11.1": - version: 4.14.1 - resolution: "swagger-ui-react@npm:4.14.1" + version: 4.14.2 + resolution: "swagger-ui-react@npm:4.14.2" dependencies: "@babel/runtime-corejs3": ^7.18.9 "@braintree/sanitize-url": =6.0.0 @@ -37018,7 +37018,7 @@ __metadata: peerDependencies: react: ">=17.0.0" react-dom: ">=17.0.0" - checksum: 256c38e8c1a0540784eff38d712e97ad4c43558b6c22fb3c8d6bf2f2adb6bf340c527aa16c2a8f8ff64c14483de37d2922d802244e5b6f59bb9a32f097505b21 + checksum: ee8d19bdfd32032926d86a1c547b5fd423f658e0e4c29bd2b96808143f7ef5c1e094fb6c2a0a6e3f20b8a5d7e0a7732f81a31fc10f8e6e6702b8b1333a40164c languageName: node linkType: hard From 09b073dd4b0d5b95535f236e4c93105d10725181 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Sep 2022 21:41:53 +0000 Subject: [PATCH 31/35] Update dependency @microsoft/microsoft-graph-types to v2.25.0 Signed-off-by: Renovate Bot --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4ba8e92e93..58af5d51b5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10763,9 +10763,9 @@ __metadata: linkType: hard "@microsoft/microsoft-graph-types@npm:^2.6.0": - version: 2.24.0 - resolution: "@microsoft/microsoft-graph-types@npm:2.24.0" - checksum: 94dfcf83905d4e416b8ddc52a338d583cbdc15bdc4bad0aff2212a0692d81870c55f9a01165dd3878442d2de512de57f02c575ebb77f1d393ac87449fb8e5c51 + version: 2.25.0 + resolution: "@microsoft/microsoft-graph-types@npm:2.25.0" + checksum: b311385e0a51f827082af5a016f35b1d6cd4d861121e8767b3279ab1a17475977cddbbdcc208abdddf0f953fd6ce4634d3c302e317cf50af4cb6111385347b4f languageName: node linkType: hard From 856b2ec4ba46adeeeba998f9624e9bcea32ffeee Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Sep 2022 22:35:12 +0000 Subject: [PATCH 32/35] Update dependency @tanstack/react-query to v4.7.2 Signed-off-by: Renovate Bot --- yarn.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index 58af5d51b5..e182cf6b3f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12684,18 +12684,18 @@ __metadata: languageName: node linkType: hard -"@tanstack/query-core@npm:4.3.8": - version: 4.3.8 - resolution: "@tanstack/query-core@npm:4.3.8" - checksum: 25ea16db7632f5acc7c80e60b9f1410cf9df430240ec5077a1607c3ffea14db2c78db800f7bc70efafd7ce26f7216cda767824fa279049cc9c7e40ac1818f38e +"@tanstack/query-core@npm:4.7.2": + version: 4.7.2 + resolution: "@tanstack/query-core@npm:4.7.2" + checksum: 5be625bf27505acded2c5add69c54a48be8c6cacdf4ea821ef499ca449a3a5694bda995bdc2439a83039563f91cb3424b765c597fd28861c6a867efda039e6d1 languageName: node linkType: hard "@tanstack/react-query@npm:^4.1.3": - version: 4.3.9 - resolution: "@tanstack/react-query@npm:4.3.9" + version: 4.7.2 + resolution: "@tanstack/react-query@npm:4.7.2" dependencies: - "@tanstack/query-core": 4.3.8 + "@tanstack/query-core": 4.7.2 use-sync-external-store: ^1.2.0 peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -12706,7 +12706,7 @@ __metadata: optional: true react-native: optional: true - checksum: 1f77aadda55722519458185b4db5378d05d95bcbe9f7c4fda0ef82121a975223ede1a56729db6030984b336e533c04b1c7aa8fed344e5c52ec73a0486b65f8e7 + checksum: 07f6ec6c44c6826986167d772d78051414f15f08c874fe38187e1175a527ec71f77025d1466651802b8cde991618acece668fc17d7dc62af837ad7fb02882fa3 languageName: node linkType: hard From 05f798dd3caeb6545cd249bb958c0df402b68eb2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 30 Sep 2022 09:37:28 +0000 Subject: [PATCH 33/35] Update dependency @swc/core to v1.3.4 Signed-off-by: Renovate Bot --- storybook/yarn.lock | 110 ++++++++++++++++++++++---------------------- yarn.lock | 110 ++++++++++++++++++++++---------------------- 2 files changed, 110 insertions(+), 110 deletions(-) diff --git a/storybook/yarn.lock b/storybook/yarn.lock index 1597d0728c..db03614312 100644 --- a/storybook/yarn.lock +++ b/storybook/yarn.lock @@ -2977,126 +2977,126 @@ __metadata: languageName: node linkType: hard -"@swc/core-android-arm-eabi@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-android-arm-eabi@npm:1.3.3" +"@swc/core-android-arm-eabi@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-android-arm-eabi@npm:1.3.4" dependencies: "@swc/wasm": 1.2.122 conditions: os=android & cpu=arm languageName: node linkType: hard -"@swc/core-android-arm64@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-android-arm64@npm:1.3.3" +"@swc/core-android-arm64@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-android-arm64@npm:1.3.4" dependencies: "@swc/wasm": 1.2.130 conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@swc/core-darwin-arm64@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-darwin-arm64@npm:1.3.3" +"@swc/core-darwin-arm64@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-darwin-arm64@npm:1.3.4" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@swc/core-darwin-x64@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-darwin-x64@npm:1.3.3" +"@swc/core-darwin-x64@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-darwin-x64@npm:1.3.4" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@swc/core-freebsd-x64@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-freebsd-x64@npm:1.3.3" +"@swc/core-freebsd-x64@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-freebsd-x64@npm:1.3.4" dependencies: "@swc/wasm": 1.2.130 conditions: os=freebsd & cpu=x64 languageName: node linkType: hard -"@swc/core-linux-arm-gnueabihf@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-linux-arm-gnueabihf@npm:1.3.3" +"@swc/core-linux-arm-gnueabihf@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-linux-arm-gnueabihf@npm:1.3.4" dependencies: "@swc/wasm": 1.2.130 conditions: os=linux & cpu=arm languageName: node linkType: hard -"@swc/core-linux-arm64-gnu@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-linux-arm64-gnu@npm:1.3.3" +"@swc/core-linux-arm64-gnu@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-linux-arm64-gnu@npm:1.3.4" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@swc/core-linux-arm64-musl@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-linux-arm64-musl@npm:1.3.3" +"@swc/core-linux-arm64-musl@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-linux-arm64-musl@npm:1.3.4" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@swc/core-linux-x64-gnu@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-linux-x64-gnu@npm:1.3.3" +"@swc/core-linux-x64-gnu@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-linux-x64-gnu@npm:1.3.4" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@swc/core-linux-x64-musl@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-linux-x64-musl@npm:1.3.3" +"@swc/core-linux-x64-musl@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-linux-x64-musl@npm:1.3.4" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@swc/core-win32-arm64-msvc@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-win32-arm64-msvc@npm:1.3.3" +"@swc/core-win32-arm64-msvc@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-win32-arm64-msvc@npm:1.3.4" dependencies: "@swc/wasm": 1.2.130 conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@swc/core-win32-ia32-msvc@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-win32-ia32-msvc@npm:1.3.3" +"@swc/core-win32-ia32-msvc@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-win32-ia32-msvc@npm:1.3.4" dependencies: "@swc/wasm": 1.2.130 conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@swc/core-win32-x64-msvc@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-win32-x64-msvc@npm:1.3.3" +"@swc/core-win32-x64-msvc@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-win32-x64-msvc@npm:1.3.4" conditions: os=win32 & cpu=x64 languageName: node linkType: hard "@swc/core@npm:^1.2.239": - version: 1.3.3 - resolution: "@swc/core@npm:1.3.3" + version: 1.3.4 + resolution: "@swc/core@npm:1.3.4" dependencies: - "@swc/core-android-arm-eabi": 1.3.3 - "@swc/core-android-arm64": 1.3.3 - "@swc/core-darwin-arm64": 1.3.3 - "@swc/core-darwin-x64": 1.3.3 - "@swc/core-freebsd-x64": 1.3.3 - "@swc/core-linux-arm-gnueabihf": 1.3.3 - "@swc/core-linux-arm64-gnu": 1.3.3 - "@swc/core-linux-arm64-musl": 1.3.3 - "@swc/core-linux-x64-gnu": 1.3.3 - "@swc/core-linux-x64-musl": 1.3.3 - "@swc/core-win32-arm64-msvc": 1.3.3 - "@swc/core-win32-ia32-msvc": 1.3.3 - "@swc/core-win32-x64-msvc": 1.3.3 + "@swc/core-android-arm-eabi": 1.3.4 + "@swc/core-android-arm64": 1.3.4 + "@swc/core-darwin-arm64": 1.3.4 + "@swc/core-darwin-x64": 1.3.4 + "@swc/core-freebsd-x64": 1.3.4 + "@swc/core-linux-arm-gnueabihf": 1.3.4 + "@swc/core-linux-arm64-gnu": 1.3.4 + "@swc/core-linux-arm64-musl": 1.3.4 + "@swc/core-linux-x64-gnu": 1.3.4 + "@swc/core-linux-x64-musl": 1.3.4 + "@swc/core-win32-arm64-msvc": 1.3.4 + "@swc/core-win32-ia32-msvc": 1.3.4 + "@swc/core-win32-x64-msvc": 1.3.4 dependenciesMeta: "@swc/core-android-arm-eabi": optional: true @@ -3126,7 +3126,7 @@ __metadata: optional: true bin: swcx: run_swcx.js - checksum: bead8463cd7c11e2cd87d3835045e4a245e755409e912a40c575026a0475cc0010fa6ef48936ea5f7e62c84cdc63c21a83d61755813f2ba9b565d397fad7c5f5 + checksum: 24b4ca4a096fea53056ed227a8aa09aa38cfe5eef344451397e66a2d183ded119872cf4fc8c671c0a6eb34985537cbf8d8a7e742b9e27dad0735426693d11dc8 languageName: node linkType: hard diff --git a/yarn.lock b/yarn.lock index f78c668e59..1258cbaf4c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12487,126 +12487,126 @@ __metadata: languageName: node linkType: hard -"@swc/core-android-arm-eabi@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-android-arm-eabi@npm:1.3.3" +"@swc/core-android-arm-eabi@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-android-arm-eabi@npm:1.3.4" dependencies: "@swc/wasm": 1.2.122 conditions: os=android & cpu=arm languageName: node linkType: hard -"@swc/core-android-arm64@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-android-arm64@npm:1.3.3" +"@swc/core-android-arm64@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-android-arm64@npm:1.3.4" dependencies: "@swc/wasm": 1.2.130 conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@swc/core-darwin-arm64@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-darwin-arm64@npm:1.3.3" +"@swc/core-darwin-arm64@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-darwin-arm64@npm:1.3.4" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@swc/core-darwin-x64@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-darwin-x64@npm:1.3.3" +"@swc/core-darwin-x64@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-darwin-x64@npm:1.3.4" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@swc/core-freebsd-x64@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-freebsd-x64@npm:1.3.3" +"@swc/core-freebsd-x64@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-freebsd-x64@npm:1.3.4" dependencies: "@swc/wasm": 1.2.130 conditions: os=freebsd & cpu=x64 languageName: node linkType: hard -"@swc/core-linux-arm-gnueabihf@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-linux-arm-gnueabihf@npm:1.3.3" +"@swc/core-linux-arm-gnueabihf@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-linux-arm-gnueabihf@npm:1.3.4" dependencies: "@swc/wasm": 1.2.130 conditions: os=linux & cpu=arm languageName: node linkType: hard -"@swc/core-linux-arm64-gnu@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-linux-arm64-gnu@npm:1.3.3" +"@swc/core-linux-arm64-gnu@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-linux-arm64-gnu@npm:1.3.4" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@swc/core-linux-arm64-musl@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-linux-arm64-musl@npm:1.3.3" +"@swc/core-linux-arm64-musl@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-linux-arm64-musl@npm:1.3.4" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@swc/core-linux-x64-gnu@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-linux-x64-gnu@npm:1.3.3" +"@swc/core-linux-x64-gnu@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-linux-x64-gnu@npm:1.3.4" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@swc/core-linux-x64-musl@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-linux-x64-musl@npm:1.3.3" +"@swc/core-linux-x64-musl@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-linux-x64-musl@npm:1.3.4" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@swc/core-win32-arm64-msvc@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-win32-arm64-msvc@npm:1.3.3" +"@swc/core-win32-arm64-msvc@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-win32-arm64-msvc@npm:1.3.4" dependencies: "@swc/wasm": 1.2.130 conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@swc/core-win32-ia32-msvc@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-win32-ia32-msvc@npm:1.3.3" +"@swc/core-win32-ia32-msvc@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-win32-ia32-msvc@npm:1.3.4" dependencies: "@swc/wasm": 1.2.130 conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@swc/core-win32-x64-msvc@npm:1.3.3": - version: 1.3.3 - resolution: "@swc/core-win32-x64-msvc@npm:1.3.3" +"@swc/core-win32-x64-msvc@npm:1.3.4": + version: 1.3.4 + resolution: "@swc/core-win32-x64-msvc@npm:1.3.4" conditions: os=win32 & cpu=x64 languageName: node linkType: hard "@swc/core@npm:^1.2.239": - version: 1.3.3 - resolution: "@swc/core@npm:1.3.3" + version: 1.3.4 + resolution: "@swc/core@npm:1.3.4" dependencies: - "@swc/core-android-arm-eabi": 1.3.3 - "@swc/core-android-arm64": 1.3.3 - "@swc/core-darwin-arm64": 1.3.3 - "@swc/core-darwin-x64": 1.3.3 - "@swc/core-freebsd-x64": 1.3.3 - "@swc/core-linux-arm-gnueabihf": 1.3.3 - "@swc/core-linux-arm64-gnu": 1.3.3 - "@swc/core-linux-arm64-musl": 1.3.3 - "@swc/core-linux-x64-gnu": 1.3.3 - "@swc/core-linux-x64-musl": 1.3.3 - "@swc/core-win32-arm64-msvc": 1.3.3 - "@swc/core-win32-ia32-msvc": 1.3.3 - "@swc/core-win32-x64-msvc": 1.3.3 + "@swc/core-android-arm-eabi": 1.3.4 + "@swc/core-android-arm64": 1.3.4 + "@swc/core-darwin-arm64": 1.3.4 + "@swc/core-darwin-x64": 1.3.4 + "@swc/core-freebsd-x64": 1.3.4 + "@swc/core-linux-arm-gnueabihf": 1.3.4 + "@swc/core-linux-arm64-gnu": 1.3.4 + "@swc/core-linux-arm64-musl": 1.3.4 + "@swc/core-linux-x64-gnu": 1.3.4 + "@swc/core-linux-x64-musl": 1.3.4 + "@swc/core-win32-arm64-msvc": 1.3.4 + "@swc/core-win32-ia32-msvc": 1.3.4 + "@swc/core-win32-x64-msvc": 1.3.4 dependenciesMeta: "@swc/core-android-arm-eabi": optional: true @@ -12636,7 +12636,7 @@ __metadata: optional: true bin: swcx: run_swcx.js - checksum: bead8463cd7c11e2cd87d3835045e4a245e755409e912a40c575026a0475cc0010fa6ef48936ea5f7e62c84cdc63c21a83d61755813f2ba9b565d397fad7c5f5 + checksum: 24b4ca4a096fea53056ed227a8aa09aa38cfe5eef344451397e66a2d183ded119872cf4fc8c671c0a6eb34985537cbf8d8a7e742b9e27dad0735426693d11dc8 languageName: node linkType: hard From d25e33ca17549f835b2e3c469ab59c1cb1d28a5a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 30 Sep 2022 12:26:53 +0000 Subject: [PATCH 34/35] Update dependency @types/dockerode to v3.3.10 Signed-off-by: Renovate Bot --- yarn.lock | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 1258cbaf4c..e5f10c942a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13363,7 +13363,17 @@ __metadata: languageName: node linkType: hard -"@types/dockerode@npm:^3.3.0, @types/dockerode@npm:^3.3.8": +"@types/dockerode@npm:^3.3.0": + version: 3.3.10 + resolution: "@types/dockerode@npm:3.3.10" + dependencies: + "@types/docker-modem": "*" + "@types/node": "*" + checksum: ef2231adebbdc1876a00fd16a51963ed2ea05a2305031467420c753f77a27a6f2a47617e2f4a42702be84c88046a5a5f6dfd471e3579f11f21166f539a3d2373 + languageName: node + linkType: hard + +"@types/dockerode@npm:^3.3.8": version: 3.3.9 resolution: "@types/dockerode@npm:3.3.9" dependencies: From 05c8342482f5e3ab8fbd29ab7b018dca396cdc35 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 30 Sep 2022 15:52:49 +0200 Subject: [PATCH 35/35] docs: add me sevrice-to-service auth section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: Patrik Oldsberg --- docs/auth/service-to-service-auth.md | 164 ++++++++++++++++++++++ docs/tutorials/backend-to-backend-auth.md | 66 +-------- microsite/sidebars.json | 2 +- mkdocs.yml | 1 + 4 files changed, 167 insertions(+), 66 deletions(-) create mode 100644 docs/auth/service-to-service-auth.md diff --git a/docs/auth/service-to-service-auth.md b/docs/auth/service-to-service-auth.md new file mode 100644 index 0000000000..7c501a8e9e --- /dev/null +++ b/docs/auth/service-to-service-auth.md @@ -0,0 +1,164 @@ +--- +id: service-to-service-auth +title: Service to Service Auth +# prettier-ignore +description: This section describes how to use service to service authentication, both internally within Backstage plugins and towards external services. +--- + +This article describes the steps needed to introduce _backend-to-backend auth_. +This allows plugin backends to determine whether a given request originates from +a legitimate Backstage plugin (or other external caller), by requiring a special +type of service-to-service token which is signed with a shared secret. + +When enabling this protection on your Backstage backend plugins, for example the +catalog, other callers in the ecosystem such as the search indexer and +scaffolder would need to present a valid token to the catalog to be able to +request its contents. + +## Setup + +In a newly created Backstage app, the backend is setup up to not require any +auth at all. This means that generated service-to-service tokens are empty, and +that incoming requests are not validated. If you want to enable +service-to-service auth, the first step is to switch out the following line in +your backend setup at `packages/backend/src/index.ts`: + +```diff +- const tokenManager = ServerTokenManager.noop(); ++ const tokenManager = ServerTokenManager.fromConfig(config, { logger: root }); +``` + +By switching from the no-op `ServiceTokenManager` to one created from config, +you enable service-to-service auth for any plugin that implements it. The local +development setup will generally not be impacted by this, as temporary keys are +generated under the hood. But for the production setup, this means you must now +provide a shared secret that enables your backend plugins to communicate with +each other. + +Backstage service-to-service tokens are currently always signed with a single +secret key. It needs to be shared across all backend plugins and services that +ones wishes to communicate across. The key can be any base64 encoded secret. +The following command can be used to generate such a key in a terminal: + +```bash +node -p 'require("crypto").randomBytes(24).toString("base64")' +``` + +Then place it in the backend configuration, either as a direct value or +injected as an env variable. + +```yaml +# commonly in your app-config.production.yaml +backend: + auth: + keys: + - secret: + # - secret: ${BACKEND_SECRET} - if you want to use an env variable instead +``` + +**NOTE**: For ease of development, we auto-generate a key for you if you haven't +configured a secret in dev mode. You _must set your own secret_ in order for +backend-to-backend auth to work in production; the `ServiceTokenManager` will +throw an exception in production if it has no keys to work with, which will lead +to the backend failing to start up. + +## Usage in Backend Plugins + +There are a few steps if you want to make use of the service-to-service auth in +your own backend plugin. First you need to add the `TokenManager` dependency to +the `createRouter` options. Typically as `tokenManager: TokenManager`. Along +with this you'll need to ask users to start providing this new dependency in +their backend setup code. + +Once the `TokenManager` is available, you use the `.getToken()` method to generate +a new token for any outgoing requests towards other Backstage backend plugins. +This method should be called for every request that you make; do not store the +token for later use. The `TokenManager` implementations should already cache +tokens as needed. The returned token should then be added as a `Bearer` token +for the upstream request, for example: + +```ts +const { token } = await this.tokenManager.getToken(); + +const response = await fetch(pluginBackendApiUrl, { + method: 'GET', + headers: { + ...headers, + Authorization: `Bearer ${token}`, + }, +}); +``` + +To authenticate an incoming request you use the `.authenticate(token)` method. +At the time of writing this method doesn't return anything, it will simply +throw if the token is invalid. + +```ts +await tokenManager.authenticate(token); // throws if token is invalid +``` + +## Usage in External Callers + +If you have enabled server-to-server auth, you may be interested in generating +tokens in code that is external to Backstage itself. External callers may even +be written in other languages than Node.js. This section explains how to generate +a valid token yourself. + +The token must be a JWT with a `HS256` signature, using the raw base64 decoded +value of the configured key as the secret. It must also have the following payload: + +- `sub`: "backstage-server" (only this value supported currently) +- `exp`: one hour from the time it was generated, in epoch seconds + +## Granular Access Control + +We plan to build out the service-to-service auth to be much more powerful in the +future, but before that is done there are a few tricks you can use with the +current system to harden your deployments. This section assumes that you have +already split your backend plugins into more than one backend deployment, in +order to scale or isolate them. + +The backend auth configuration has support for providing multiple keys, for +example: + +```yaml +backend: + auth: + keys: + - secret: my-secret-key-1 + - secret: my-secret-key-2 + - secret: my-secret-key-3 +``` + +The first key will be used for signing requests, while all of the keys will be +used for validation. This means that you can set up an asymmetric configuration +where some backend deployments do not have access to each other. + +For example, consider the case where we have split up the catalog, scaffolder, +and search plugin into three separate backend deployments. We can use the +following configurations to allow both the scaffolder and search plugin to speak +to the +catalog, but not the other way around, and to not allow any communication between +the scaffolder and search plugins. + +```yaml +# catalog config +backend: + auth: + keys: + - secret: my-secret-key-catalog + - secret: my-secret-key-scaffolder + - secret: my-secret-key-search + +# scaffolder config +backend: + auth: + keys: + - secret: my-secret-key-scaffolder + +# search config +backend: + auth: + keys: + - secret: my-secret-key-search +``` diff --git a/docs/tutorials/backend-to-backend-auth.md b/docs/tutorials/backend-to-backend-auth.md index 7de751be77..607356927c 100644 --- a/docs/tutorials/backend-to-backend-auth.md +++ b/docs/tutorials/backend-to-backend-auth.md @@ -4,68 +4,4 @@ title: Backend-to-Backend Authentication description: Guide for authenticating API requests between Backstage plugin backends --- -This tutorial describes the steps needed to handle _backend-to-backend -authentication_, which allows plugin backends to determine whether a given -request originates from a legitimate Backstage backend by verifying a token -signed with a shared secret. This system has limited use for now, but will be -needed to support the upcoming framework for permissions and authorization (see -[the PRFC on the topic](https://github.com/backstage/backstage/pull/7761) for -more details). - -Backends have no concept of a Backstage identity, so instead they use a token -generated using a shared key stored in config. You can generate a unique key for -your app in a terminal, and set the `BACKEND_SECRET` environment variable to the -resulting value. - -```bash -node -p 'require("crypto").randomBytes(24).toString("base64")' -``` - -**NOTE**: For ease of development, we auto-generate a key for you if you haven't -configured a secret in dev mode. You _must set your own secret_ in order for -backend-to-backend authentication to work in production. - -Requests originating from a backend plugin can be authenticated by decorating -them with a backend token. Backend tokens can be generated using a -`TokenManager`, which can be passed to plugin backends via the -`PluginEnvironment`. The `TokenManager` provided in new Backstage instances -generated by `create-app` is a stub, which returns empty tokens and accepts any -input string as valid. To enable backend-to-backend authentication, you'll need -to instantiate a new one using the secret from your config instead: - -```diff -// packages/backend/src/index.ts - -function makeCreateEnv(config: Config) { - const root = getRootLogger(); - const reader = UrlReaders.default({ logger: root, config }); - const discovery = SingleHostDiscovery.fromConfig(config); - - root.info(`Created UrlReader ${reader}`); - - const cacheManager = CacheManager.fromConfig(config); - const databaseManager = DatabaseManager.fromConfig(config); -- const tokenManager = ServerTokenManager.noop(); -+ const tokenManager = ServerTokenManager.fromConfig(config, { logger: root }); -``` - -With this `tokenManager`, you can then generate a server token for requests: - -```typescript -const { token } = await this.tokenManager.getToken(); - -const response = await fetch(pluginBackendApiUrl, { - method: 'GET', - headers: { - ...headers, - Authorization: `Bearer ${token}`, - }, -}); -``` - -You can use the same `tokenManager` to authenticate tokens supplied on incoming -requests: - -```typescript -await tokenManager.authenticate(token); // throws if token is invalid -``` +See [new docs](../auth/service-to-service-auth.md) diff --git a/microsite/sidebars.json b/microsite/sidebars.json index f00b7b2ee1..fbad2529e5 100644 --- a/microsite/sidebars.json +++ b/microsite/sidebars.json @@ -279,6 +279,7 @@ "auth/identity-resolver", "auth/oauth", "auth/add-auth-provider", + "auth/service-to-service-auth", "auth/troubleshooting", "auth/glossary" ], @@ -335,7 +336,6 @@ "tutorials/configuring-plugin-databases", "tutorials/switching-sqlite-postgres", "tutorials/using-backstage-proxy-within-plugin", - "tutorials/backend-to-backend-auth", "tutorials/yarn-migration" ], "Architecture Decision Records (ADRs)": [ diff --git a/mkdocs.yml b/mkdocs.yml index 8c86ae095d..9612a68534 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -164,6 +164,7 @@ nav: - Sign in resolvers: 'auth/identity-resolver.md' - OAuth and OpenID Connect: 'auth/oauth.md' - Contributing New Providers: 'auth/add-auth-provider.md' + - Service to Service Auth: 'auth/service-to-service-auth.md' - Troubleshooting Auth: 'auth/troubleshooting.md' - Glossary: 'auth/glossary.md' - Deployment: