Browse Source

Fix OAuth Source Edit Page (#18495) (#18503)

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>
tags/v1.16.1
zeripath 3 years ago committed by GitHub
parent
commit
083b85c655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      routers/web/admin/auths.go
  2. 4
      routers/web/auth/oauth.go

3
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,
}
}

4
routers/web/auth/oauth.go

@ -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, ",")

Loading…
Cancel
Save