mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-02-11 21:41:46 +01:00
Renaming due to linter complaints
This commit is contained in:
@@ -26,7 +26,7 @@ type LdapConfig struct {
|
|||||||
UserBind string `json:"user-bind"`
|
UserBind string `json:"user-bind"`
|
||||||
UserFilter string `json:"user-filter"`
|
UserFilter string `json:"user-filter"`
|
||||||
UserAttr string `json:"username-attr"`
|
UserAttr string `json:"username-attr"`
|
||||||
UidAttr string `json:"uid-attr"`
|
UIDAttr string `json:"uid-attr"`
|
||||||
SyncInterval string `json:"sync-interval"` // Parsed using time.ParseDuration.
|
SyncInterval string `json:"sync-interval"` // Parsed using time.ParseDuration.
|
||||||
SyncDelOldUsers bool `json:"sync-del-old-users"`
|
SyncDelOldUsers bool `json:"sync-del-old-users"`
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ type LdapConfig struct {
|
|||||||
type LdapAuthenticator struct {
|
type LdapAuthenticator struct {
|
||||||
syncPassword string
|
syncPassword string
|
||||||
UserAttr string
|
UserAttr string
|
||||||
UidAttr string
|
UIDAttr string
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ Authenticator = (*LdapAuthenticator)(nil)
|
var _ Authenticator = (*LdapAuthenticator)(nil)
|
||||||
@@ -55,10 +55,10 @@ func (la *LdapAuthenticator) Init() error {
|
|||||||
la.UserAttr = "gecos"
|
la.UserAttr = "gecos"
|
||||||
}
|
}
|
||||||
|
|
||||||
if Keys.LdapConfig.UidAttr != "" {
|
if Keys.LdapConfig.UIDAttr != "" {
|
||||||
la.UidAttr = Keys.LdapConfig.UidAttr
|
la.UIDAttr = Keys.LdapConfig.UIDAttr
|
||||||
} else {
|
} else {
|
||||||
la.UidAttr = "uid"
|
la.UIDAttr = "uid"
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -88,8 +88,8 @@ func (la *LdapAuthenticator) CanLogin(
|
|||||||
searchRequest := ldap.NewSearchRequest(
|
searchRequest := ldap.NewSearchRequest(
|
||||||
lc.UserBase,
|
lc.UserBase,
|
||||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||||
fmt.Sprintf("(&%s(%s=%s))", lc.UserFilter, la.UidAttr, ldap.EscapeFilter(username)),
|
fmt.Sprintf("(&%s(%s=%s))", lc.UserFilter, la.UIDAttr, ldap.EscapeFilter(username)),
|
||||||
[]string{"dn", la.UidAttr, la.UserAttr}, nil)
|
[]string{"dn", la.UIDAttr, la.UserAttr}, nil)
|
||||||
|
|
||||||
sr, err := l.Search(searchRequest)
|
sr, err := l.Search(searchRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -169,7 +169,7 @@ func (la *LdapAuthenticator) Sync() error {
|
|||||||
lc.UserBase,
|
lc.UserBase,
|
||||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||||
lc.UserFilter,
|
lc.UserFilter,
|
||||||
[]string{"dn", la.UidAttr, la.UserAttr}, nil))
|
[]string{"dn", la.UIDAttr, la.UserAttr}, nil))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.Warn("LDAP search error")
|
cclog.Warn("LDAP search error")
|
||||||
return err
|
return err
|
||||||
@@ -177,9 +177,9 @@ func (la *LdapAuthenticator) Sync() error {
|
|||||||
|
|
||||||
newnames := map[string]string{}
|
newnames := map[string]string{}
|
||||||
for _, entry := range ldapResults.Entries {
|
for _, entry := range ldapResults.Entries {
|
||||||
username := entry.GetAttributeValue(la.UidAttr)
|
username := entry.GetAttributeValue(la.UIDAttr)
|
||||||
if username == "" {
|
if username == "" {
|
||||||
return fmt.Errorf("no attribute '%s'", la.UidAttr)
|
return fmt.Errorf("no attribute '%s'", la.UIDAttr)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, ok := users[username]
|
_, ok := users[username]
|
||||||
|
|||||||
Reference in New Issue
Block a user