outposts/ldap: use backend group num_pk
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
4d5a619cc0
commit
51194cbf42
|
@ -140,7 +140,7 @@ func (ms *MemorySearcher) Search(req *search.Request) (ldap.ServerSearchResult,
|
|||
for _, u := range g.UsersObj {
|
||||
if flags.UserPk == u.Pk {
|
||||
//TODO: Is there a better way to clone this object?
|
||||
fg := api.NewGroup(g.Pk, g.Name, g.Parent, g.ParentName, []int32{flags.UserPk}, []api.GroupMember{u})
|
||||
fg := api.NewGroup(g.Pk, g.NumPk, g.Name, g.Parent, g.ParentName, []int32{flags.UserPk}, []api.GroupMember{u})
|
||||
fg.SetAttributes(*g.Attributes)
|
||||
fg.SetIsSuperuser(*g.IsSuperuser)
|
||||
groups = append(groups, group.FromAPIGroup(*fg, ms.si))
|
||||
|
|
|
@ -2,9 +2,7 @@ package ldap
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"goauthentik.io/api/v3"
|
||||
)
|
||||
|
@ -54,20 +52,5 @@ func (pi *ProviderInstance) GetGidNumber(group api.Group) string {
|
|||
return gidNumber
|
||||
}
|
||||
|
||||
return strconv.FormatInt(int64(pi.gidStartNumber+pi.GetRIDForGroup(group.Pk)), 10)
|
||||
}
|
||||
|
||||
func (pi *ProviderInstance) GetRIDForGroup(uid string) int32 {
|
||||
var i big.Int
|
||||
i.SetString(strings.Replace(uid, "-", "", -1), 16)
|
||||
intStr := i.String()
|
||||
|
||||
// Get the last 5 characters/digits of the int-version of the UUID
|
||||
gid, err := strconv.Atoi(intStr[len(intStr)-5:])
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return int32(gid)
|
||||
return strconv.FormatInt(int64(pi.gidStartNumber+group.NumPk), 10)
|
||||
}
|
||||
|
|
Reference in New Issue