forked from Deuxfleurs/guichet
Fix several group membership issue
TODO: - check for other wrong uses of GetAttributeValue(s) - refactor is_admin check
This commit is contained in:
parent
0dca53bca0
commit
dc9b2bc458
2 changed files with 18 additions and 9 deletions
11
admin.go
11
admin.go
|
@ -19,9 +19,14 @@ func checkAdminLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
can_admin := (login.Info.DN == config.AdminAccount)
|
can_admin := (login.Info.DN == config.AdminAccount)
|
||||||
for _, group := range login.UserEntry.GetAttributeValues("memberof") {
|
fmt.Printf("%#v", login.UserEntry)
|
||||||
if config.GroupCanAdmin != "" && group == config.GroupCanAdmin {
|
for _, attr := range login.UserEntry.Attributes {
|
||||||
can_admin = true
|
if strings.EqualFold(attr.Name, "memberof") {
|
||||||
|
for _, group := range attr.Values {
|
||||||
|
if config.GroupCanAdmin != "" && group == config.GroupCanAdmin {
|
||||||
|
can_admin = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
main.go
16
main.go
|
@ -259,12 +259,16 @@ func handleHome(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
can_admin := (login.Info.DN == config.AdminAccount)
|
can_admin := (login.Info.DN == config.AdminAccount)
|
||||||
can_invite := false
|
can_invite := false
|
||||||
for _, group := range login.UserEntry.GetAttributeValues("memberof") {
|
for _, attr := range login.UserEntry.Attributes {
|
||||||
if config.GroupCanInvite != "" && group == config.GroupCanInvite {
|
if strings.EqualFold(attr.Name, "memberof") {
|
||||||
can_invite = true
|
for _, group := range attr.Values {
|
||||||
}
|
if config.GroupCanInvite != "" && group == config.GroupCanInvite {
|
||||||
if config.GroupCanAdmin != "" && group == config.GroupCanAdmin {
|
can_invite = true
|
||||||
can_admin = true
|
}
|
||||||
|
if config.GroupCanAdmin != "" && group == config.GroupCanAdmin {
|
||||||
|
can_admin = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue