summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-09-14 15:48:51 -0400
committerUnknwon <u@gogs.io>2015-09-14 15:48:51 -0400
commitf5c7f22cc8595a81b5d9f9da4a0a29faf2dbbdce (patch)
treeaf338ee4d3f7ca0edec0f8e1159b52d69da5f912 /models
parent2bc3e83e1ce89a6c250116216a93da3a401127db (diff)
downloadgitea-f5c7f22cc8595a81b5d9f9da4a0a29faf2dbbdce.tar.gz
gitea-f5c7f22cc8595a81b5d9f9da4a0a29faf2dbbdce.zip
#1637 able to skip verify for LDAP
Diffstat (limited to 'models')
-rw-r--r--models/login.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/models/login.go b/models/login.go
index 1b7ecdf417..79a262c575 100644
--- a/models/login.go
+++ b/models/login.go
@@ -55,15 +55,15 @@ var (
)
type LDAPConfig struct {
- ldap.Ldapsource
+ *ldap.Source
}
func (cfg *LDAPConfig) FromDB(bs []byte) error {
- return json.Unmarshal(bs, &cfg.Ldapsource)
+ return json.Unmarshal(bs, &cfg)
}
func (cfg *LDAPConfig) ToDB() ([]byte, error) {
- return json.Marshal(cfg.Ldapsource)
+ return json.Marshal(cfg)
}
type SMTPConfig struct {
@@ -152,6 +152,17 @@ func (source *LoginSource) UseTLS() bool {
return false
}
+func (source *LoginSource) SkipVerify() bool {
+ switch source.Type {
+ case LDAP, DLDAP:
+ return source.LDAP().SkipVerify
+ case SMTP:
+ return source.SMTP().SkipVerify
+ }
+
+ return false
+}
+
func (source *LoginSource) LDAP() *LDAPConfig {
return source.Cfg.(*LDAPConfig)
}
@@ -221,7 +232,7 @@ func DeleteSource(source *LoginSource) error {
func LoginUserLDAPSource(u *User, name, passwd string, source *LoginSource, autoRegister bool) (*User, error) {
cfg := source.Cfg.(*LDAPConfig)
directBind := (source.Type == DLDAP)
- fn, sn, mail, admin, logged := cfg.Ldapsource.SearchEntry(name, passwd, directBind)
+ fn, sn, mail, admin, logged := cfg.SearchEntry(name, passwd, directBind)
if !logged {
// User not in LDAP, do nothing
return nil, ErrUserNotExist{0, name}