outposts/ldap: more cleanup
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
a426a1a0b6
commit
30aa24ce6e
|
@ -122,21 +122,3 @@ func (ls *LDAPServer) Start() error {
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type transport struct {
|
|
||||||
headers map[string]string
|
|
||||||
inner http.RoundTripper
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|
||||||
for key, value := range t.headers {
|
|
||||||
req.Header.Add(key, value)
|
|
||||||
}
|
|
||||||
return t.inner.RoundTrip(req)
|
|
||||||
}
|
|
||||||
func newTransport(inner http.RoundTripper, headers map[string]string) *transport {
|
|
||||||
return &transport{
|
|
||||||
inner: inner,
|
|
||||||
headers: headers,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -57,10 +57,9 @@ func (pi *ProviderInstance) Bind(username string, bindDN, bindPW string, conn ne
|
||||||
config.UserAgent = pkg.UserAgent()
|
config.UserAgent = pkg.UserAgent()
|
||||||
config.HTTPClient = &http.Client{
|
config.HTTPClient = &http.Client{
|
||||||
Jar: jar,
|
Jar: jar,
|
||||||
Transport: newTransport(ak.GetTLSTransport(), map[string]string{
|
Transport: ak.GetTLSTransport(),
|
||||||
"X-authentik-remote-ip": host,
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
|
config.AddDefaultHeader("X-authentik-remote-ip", host)
|
||||||
// create the API client, with the transport
|
// create the API client, with the transport
|
||||||
apiClient := api.NewAPIClient(config)
|
apiClient := api.NewAPIClient(config)
|
||||||
|
|
||||||
|
|
|
@ -108,11 +108,11 @@ func (pi *ProviderInstance) UserEntry(u api.User) *ldap.Entry {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "uidNumber",
|
Name: "uidNumber",
|
||||||
Values: []string{ pi.GetUidNumber(u) },
|
Values: []string{pi.GetUidNumber(u)},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "gidNumber",
|
Name: "gidNumber",
|
||||||
Values: []string{ pi.GetUidNumber(u) },
|
Values: []string{pi.GetUidNumber(u)},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,11 +144,11 @@ func (pi *ProviderInstance) GroupEntry(g LDAPGroup) *ldap.Entry {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "gidNumber",
|
Name: "gidNumber",
|
||||||
Values: []string{ g.gidNumber },
|
Values: []string{g.gidNumber},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g.isVirtualGroup) {
|
if g.isVirtualGroup {
|
||||||
attrs = append(attrs, &ldap.EntryAttribute{
|
attrs = append(attrs, &ldap.EntryAttribute{
|
||||||
Name: "objectClass",
|
Name: "objectClass",
|
||||||
Values: []string{GroupObjectClass, "goauthentik.io/ldap/group", "goauthentik.io/ldap/virtual-group"},
|
Values: []string{GroupObjectClass, "goauthentik.io/ldap/group", "goauthentik.io/ldap/virtual-group"},
|
||||||
|
@ -163,7 +163,7 @@ func (pi *ProviderInstance) GroupEntry(g LDAPGroup) *ldap.Entry {
|
||||||
attrs = append(attrs, &ldap.EntryAttribute{Name: "member", Values: g.member})
|
attrs = append(attrs, &ldap.EntryAttribute{Name: "member", Values: g.member})
|
||||||
attrs = append(attrs, &ldap.EntryAttribute{Name: "goauthentik.io/ldap/superuser", Values: []string{BoolToString(g.isSuperuser)}})
|
attrs = append(attrs, &ldap.EntryAttribute{Name: "goauthentik.io/ldap/superuser", Values: []string{BoolToString(g.isSuperuser)}})
|
||||||
|
|
||||||
if (g.akAttributes != nil) {
|
if g.akAttributes != nil {
|
||||||
attrs = append(attrs, AKAttrsToLDAP(g.akAttributes)...)
|
attrs = append(attrs, AKAttrsToLDAP(g.akAttributes)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,11 +115,11 @@ func (pi *ProviderInstance) GetGroupDN(group string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pi *ProviderInstance) GetUidNumber(user api.User) string {
|
func (pi *ProviderInstance) GetUidNumber(user api.User) string {
|
||||||
return strconv.FormatInt(int64(pi.uidStartNumber + user.Pk), 10)
|
return strconv.FormatInt(int64(pi.uidStartNumber+user.Pk), 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pi *ProviderInstance) GetGidNumber(group api.Group) string {
|
func (pi *ProviderInstance) GetGidNumber(group api.Group) string {
|
||||||
return strconv.FormatInt(int64(pi.gidStartNumber + pi.GetRIDForGroup(group.Pk)), 10)
|
return strconv.FormatInt(int64(pi.gidStartNumber+pi.GetRIDForGroup(group.Pk)), 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pi *ProviderInstance) GetRIDForGroup(uid string) int32 {
|
func (pi *ProviderInstance) GetRIDForGroup(uid string) int32 {
|
||||||
|
|
Reference in a new issue