]> source.dussan.org Git - gitea.git/commitdiff
Fix OAuth Source Edit Page (#18495)
authorzeripath <art27@cantab.net>
Mon, 31 Jan 2022 20:41:11 +0000 (20:41 +0000)
committerGitHub <noreply@github.com>
Mon, 31 Jan 2022 20:41:11 +0000 (20:41 +0000)
* 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 7793a408d84f73ea63de93d42f2049ea5344044d..a8a132bc941a2356a13d53c9d99535afc0253bab 100644 (file)
@@ -900,6 +900,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, ",")