create-app: add sign-in resolver example

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-05-02 11:02:54 +02:00
parent 73357576e0
commit 7b253072c6
2 changed files with 27 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/create-app': patch
---
Tweaked template to provide an example and guidance for how to configure sign-in in `packages/backend/src/plugins/auth.ts`. There is no need to add this to existing apps, but for more information about sign-in configuration, see https://backstage.io/docs/auth/identity-resolver.
@@ -1,4 +1,8 @@
import { createRouter } from '@backstage/plugin-auth-backend';
import {
createRouter,
providers,
defaultAuthProviderFactories,
} from '@backstage/plugin-auth-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';
@@ -11,5 +15,22 @@ export default async function createPlugin(
database: env.database,
discovery: env.discovery,
tokenManager: env.tokenManager,
providerFactories: {
...defaultAuthProviderFactories,
// This overrides the default GitHub auth provider with a custom one.
// Since the options are empty it will behave just like the default
// provider, but if you uncomment the `signIn` section you will enable
// sign-in via GitHub. This particular configuration uses a resolver
// that matches the username to the user entity name. See the auth
// documentation for more details on how to enable and customize sign-in:
//
// https://backstage.io/docs/auth/identity-resolver
github: providers.github.create({
// signIn: {
// resolver: providers.github.resolvers.usernameMatchingUserEntityName(),
// },
}),
},
});
}