Skip to content

Commit

Permalink
Merge pull request taskcluster#525 from djmitche/bug1536863-c
Browse files Browse the repository at this point in the history
Bug 1536863 - be a little more flexible in reading the chimeric Auth0 profiles
  • Loading branch information
djmitche authored Apr 1, 2019
2 parents 57eef35 + 27f2c5c commit fa98fdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions services/login/src/handlers/mozilla-auth0.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,12 @@ class Handler {
for (let {provider, connection, profileData} of profile.identities) {
if (provider === 'oauth2' && connection === 'firefoxaccounts') {
// we expect the auth0 user_id to be `oauth|firefoxaccounts|<fxa_sub>`
assert(user_id.endsWith(profileData.fxa_sub),
// sometimes fxa_sub is on profileData, sometimes on the profile
const fxa_sub = profileData ? profileData.fxa_sub : profile.fxa_sub;
assert(user_id.endsWith(fxa_sub),
`Auth0 user_id ${user_id} not formatted as expected`);
identity += `|${profileData.email}`;
const email = profileData ? profileData.email : profile.email;
identity += `|${email}`;
break;
}
}
Expand Down
5 changes: 3 additions & 2 deletions services/login/test/handlers_mozilla_auth0_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ suite('handlers/mozilla-auth0', function() {
const identities = [
{provider: 'ad', connection: 'Mozilla-LDAP'},
{provider: 'github', connection: 'github', user_id: 1234},
{provider: 'oauth2', connection: 'firefoxaccounts',
profileData: {fxa_sub: 'abcdef', email: 'rockets@ksc'}},
{provider: 'oauth2', connection: 'firefoxaccounts'},
{provider: 'email', connection: 'email', user_id: 'slashy/slashy'},
];
return {
Expand All @@ -42,6 +41,8 @@ suite('handlers/mozilla-auth0', function() {
case 'oauth2|firefoxaccounts|abcdef':
return {
user_id: 'oauth2|firefoxaccounts|abcdef',
email: 'rockets@ksc',
fxa_sub: 'abcdef',
identities,
};
case 'email|slashy/slashy':
Expand Down

0 comments on commit fa98fdd

Please sign in to comment.