]> source.dussan.org Git - gitea.git/commitdiff
Fix OAuth Source Edit Page (#18495) (#18503)
authorzeripath <art27@cantab.net>
Mon, 31 Jan 2022 21:36:34 +0000 (21:36 +0000)
committerGitHub <noreply@github.com>
Mon, 31 Jan 2022 21:36:34 +0000 (23:36 +0200)
Backport #18495

* Fix OAuth Source Edit Page to ensure restricted and group settings are set
* Also tolerate []interface in the groups

Fix #18432

Signed-off-by: Andrew Thornton <art27@cantab.net>
routers/web/admin/auths.go
routers/web/auth/oauth.go

index 338a54c5dd264a99bb5cf6e512d347dd2d750023..20f364739e12e84f91640529d0a5c93ae5c2dc0c 100644 (file)
@@ -192,6 +192,9 @@ func parseOAuth2Config(form forms.AuthenticationForm) *oauth2.Source {
                RequiredClaimName:             form.Oauth2RequiredClaimName,
                RequiredClaimValue:            form.Oauth2RequiredClaimValue,
                SkipLocalTwoFA:                form.SkipLocalTwoFA,
+               GroupClaimName:                form.Oauth2GroupClaimName,
+               RestrictedGroup:               form.Oauth2RestrictedGroup,
+               AdminGroup:                    form.Oauth2AdminGroup,
        }
 }
 
index fa2b0aa65f1f804b0b64c3ad26e82dca1edfd701..dbd17563484dadb516f6065576d8bc034f3d9328 100644 (file)
@@ -904,6 +904,10 @@ func claimValueToStringSlice(claimValue interface{}) []string {
        switch rawGroup := claimValue.(type) {
        case []string:
                groups = rawGroup
+       case []interface{}:
+               for _, group := range rawGroup {
+                       groups = append(groups, fmt.Sprintf("%s", group))
+               }
        default:
                str := fmt.Sprintf("%s", rawGroup)
                groups = strings.Split(str, ",")