SignInConfig -> SignInProviderConfig

Signed-off-by: Tim Hansen <timbonicus@gmail.com>
This commit is contained in:
Tim Hansen
2021-04-13 07:59:31 -06:00
parent 8fd2a33642
commit 83a437b349
6 changed files with 18 additions and 14 deletions
+3 -3
View File
@@ -58,7 +58,7 @@ the local `auth.environment` setting will be selected.
After configuring an authentication provider, the `app` frontend package needs a
small update to show this provider as a login option. The `SignInPage` component
handles this, and takes either a `provider` or `providers` (array) prop of
`SignInConfig` definitions.
`SignInProviderConfig` definitions.
These reference the [ApiRef](../reference/utility-apis/README.md) exported by
the provider. Again, an example using GitHub that can be adapted to any of the
@@ -66,9 +66,9 @@ built-in providers:
```diff
# packages/app/src/App.tsx
+ import { githubAuthApiRef, SignInConfig, SignInPage } from '@backstage/core';
+ import { githubAuthApiRef, SignInProviderConfig, SignInPage } from '@backstage/core';
+ const githubProvider: SignInConfig = {
+ const githubProvider: SignInProviderConfig = {
+ id: 'github-auth-provider',
+ title: 'GitHub',
+ message: 'Sign in using GitHub',
@@ -22,7 +22,7 @@ import { ContentHeader } from '../ContentHeader/ContentHeader';
import { Grid, Button, Typography } from '@material-ui/core';
import { SignInPageProps, useApi, configApiRef } from '@backstage/core-api';
import { useSignInProviders, getSignInProviders } from './providers';
import { IdentityProviders, SignInConfig } from './types';
import { IdentityProviders, SignInProviderConfig } from './types';
import { Progress } from '../../components/Progress';
import { GridItem, useStyles } from './styles';
import { InfoCard } from '../InfoCard';
@@ -34,7 +34,7 @@ type MultiSignInPageProps = SignInPageProps & {
};
type SingleSignInPageProps = SignInPageProps & {
provider: SignInConfig;
provider: SignInProviderConfig;
auto?: boolean;
};
@@ -21,13 +21,13 @@ import {
ProviderComponent,
ProviderLoader,
SignInProvider,
SignInConfig,
SignInProviderConfig,
} from './types';
import { useApi, errorApiRef } from '@backstage/core-api';
import { GridItem } from './styles';
const Component: ProviderComponent = ({ config, onResult }) => {
const { apiRef, title, message } = config as SignInConfig;
const { apiRef, title, message } = config as SignInProviderConfig;
const authApi = useApi(apiRef);
const errorApi = useApi(errorApiRef);
+1 -1
View File
@@ -14,5 +14,5 @@
* limitations under the License.
*/
export type { SignInConfig } from './types';
export type { SignInProviderConfig } from './types';
export { SignInPage } from './SignInPage';
@@ -22,7 +22,11 @@ import {
useApiHolder,
errorApiRef,
} from '@backstage/core-api';
import { SignInConfig, IdentityProviders, SignInProvider } from './types';
import {
IdentityProviders,
SignInProvider,
SignInProviderConfig,
} from './types';
import { commonProvider } from './commonProvider';
import { guestProvider } from './guestProvider';
import { customProvider } from './customProvider';
@@ -33,7 +37,7 @@ export type SignInProviderType = {
[key: string]: {
components: SignInProvider;
id: string;
config?: SignInConfig;
config?: SignInProviderConfig;
};
};
@@ -62,7 +66,7 @@ export function getSignInProviders(
return acc;
}
const { id } = config as SignInConfig;
const { id } = config as SignInProviderConfig;
validateIDs(id, acc);
acc[id] = { components: signInProviders.common, id, config };
+3 -3
View File
@@ -25,17 +25,17 @@ import {
SessionApi,
} from '@backstage/core-api';
export type SignInConfig = {
export type SignInProviderConfig = {
id: string;
title: string;
message: string;
apiRef: ApiRef<ProfileInfoApi & BackstageIdentityApi & SessionApi>;
};
export type IdentityProviders = ('guest' | 'custom' | SignInConfig)[];
export type IdentityProviders = ('guest' | 'custom' | SignInProviderConfig)[];
export type ProviderComponent = ComponentType<
SignInPageProps & { config: SignInConfig }
SignInPageProps & { config: SignInProviderConfig }
>;
export type ProviderLoader = (