mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-25 04:49:05 +01:00
Fix errors in ldap auth
This commit is contained in:
parent
202521cbfd
commit
4f6d1fec68
@ -158,12 +158,13 @@ func Init(db *sqlx.DB,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if config, ok := configs["ldap"]; ok {
|
if config, ok := configs["ldap"]; ok {
|
||||||
auth.LdapAuth = &LdapAuthenticator{}
|
ldapAuth := &LdapAuthenticator{}
|
||||||
if err := auth.LdapAuth.Init(auth, config); err != nil {
|
if err := ldapAuth.Init(auth, config); err != nil {
|
||||||
log.Error("Error while initializing authentication -> ldapAuth init failed")
|
log.Warn("Error while initializing authentication -> ldapAuth init failed")
|
||||||
return nil, err
|
} else {
|
||||||
|
auth.LdapAuth = ldapAuth
|
||||||
|
auth.authenticators = append(auth.authenticators, auth.LdapAuth)
|
||||||
}
|
}
|
||||||
auth.authenticators = append(auth.authenticators, auth.LdapAuth)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jwtSessionAuth := &JWTSessionAuthenticator{}
|
jwtSessionAuth := &JWTSessionAuthenticator{}
|
||||||
@ -174,7 +175,7 @@ func Init(db *sqlx.DB,
|
|||||||
}
|
}
|
||||||
|
|
||||||
jwtCookieSessionAuth := &JWTCookieSessionAuthenticator{}
|
jwtCookieSessionAuth := &JWTCookieSessionAuthenticator{}
|
||||||
if err := jwtSessionAuth.Init(auth, configs["jwt"]); err != nil {
|
if err := jwtCookieSessionAuth.Init(auth, configs["jwt"]); err != nil {
|
||||||
log.Warn("Error while initializing authentication -> jwtCookieSessionAuth init failed")
|
log.Warn("Error while initializing authentication -> jwtCookieSessionAuth init failed")
|
||||||
} else {
|
} else {
|
||||||
auth.authenticators = append(auth.authenticators, jwtCookieSessionAuth)
|
auth.authenticators = append(auth.authenticators, jwtCookieSessionAuth)
|
||||||
|
@ -59,6 +59,8 @@ func (la *LdapAuthenticator) Init(
|
|||||||
log.Print("sync done")
|
log.Print("sync done")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("missing LDAP configuration")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -73,7 +75,7 @@ func (la *LdapAuthenticator) CanLogin(
|
|||||||
if user != nil && user.AuthSource == AuthViaLDAP {
|
if user != nil && user.AuthSource == AuthViaLDAP {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
if la.config.SyncUserOnLogin {
|
if la.config != nil && la.config.SyncUserOnLogin {
|
||||||
l, err := la.getLdapConnection(true)
|
l, err := la.getLdapConnection(true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("LDAP connection error")
|
log.Error("LDAP connection error")
|
||||||
|
Loading…
Reference in New Issue
Block a user