-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve oauth2 client "preferred username field" logic and the error …
…handling (#30622) Follow #30454 And fix #24957 When using "preferred_username", if no such field, `extractUserNameFromOAuth2` (old `getUserName`) shouldn't return an error. All other USERNAME options do not return such error. And fine tune some logic and error messages, make code more stable and more friendly to end users.
- Loading branch information
1 parent
d0bfc97
commit bffbbf5
Showing
16 changed files
with
172 additions
and
67 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
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 |
---|---|---|
|
@@ -506,15 +506,16 @@ func Test_NormalizeUserFromEmail(t *testing.T) { | |
Expected string | ||
IsNormalizedValid bool | ||
}{ | ||
{"test", "test", true}, | ||
{"[email protected]", "name", true}, | ||
{"test'`´name", "testname", true}, | ||
{"Sinéad.O'Connor", "Sinead.OConnor", true}, | ||
{"Æsir", "AEsir", true}, | ||
// \u00e9\u0065\u0301 | ||
{"éé", "ee", true}, | ||
{"éé", "ee", true}, // \u00e9\u0065\u0301 | ||
{"Awareness Hub", "Awareness-Hub", true}, | ||
{"double__underscore", "double__underscore", false}, // We should consider squashing double non-alpha characters | ||
{".bad.", ".bad.", false}, | ||
{"new😀user", "new😀user", false}, // No plans to support | ||
{`"quoted"`, `"quoted"`, false}, // No plans to support | ||
} | ||
for _, testCase := range testCases { | ||
normalizedName, err := user_model.NormalizeUserName(testCase.Input) | ||
|
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2024 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package session | ||
|
||
import ( | ||
"net/http" | ||
|
||
"gitea.com/go-chi/session" | ||
) | ||
|
||
type MockStore struct { | ||
*session.MemStore | ||
} | ||
|
||
func (m *MockStore) Destroy(writer http.ResponseWriter, request *http.Request) error { | ||
return nil | ||
} | ||
|
||
type mockStoreContextKeyStruct struct{} | ||
|
||
var MockStoreContextKey = mockStoreContextKeyStruct{} | ||
|
||
func NewMockStore(sid string) *MockStore { | ||
return &MockStore{session.NewMemStore(sid)} | ||
} |
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
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
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
Oops, something went wrong.