core: allow filtering users by the groups they are in

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-08-21 16:23:07 +02:00
parent ff24bc8cb8
commit 3e909ae6bb
6 changed files with 57 additions and 10 deletions

View File

@ -1,6 +1,7 @@
package ldap
import (
goldap "github.com/go-ldap/ldap/v3"
ber "github.com/nmcclain/asn1-ber"
"github.com/nmcclain/ldap"
"goauthentik.io/api"
@ -45,6 +46,14 @@ func parseFilterForUserSingle(req api.ApiCoreUsersListRequest, f *ber.Packet) ap
return req.Name(vv)
case "mail":
return req.Email(vv)
case "member":
case "memberOf":
groupDN, err := goldap.ParseDN(vv)
if err != nil {
return req
}
name := groupDN.RDNs[0].Attributes[0].Value
return req.GroupsByName([]string{name})
}
// TODO: Support int
default: