Have LDAP read from config
This commit is contained in:
No files matched your search
@@ -27,6 +27,7 @@ import (
|
||||
"go.senan.xyz/gonic/db"
|
||||
"go.senan.xyz/gonic/handlerutil"
|
||||
"go.senan.xyz/gonic/lastfm"
|
||||
"go.senan.xyz/gonic/ldap"
|
||||
"go.senan.xyz/gonic/podcast"
|
||||
"go.senan.xyz/gonic/scanner"
|
||||
"go.senan.xyz/gonic/server/ctrladmin/adminui"
|
||||
@@ -48,11 +49,12 @@ type Controller struct {
|
||||
podcasts *podcast.Podcasts
|
||||
lastfmClient *lastfm.Client
|
||||
resolveProxyPath ProxyPathResolver
|
||||
ldapConfig ldap.Config
|
||||
}
|
||||
|
||||
type ProxyPathResolver func(in string) string
|
||||
|
||||
func New(dbc *db.DB, sessDB *gormstore.Store, scanner *scanner.Scanner, podcasts *podcast.Podcasts, lastfmClient *lastfm.Client, resolveProxyPath ProxyPathResolver) (*Controller, error) {
|
||||
func New(dbc *db.DB, sessDB *gormstore.Store, scanner *scanner.Scanner, podcasts *podcast.Podcasts, lastfmClient *lastfm.Client, resolveProxyPath ProxyPathResolver, ldapConfig ldap.Config) (*Controller, error) {
|
||||
c := Controller{
|
||||
ServeMux: http.NewServeMux(),
|
||||
|
||||
@@ -62,6 +64,7 @@ func New(dbc *db.DB, sessDB *gormstore.Store, scanner *scanner.Scanner, podcasts
|
||||
podcasts: podcasts,
|
||||
lastfmClient: lastfmClient,
|
||||
resolveProxyPath: resolveProxyPath,
|
||||
ldapConfig: ldapConfig,
|
||||
}
|
||||
|
||||
resp := respHandler(adminui.TemplatesFS, resolveProxyPath)
|
||||
|
||||
@@ -21,7 +21,7 @@ func (c *Controller) ServeLoginDo(w http.ResponseWriter, r *http.Request) {
|
||||
if user == nil || password != user.Password {
|
||||
// Because internal authentication failed, we can now try to use LDAP, if
|
||||
// it was enabled by the user.
|
||||
ok, err := ldap.CheckLDAPcreds(username, password, c.dbc)
|
||||
ok, err := ldap.CheckLDAPcreds(username, password, c.dbc, c.ldapConfig)
|
||||
if err != nil {
|
||||
sessAddFlashW(session, []string{err.Error()})
|
||||
} else if !ok {
|
||||
|
||||
Reference in New Issue
Block a user