mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-07-04 17:06:49 +00:00
Adds LDAP auth support
This commit is contained in:
20
backend/internal/entity/setting/auth_methods.go
Normal file
20
backend/internal/entity/setting/auth_methods.go
Normal file
@ -0,0 +1,20 @@
|
||||
package setting
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// GetAuthMethods returns the authentication methods enabled for this site
|
||||
func GetAuthMethods() ([]string, error) {
|
||||
var l []string
|
||||
var m Model
|
||||
if err := m.LoadByName("auth-methods"); err != nil {
|
||||
return l, err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal([]byte(m.Value.String()), &l); err != nil {
|
||||
return l, err
|
||||
}
|
||||
|
||||
return l, nil
|
||||
}
|
32
backend/internal/entity/setting/ldap.go
Normal file
32
backend/internal/entity/setting/ldap.go
Normal file
@ -0,0 +1,32 @@
|
||||
package setting
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// LDAPSettings are the settings for LDAP that come from
|
||||
// the `ldap-auth` setting value
|
||||
type LDAPSettings struct {
|
||||
Host string `json:"host"`
|
||||
BaseDN string `json:"base_dn"`
|
||||
UserDN string `json:"user_dn"`
|
||||
EmailProperty string `json:"email_property"`
|
||||
NameProperty string `json:"name_property"`
|
||||
SelfFilter string `json:"self_filter"`
|
||||
AutoCreateUser bool `json:"auto_create_user"`
|
||||
}
|
||||
|
||||
// GetLDAPSettings will return the LDAP settings
|
||||
func GetLDAPSettings() (LDAPSettings, error) {
|
||||
var l LDAPSettings
|
||||
var m Model
|
||||
if err := m.LoadByName("ldap-auth"); err != nil {
|
||||
return l, err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal([]byte(m.Value.String()), &l); err != nil {
|
||||
return l, err
|
||||
}
|
||||
|
||||
return l, nil
|
||||
}
|
Reference in New Issue
Block a user