Skip to content

Commit 6ecdea1

Browse files
committed
Remove option for normalization
1 parent e989db0 commit 6ecdea1

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

custom/conf/app.example.ini

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,8 +1525,10 @@ LEVEL = Info
15251525
;; userid = use the userid / sub attribute
15261526
;; nickname = use the nickname attribute
15271527
;; email = use the username part of the email attribute
1528-
;; email-normalized = use the username part of the email attribute with single-quotes
1529-
;; removed, and any other non-supported username characters replaced with a `-` character
1528+
;; Note: `nickname` and `email` options will normalize input strings using the following criteria:
1529+
;; - diacritics are removed
1530+
;; - single-quotes are removed
1531+
;; - the characters set `\s,` is replaced with `-`
15301532
;USERNAME = nickname
15311533
;;
15321534
;; Update avatar if available from oauth2 provider.

docs/content/administration/config-cheat-sheet.en-us.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -595,10 +595,13 @@ And the following unique queues:
595595
- `OPENID_CONNECT_SCOPES`: **_empty_**: List of additional openid connect scopes. (`openid` is implicitly added)
596596
- `ENABLE_AUTO_REGISTRATION`: **false**: Automatically create user accounts for new oauth2 users.
597597
- `USERNAME`: **nickname**: The source of the username for new oauth2 accounts:
598-
- userid - use the userid / sub attribute
599-
- nickname - use the nickname attribute
600-
- email - use the username part of the email attribute
601-
- email-normalized - use the username part of the email attribute with diacritics and single-quotes removed, and `\s,` replaced with `-`
598+
- `userid` - use the userid / sub attribute
599+
- `nickname` - use the nickname attribute
600+
- `email` - use the username part of the email attribute
601+
- Note: `nickname` and `email` options will normalize input strings using the following criteria:
602+
- diacritics are removed
603+
- single-quotes are removed
604+
- the characters set `\s,` is replaced with `-`
602605
- `UPDATE_AVATAR`: **false**: Update avatar if available from oauth2 provider. Update will be performed on each login.
603606
- `ACCOUNT_LINKING`: **login**: How to handle if an account / email already exists:
604607
- disabled - show an error

models/user/user_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,13 +553,13 @@ func Test_NormalizeUserFromEmail(t *testing.T) {
553553
}{
554554
{"test", "test", true},
555555
{"Sinéad.O'Connor", "Sinead.OConnor", true},
556-
{"Æsir", "-sir", false}, // Currently unsupported
556+
{"Æsir", "Æsir", false}, // Currently unsupported
557557
// \u00e9\u0065\u0301
558558
{"éé", "ee", true},
559559
{"Awareness Hub", "Awareness-Hub", true},
560560
{"double__underscore", "double__underscore", false}, // We should consider squashing double non-alpha characters
561561
{".bad.", ".bad.", false},
562-
{"new😀user", "new-user", true},
562+
{"new😀user", "new😀user", false},
563563
}
564564
for _, testCase := range testCases {
565565
normalizedName, err := user_model.NormalizeUserName(testCase.Input)

modules/setting/oauth2.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@ const (
2323
OAuth2UsernameNickname OAuth2UsernameType = "nickname"
2424
// OAuth2UsernameEmail username of oauth2 email field will be used as gitea name
2525
OAuth2UsernameEmail OAuth2UsernameType = "email"
26-
// OAuth2UsernameEmail username of oauth2 email field will be used as gitea name, with
27-
// single-quotes removed, and any other non-supported username characters replaced with
28-
// a `-` character
29-
OAuth2UsernameEmailNormalized OAuth2UsernameType = "email-normalized"
3026
)
3127

3228
func (username OAuth2UsernameType) isValid() bool {
3329
switch username {
34-
case OAuth2UsernameUserid, OAuth2UsernameNickname, OAuth2UsernameEmail, OAuth2UsernameEmailNormalized:
30+
case OAuth2UsernameUserid, OAuth2UsernameNickname, OAuth2UsernameEmail:
3531
return true
3632
}
3733
return false

routers/web/auth/auth.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,9 @@ func handleSignInFull(ctx *context.Context, u *user_model.User, remember, obeyRe
371371
func getUserName(gothUser *goth.User) (string, error) {
372372
switch setting.OAuth2Client.Username {
373373
case setting.OAuth2UsernameEmail:
374-
return strings.Split(gothUser.Email, "@")[0], nil
375-
case setting.OAuth2UsernameEmailNormalized:
376374
return user_model.NormalizeUserName(strings.Split(gothUser.Email, "@")[0])
377375
case setting.OAuth2UsernameNickname:
378-
return gothUser.NickName, nil
376+
return user_model.NormalizeUserName(gothUser.NickName)
379377
default: // OAuth2UsernameUserid
380378
return gothUser.UserID, nil
381379
}

0 commit comments

Comments
 (0)