set config file
This commit is contained in:
24
auth/auth.go
24
auth/auth.go
@ -1,24 +1,34 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"cadoles/foodoles/config"
|
||||
"log"
|
||||
|
||||
"github.com/jtblin/go-ldap-client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// LogIn auth the client
|
||||
func LogIn(username string, password string) (ok bool, user map[string]string) {
|
||||
|
||||
var configFile = "../server.conf"
|
||||
var conf *config.Config
|
||||
var conferr error
|
||||
conf, conferr = config.NewFromFile(configFile)
|
||||
if conferr != nil {
|
||||
panic(errors.Wrapf(conferr, "error while loading config file '%s'", configFile))
|
||||
}
|
||||
|
||||
ldapclient := &ldap.LDAPClient{
|
||||
Base: "o=gouv,c=fr",
|
||||
Host: "ldap.cadoles.com",
|
||||
Port: 389,
|
||||
Base: conf.LDAP.Base,
|
||||
Host: conf.LDAP.Host,
|
||||
Port: conf.LDAP.Port,
|
||||
UseSSL: false,
|
||||
BindDN: "cn=reader,o=gouv,c=fr",
|
||||
BindPassword: "ohc7kei8lil8Zoesai5chisaiGhu5Yaisai6kaegh9aingai0pae8ohb",
|
||||
UserFilter: "(uid=%s)",
|
||||
BindDN: conf.LDAP.BindDN,
|
||||
BindPassword: conf.LDAP.BindPassword,
|
||||
UserFilter: conf.LDAP.UserFilter,
|
||||
GroupFilter: "(memberUid=%s)",
|
||||
Attributes: []string{"uid", "mail"},
|
||||
Attributes: conf.LDAP.Attributes,
|
||||
}
|
||||
defer ldapclient.Close()
|
||||
|
||||
|
Reference in New Issue
Block a user