mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 10:32:25 -05:00
[feature] Make OIDC admin groups configurable (#1555)
This removes the current default of checking for membership of the admin or admins group and makes it required to explicitly configure which groups should grant admin access, if any. Relying on the implicit default of admin or admins is potentially dangerous as that group may contain a different subset of people that we may wish to grant admin access to GtS. This is probably not an issue for a single-person instance, but for a community instance different admin groups may exist in an OIDC provider for different applications. I'm explicitly opting for not defaulting the value of oidc-admin-groups to admin,admins because I think it's better for those things to be explicitly configured.
This commit is contained in:
parent
c27b4d7ed0
commit
9cfb69f75d
6 changed files with 49 additions and 6 deletions
|
|
@ -284,10 +284,15 @@ func (m *Module) createUserFromOIDC(ctx context.Context, claims *oidc.Claims, ex
|
|||
}
|
||||
|
||||
// check if the user is in any recognised admin groups
|
||||
adminGroups := config.GetOIDCAdminGroups()
|
||||
var admin bool
|
||||
LOOP:
|
||||
for _, g := range claims.Groups {
|
||||
if strings.EqualFold(g, "admin") || strings.EqualFold(g, "admins") {
|
||||
admin = true
|
||||
for _, ag := range adminGroups {
|
||||
if strings.EqualFold(g, ag) {
|
||||
admin = true
|
||||
break LOOP
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue