forked from supabase/auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: lowercase oauth emails for account linking (supabase#1125)
- Loading branch information
1 parent
577a97e
commit df22915
Showing
3 changed files
with
42 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,12 +125,6 @@ func (ts *AccountLinkingTestSuite) TestLinkAccountExists() { | |
require.NoError(ts.T(), err) | ||
require.NoError(ts.T(), ts.db.Create(identityA)) | ||
|
||
// link decision because the below described identity is in the default linking domain but uses "other-provider" instead of "provder" | ||
decision, err := DetermineAccountLinking(ts.db, "other-provider", userA.ID.String(), []string{"[email protected]"}) | ||
require.NoError(ts.T(), err) | ||
|
||
require.Equal(ts.T(), decision.Decision, LinkAccount) | ||
|
||
userB, err := NewUser("", "[email protected]", "", "authenticated", nil) | ||
require.NoError(ts.T(), err) | ||
require.NoError(ts.T(), ts.db.Create(userB)) | ||
|
@@ -142,11 +136,46 @@ func (ts *AccountLinkingTestSuite) TestLinkAccountExists() { | |
require.NoError(ts.T(), err) | ||
require.NoError(ts.T(), ts.db.Create(identityB)) | ||
|
||
// no link decision because the SSO linking domain is scoped to the provider unique ID | ||
decision, err = DetermineAccountLinking(ts.db, "sso:f06f9e3d-ff92-4c47-a179-7acf1fda6387", userB.ID.String(), []string{"[email protected]"}) | ||
require.NoError(ts.T(), err) | ||
cases := []struct { | ||
desc string | ||
email string | ||
sub string | ||
provider string | ||
decision AccountLinkingDecision | ||
}{ | ||
{ | ||
// link decision because the below described identity is in the default linking domain but uses "other-provider" instead of "provder" | ||
desc: "same email address", | ||
email: "[email protected]", | ||
sub: userA.ID.String(), | ||
provider: "other-provider", | ||
decision: LinkAccount, | ||
}, | ||
{ | ||
desc: "same email address in uppercase", | ||
email: "[email protected]", | ||
sub: userA.ID.String(), | ||
provider: "other-provider", | ||
decision: LinkAccount, | ||
}, | ||
{ | ||
desc: "no link decision because the SSO linking domain is scoped to the provider unique ID", | ||
email: "[email protected]", | ||
sub: userB.ID.String(), | ||
provider: "sso:f06f9e3d-ff92-4c47-a179-7acf1fda6387", | ||
decision: AccountExists, | ||
}, | ||
} | ||
|
||
for _, c := range cases { | ||
ts.Run(c.desc, func() { | ||
decision, err := DetermineAccountLinking(ts.db, c.provider, c.sub, []string{c.email}) | ||
require.NoError(ts.T(), err) | ||
|
||
require.Equal(ts.T(), decision.Decision, c.decision) | ||
}) | ||
} | ||
|
||
require.NotEqual(ts.T(), decision.Decision, LinkAccount) | ||
} | ||
|
||
func (ts *AccountLinkingTestSuite) TestMultipleAccounts() { | ||
|