backend: drop catalog user requirement from github sign-in

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-05-30 11:44:58 +02:00
parent 3b773b8cc6
commit 55b79c4a71
+21 -1
View File
@@ -44,7 +44,27 @@ export default async function createPlugin(
// It is here for demo purposes only.
github: providers.github.create({
signIn: {
resolver: providers.github.resolvers.usernameMatchingUserEntityName(),
async resolver({ result: { fullProfile } }, ctx) {
const userId = fullProfile.username;
if (!userId) {
throw new Error(
`GitHub user profile does not contain a username`,
);
}
const userEntityRef = stringifyEntityRef({
kind: 'User',
name: userId,
namespace: DEFAULT_NAMESPACE,
});
return ctx.issueToken({
claims: {
sub: userEntityRef,
ent: [userEntityRef],
},
});
},
},
}),
gitlab: providers.gitlab.create({