Merge pull request #1500 from timurista/timurista

Add gitlab sign in method #343
This commit is contained in:
Patrik Oldsberg
2020-07-06 19:21:44 +02:00
committed by GitHub
5 changed files with 117 additions and 2 deletions
@@ -41,6 +41,9 @@ describe('GitlabAuthProvider', () => {
},
},
expect: {
backstageIdentity: {
id: 'jimmymarkum',
},
providerInfo: {
accessToken: '19xasczxcm9n7gacn9jdgm19me',
expiresInSeconds: 100,
@@ -74,6 +77,9 @@ describe('GitlabAuthProvider', () => {
},
},
expect: {
backstageIdentity: {
id: 'daveboyle',
},
providerInfo: {
accessToken:
'ajakljsdoiahoawxbrouawucmbawe.awkxjemaneasdxwe.sodijxqeqwexeqwxe',
@@ -78,6 +78,14 @@ export class GitlabAuthProvider implements OAuthProviderHandlers {
idToken: params.id_token,
};
// gitlab provides an id numeric value (123)
// as a fallback
let id = passportProfile!.id;
if (profile.email) {
id = profile.email.split('@')[0];
}
if (params.expires_in) {
providerInfo.expiresInSeconds = params.expires_in;
}
@@ -87,6 +95,9 @@ export class GitlabAuthProvider implements OAuthProviderHandlers {
return {
providerInfo,
profile,
backstageIdentity: {
id,
},
};
}