docs: update alb authentication example

Signed-off-by: Joel Cox <joel@pinecodes.com>
This commit is contained in:
Joel Cox
2022-03-29 23:10:04 +11:00
parent d8dd90927e
commit 76b7167e57
2 changed files with 36 additions and 20 deletions
+1 -2
View File
@@ -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. |
+35 -18
View File
@@ -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<string | undefined>();
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 <div />;
} catch (err) {
return <div>{err.message}</div>;
}, [config]);
if (error) {
return <div>{error}</div>;
}
return <div />;
};
```