From 7d452558f095a5dea687a6e9b67961c8ae2aef7f Mon Sep 17 00:00:00 2001 From: zeripath Date: Mon, 31 Jan 2022 20:41:11 +0000 Subject: [PATCH] Fix OAuth Source Edit Page (#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 --- routers/web/admin/auths.go | 3 +++ routers/web/auth/oauth.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/routers/web/admin/auths.go b/routers/web/admin/auths.go index 338a54c5dd2..20f364739e1 100644 --- a/routers/web/admin/auths.go +++ b/routers/web/admin/auths.go @@ -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, } } diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go index 7793a408d84..a8a132bc941 100644 --- a/routers/web/auth/oauth.go +++ b/routers/web/auth/oauth.go @@ -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, ",")