From 76b7167e573bc07cd453a2fedd337026eaddc827 Mon Sep 17 00:00:00 2001 From: Joel Cox Date: Tue, 29 Mar 2022 23:10:04 +1100 Subject: [PATCH] docs: update alb authentication example Signed-off-by: Joel Cox --- ADOPTERS.md | 3 +- .../docs/tutorials/aws-alb-aad-oidc-auth.md | 53 ++++++++++++------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/ADOPTERS.md b/ADOPTERS.md index ac9139a7ed..9630ee8c9a 100644 --- a/ADOPTERS.md +++ b/ADOPTERS.md @@ -47,7 +47,7 @@ _If you're using Backstage in your organization, please try to add your company | [creditas.com](https://creditas.com/) | [@aureliosaraiva](https://github.com/aureliosaraiva) [@Creditas](https://github.com/creditas) | Centralization of all services, standards, documentation, etc. We started the deployment process. | | [Prisjakt](https://www.prisjakt.nu) / [PriceSpy](https://pricespy.co.uk) | [@kennylindahl](https://github.com/kennylindahl) | Internal developer portal - Documentation, scaffolding, software catalog, TechRadar, Gitlab org data integration | | [Powerspike](https://powerspike.tv/) | [@trelore](https://github.com/trelore) | Developer portal for documentation of core libraries and repositories. | -| [2U](https://2u.com) | [@danielleEriksen](https://github.com/danielleEriksen), [@sbhatia](https://github.com/sbhatia) | Development team home-base, promoting service discoverability, resource dependencies, and tech radar | +| [2U](https://2u.com) | [@danielleEriksen](https://github.com/danielleEriksen), [@sbhatia](https://github.com/sbhatia) | Development team home-base, promoting service discoverability, resource dependencies, and tech radar | | [Taxfix](https://taxfix.de/) | [Sami Ur Rehman](https://github.com/samiurrehman92) | Developer's portal with software catalog at it's core. Hosts API Specs, Tech Docs, Tech Radar and some custom plugins. | | [Busuu](https://busuu.com/) | [Adam Tester](https://github.com/adamtester) | Developer portal with service catalog, API docs, Event docs, service templating, and cost insights. | | [Loadsmart](https://loadsmart.com/) | [Loadsmart](https://github.com/loadsmart) | Improve services visibility and operations for service owners and developers. | @@ -109,4 +109,3 @@ _If you're using Backstage in your organization, please try to add your company | [Bonial International GmbH](https://www.bonial.com/) | [@pjungermann](https://github.com/pjungermann) | Centralized developer portal with software catalog, tech docs, templates, and more. | | [Beez Innovation Labs Pvt. Ltd](https://www.beezlabs.com/) | [Karthikeyan Venkatesan](https://github.com/karthikeyan23) | Developer portal with software catalog, scaffolding, tech docs, templates, and infra. | | [Agorapulse](https://www.agorapulse.com/) | [@jvdrean](https://github.com/jvdrean) | Developer portal with software catalog, documentation, monitoring, runbooks, tech radar and more. | - diff --git a/contrib/docs/tutorials/aws-alb-aad-oidc-auth.md b/contrib/docs/tutorials/aws-alb-aad-oidc-auth.md index 52f7888fb8..52784e93bb 100644 --- a/contrib/docs/tutorials/aws-alb-aad-oidc-auth.md +++ b/contrib/docs/tutorials/aws-alb-aad-oidc-auth.md @@ -55,33 +55,50 @@ When using ALB authentication Backstage will only be loaded once the user has su - add the following definition just before the app is created (`const app = createApp`): ```ts -const DummySignInComponent: any = (props: any) => { - try { - const config = useApi(configApiRef); +import React from 'react'; +import { UserIdentity } from '@backstage/core-components'; +import { SignInPageProps } from '@backstage/core-app-api'; + +const DummySignInComponent: any = (props: SignInPageProps) => { + const [error, setError] = React.useState(); + const config = useApi(configApiRef); + React.useEffect(() => { const shouldAuth = !!config.getOptionalConfig('auth.providers.awsalb'); if (shouldAuth) { fetch(`${window.location.origin}/api/auth/awsalb/refresh`) .then(data => data.json()) .then(data => { - props.onResult({ - userId: data.backstageIdentity.id, - profile: data.profile, - }); + props.onSignInSuccess( + UserIdentity.fromLegacy({ + userId: data.backstageIdentity.id, + profile: data.profile, + }), + ); + }) + .catch(err => { + setError(err.message); }); } else { - props.onResult({ - userId: 'guest', - profile: { - email: 'guest@example.com', - displayName: 'Guest', - picture: '', - }, - }); + try { + props.onSignInSuccess( + UserIdentity.fromLegacy({ + userId: 'guest', + profile: { + email: 'guest@example.com', + displayName: 'Guest', + picture: '', + }, + }), + ); + } catch (err) { + setError(err.message); + } } - return
; - } catch (err) { - return
{err.message}
; + }, [config]); + if (error) { + return
{error}
; } + return
; }; ```