set config file

This commit is contained in:
2019-11-27 12:09:15 +01:00
parent 68eb55d8a7
commit 86c2cf49f0
9 changed files with 103 additions and 15 deletions

View File

@ -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()