minor change to realm handling
This commit is contained in:
+8
-3
@@ -87,8 +87,10 @@ func Run() {
|
|||||||
}
|
}
|
||||||
userbackends.PVE = PVEClient
|
userbackends.PVE = PVEClient
|
||||||
|
|
||||||
// bind ldap backend if backend is ldap
|
// bind backend by type
|
||||||
if handler == "ldap" {
|
switch handler {
|
||||||
|
case "pve":
|
||||||
|
case "ldap":
|
||||||
config := Realms[body.Username.Realm].Config.(common.LDAPConfig)
|
config := Realms[body.Username.Realm].Config.(common.LDAPConfig)
|
||||||
LDAPClient, code, err := ldap.NewClientFromCredentials(config, body.Username, body.Password)
|
LDAPClient, code, err := ldap.NewClientFromCredentials(config, body.Username, body.Password)
|
||||||
if err != nil { // ldap client failed to bind
|
if err != nil { // ldap client failed to bind
|
||||||
@@ -97,6 +99,9 @@ func Run() {
|
|||||||
}
|
}
|
||||||
userbackends.Realm.Name = body.Username.Realm
|
userbackends.Realm.Name = body.Username.Realm
|
||||||
userbackends.Realm.Handler = LDAPClient
|
userbackends.Realm.Handler = LDAPClient
|
||||||
|
default:
|
||||||
|
c.JSON(code, gin.H{"auth": false, "error": fmt.Errorf("user realm %s is not supported", body.Username.Realm)})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
userbackends.DB = &db
|
userbackends.DB = &db
|
||||||
@@ -580,7 +585,7 @@ func GetRealmsFromPVE(config *common.Config) map[string]Realm {
|
|||||||
}
|
}
|
||||||
log.Printf("Configured default authentication realm pve")
|
log.Printf("Configured default authentication realm pve")
|
||||||
|
|
||||||
// iterate through handlers and
|
// iterate through handlers and add to realms
|
||||||
for _, r := range pverealms {
|
for _, r := range pverealms {
|
||||||
realm, err := client.Domain(context.Background(), r.Realm)
|
realm, err := client.Domain(context.Background(), r.Realm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user