diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-05-05 16:42:15 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-05-05 16:42:15 +0800 |
commit | d8136c9c3cf0f7d84510402f01cbe07a656a0587 (patch) | |
tree | 2a1a7553a111a008a0322625c30130ca952b6acd /modules | |
parent | 02687cbdf37be3c89005abe45c7d1f6240e339e0 (diff) | |
parent | 1652dd5068f2f3ae1851bc2321832c88af85d570 (diff) | |
download | gitea-d8136c9c3cf0f7d84510402f01cbe07a656a0587.tar.gz gitea-d8136c9c3cf0f7d84510402f01cbe07a656a0587.zip |
Merge branch 'dev-ldap' into dev
Diffstat (limited to 'modules')
-rw-r--r-- | modules/auth/admin.go | 13 | ||||
-rw-r--r-- | modules/auth/auth.go | 1 | ||||
-rw-r--r-- | modules/auth/authentication.go | 15 | ||||
-rw-r--r-- | modules/auth/ldap/ldap.go | 9 |
4 files changed, 28 insertions, 10 deletions
diff --git a/modules/auth/admin.go b/modules/auth/admin.go index 51c1b78cc7..c82fa78150 100644 --- a/modules/auth/admin.go +++ b/modules/auth/admin.go @@ -16,12 +16,13 @@ import ( ) type AdminEditUserForm struct { - Email string `form:"email" binding:"Required;Email;MaxSize(50)"` - Website string `form:"website" binding:"MaxSize(50)"` - Location string `form:"location" binding:"MaxSize(50)"` - Avatar string `form:"avatar" binding:"Required;Email;MaxSize(50)"` - Active string `form:"active"` - Admin string `form:"admin"` + Email string `form:"email" binding:"Required;Email;MaxSize(50)"` + Website string `form:"website" binding:"MaxSize(50)"` + Location string `form:"location" binding:"MaxSize(50)"` + Avatar string `form:"avatar" binding:"Required;Email;MaxSize(50)"` + Active string `form:"active"` + Admin string `form:"admin"` + LoginType int `form:"login_type"` } func (f *AdminEditUserForm) Name(field string) string { diff --git a/modules/auth/auth.go b/modules/auth/auth.go index 8f7deaa309..2f77349177 100644 --- a/modules/auth/auth.go +++ b/modules/auth/auth.go @@ -26,6 +26,7 @@ type RegisterForm struct { Email string `form:"email" binding:"Required;Email;MaxSize(50)"` Password string `form:"passwd" binding:"Required;MinSize(6);MaxSize(30)"` RetypePasswd string `form:"retypepasswd"` + LoginType string `form:"logintype"` } func (f *RegisterForm) Name(field string) string { diff --git a/modules/auth/authentication.go b/modules/auth/authentication.go new file mode 100644 index 0000000000..d9c61b9d79 --- /dev/null +++ b/modules/auth/authentication.go @@ -0,0 +1,15 @@ +package auth + +type AuthenticationForm struct { + Id int64 `form:"id"` + Type int `form:"type"` + Name string `form:"name" binding:"MaxSize(50)"` + Domain string `form:"domain"` + Host string `form:"host"` + Port int `form:"port"` + BaseDN string `form:"base_dn"` + Attributes string `form:"attributes"` + Filter string `form:"filter"` + MsAdSA string `form:"ms_ad_sa"` + IsActived bool `form:"is_actived"` +} diff --git a/modules/auth/ldap/ldap.go b/modules/auth/ldap/ldap.go index 29773cda5c..8578e38a4d 100644 --- a/modules/auth/ldap/ldap.go +++ b/modules/auth/ldap/ldap.go @@ -8,12 +8,13 @@ package ldap import ( "fmt" + "github.com/gogits/gogs/modules/log" goldap "github.com/juju2013/goldap" ) // Basic LDAP authentication service -type ldapsource struct { +type Ldapsource struct { Name string // canonical name (ie. corporate.ad) Host string // LDAP host Port int // port number @@ -26,12 +27,12 @@ type ldapsource struct { //Global LDAP directory pool var ( - Authensource []ldapsource + Authensource []Ldapsource ) // Add a new source (LDAP directory) to the global pool func AddSource(name string, host string, port int, basedn string, attributes string, filter string, msadsaformat string) { - ldaphost := ldapsource{name, host, port, basedn, attributes, filter, msadsaformat, true} + ldaphost := Ldapsource{name, host, port, basedn, attributes, filter, msadsaformat, true} Authensource = append(Authensource, ldaphost) } @@ -50,7 +51,7 @@ func LoginUser(name, passwd string) (a string, r bool) { } // searchEntry : search an LDAP source if an entry (name, passwd) is valide and in the specific filter -func (ls ldapsource) searchEntry(name, passwd string) (string, bool) { +func (ls Ldapsource) searchEntry(name, passwd string) (string, bool) { l, err := goldap.Dial("tcp", fmt.Sprintf("%s:%d", ls.Host, ls.Port)) if err != nil { log.Debug("LDAP Connect error, disabled source %s", ls.Host) |