mirror of
https://github.com/goauthentik/authentik
synced 2026-04-30 11:27:15 +02:00
* packages/client-go: init Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> * format Signed-off-by: Jens Langhammer <jens@goauthentik.io> * remove mod/sum Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix translate Signed-off-by: Jens Langhammer <jens@goauthentik.io> * no go replace Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update rust makefile with pwd Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> * fix build Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix docs Signed-off-by: Jens Langhammer <jens@goauthentik.io> * don't need a version ig? Signed-off-by: Jens Langhammer <jens@goauthentik.io> * exclude go client from cspell Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix main docker build Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: Jens Langhammer <jens@goauthentik.io>
64 lines
1.8 KiB
Go
64 lines
1.8 KiB
Go
package ldap
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"beryju.io/ldap"
|
|
|
|
"goauthentik.io/internal/outpost/ldap/constants"
|
|
"goauthentik.io/internal/outpost/ldap/utils"
|
|
api "goauthentik.io/packages/client-go"
|
|
)
|
|
|
|
func (pi *ProviderInstance) UserEntry(u api.User) *ldap.Entry {
|
|
dn := pi.GetUserDN(u.Username)
|
|
attrs := utils.AttributesToLDAP(u.Attributes, func(key string) string {
|
|
return utils.AttributeKeySanitize(key)
|
|
}, func(value []string) []string {
|
|
for i, v := range value {
|
|
if strings.Contains(v, "%s") {
|
|
value[i] = fmt.Sprintf(v, u.Username)
|
|
}
|
|
}
|
|
return value
|
|
})
|
|
|
|
if u.IsActive == nil {
|
|
u.IsActive = new(false)
|
|
}
|
|
if u.Email == nil {
|
|
u.Email = new("")
|
|
}
|
|
attrs = utils.EnsureAttributes(attrs, map[string][]string{
|
|
"ak-active": {strings.ToUpper(strconv.FormatBool(*u.IsActive))},
|
|
"ak-superuser": {strings.ToUpper(strconv.FormatBool(u.IsSuperuser))},
|
|
"memberOf": pi.GroupsForUser(u),
|
|
"cn": {u.Username},
|
|
"sAMAccountName": {u.Username},
|
|
"uid": {u.Uid},
|
|
"name": {u.Name},
|
|
"displayName": {u.Name},
|
|
"mail": {*u.Email},
|
|
"objectClass": {
|
|
constants.OCTop,
|
|
constants.OCPerson,
|
|
constants.OCOrgPerson,
|
|
constants.OCInetOrgPerson,
|
|
constants.OCUser,
|
|
constants.OCPosixAccount,
|
|
constants.OCAKUser,
|
|
},
|
|
"uidNumber": {pi.GetUserUidNumber(u)},
|
|
"gidNumber": {pi.GetUserGidNumber(u)},
|
|
"homeDirectory": {fmt.Sprintf("/home/%s", u.Username)},
|
|
"sn": {u.Name},
|
|
"pwdChangedTime": {u.PasswordChangeDate.In(time.UTC).Format("20060102150405Z")},
|
|
"createTimestamp": {u.DateJoined.In(time.UTC).Format("20060102150405Z")},
|
|
"modifyTimestamp": {u.LastUpdated.In(time.UTC).Format("20060102150405Z")},
|
|
})
|
|
return &ldap.Entry{DN: dn, Attributes: attrs}
|
|
}
|