diff options
author | 无闻 <joe2010xtmf@163.com> | 2014-04-24 14:25:56 -0600 |
---|---|---|
committer | 无闻 <joe2010xtmf@163.com> | 2014-04-24 14:25:56 -0600 |
commit | 37cbfc032a6dc92293401622977f3076c710fed9 (patch) | |
tree | 8a7613699d3ab8eebdedb2945485b2e677ea4a52 /modules/base | |
parent | 5898d562055085d62da8129442b01cd71443163a (diff) | |
parent | efc05ea1dec5a60c95763fc5158d60b45ef46d8f (diff) | |
download | gitea-37cbfc032a6dc92293401622977f3076c710fed9.tar.gz gitea-37cbfc032a6dc92293401622977f3076c710fed9.zip |
Merge pull request #112 from juju2013/master
basic support for LDAP/Microsoft Active Directory authentication
Diffstat (limited to 'modules/base')
-rw-r--r-- | modules/base/conf.go | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/modules/base/conf.go b/modules/base/conf.go index abb67f6d8f..5724504503 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -10,6 +10,7 @@ import ( "os/exec" "path" "path/filepath" + "regexp" "strings" "github.com/Unknwon/com" @@ -19,6 +20,7 @@ import ( "github.com/gogits/cache" "github.com/gogits/session" + "github.com/gogits/gogs/modules/auth/ldap" "github.com/gogits/gogs/modules/log" ) @@ -51,6 +53,7 @@ var ( Domain string SecretKey string RunUser string + LdapAuth bool RepoRootPath string ScriptType string @@ -83,13 +86,13 @@ var ( ) var Service struct { - RegisterEmailConfirm bool - DisableRegistration bool - RequireSignInView bool - EnableCacheAvatar bool - NotifyMail bool - ActiveCodeLives int - ResetPwdCodeLives int + RegisterEmailConfirm bool + DisableRegistration bool + RequireSignInView bool + EnableCacheAvatar bool + NotifyMail bool + ActiveCodeLives int + ResetPwdCodeLives int } func ExecDir() (string, error) { @@ -310,6 +313,33 @@ func NewConfigContext() { CookieUserName = Cfg.MustValue("security", "COOKIE_USERNAME") CookieRememberName = Cfg.MustValue("security", "COOKIE_REMEMBER_NAME") + // load LDAP authentication configuration if present + LdapAuth = Cfg.MustBool("security", "LDAP_AUTH", false) + if LdapAuth { + log.Debug("LDAP AUTHENTICATION activated") + nbsrc := 0 + for _, v := range Cfg.GetSectionList() { + if matched, _ := regexp.MatchString("(?i)^LDAPSOURCE.*", v); matched { + ldapname := Cfg.MustValue(v, "name", v) + ldaphost := Cfg.MustValue(v, "host") + ldapport := Cfg.MustInt(v, "port", 389) + ldapbasedn := Cfg.MustValue(v, "basedn", "dc=*,dc=*") + ldapattribute := Cfg.MustValue(v, "attribute", "mail") + ldapfilter := Cfg.MustValue(v, "filter", "(*)") + ldapmsadsaformat := Cfg.MustValue(v, "MSADSAFORMAT", "%s") + ldap.AddSource(ldapname, ldaphost, ldapport, ldapbasedn, ldapattribute, ldapfilter, ldapmsadsaformat) + nbsrc += 1 + log.Debug("%s added as LDAP source", ldapname) + } + } + if nbsrc == 0 { + log.Debug("No valide LDAP found, LDAP AUTHENTICATION NOT activated") + LdapAuth = false + } + } else { + log.Debug("LDAP AUTHENTICATION NOT activated") + } + PictureService = Cfg.MustValue("picture", "SERVICE") // Determine and create root git reposiroty path. |