#1542 A way to skip TLS verify for SMTP authentication

This commit is contained in:
Unknwon committed 2015-08-29 15:45:58 +08:00
1 parent 384fbeca80
commit ea454c21f7
9 files changed
+106 -89

No files matched your search

+1
View File
@@ -794,6 +794,7 @@ auths.smtp_auth = SMTP Authorization Type
auths.smtphost = SMTP Host auths.smtphost = SMTP Host
auths.smtpport = SMTP Port auths.smtpport = SMTP Port
auths.enable_tls = Enable TLS Encryption auths.enable_tls = Enable TLS Encryption
auths.skip_tls_verify = Skip TLS Verify
auths.pam_service_name = PAM Service Name auths.pam_service_name = PAM Service Name
auths.enable_auto_register = Enable Auto Registration auths.enable_auto_register = Enable Auto Registration
auths.tips = Tips auths.tips = Tips
+45 -40
View File
@@ -63,10 +63,11 @@ func (cfg *LDAPConfig) ToDB() ([]byte, error) {
} }
type SMTPConfig struct { type SMTPConfig struct {
Auth string Auth string
Host string Host string
Port int Port int
TLS bool TLS bool
SkipVerify bool
} }
func (cfg *SMTPConfig) FromDB(bs []byte) error { func (cfg *SMTPConfig) FromDB(bs []byte) error {
@@ -90,7 +91,7 @@ func (cfg *PAMConfig) ToDB() ([]byte, error) {
} }
type LoginSource struct { type LoginSource struct {
Id int64 ID int64 `xorm:"pk autoincr"`
Type LoginType Type LoginType
Name string `xorm:"UNIQUE"` Name string `xorm:"UNIQUE"`
IsActived bool `xorm:"NOT NULL DEFAULT false"` IsActived bool `xorm:"NOT NULL DEFAULT false"`
@@ -100,6 +101,20 @@ type LoginSource struct {
Updated time.Time `xorm:"UPDATED"` Updated time.Time `xorm:"UPDATED"`
} }
func (source *LoginSource) BeforeSet(colName string, val xorm.Cell) {
switch colName {
case "type":
switch LoginType((*val).(int64)) {
case LDAP:
source.Cfg = new(LDAPConfig)
case SMTP:
source.Cfg = new(SMTPConfig)
case PAM:
source.Cfg = new(PAMConfig)
}
}
}
func (source *LoginSource) TypeString() string { func (source *LoginSource) TypeString() string {
return LoginTypes[source.Type] return LoginTypes[source.Type]
} }
@@ -116,32 +131,17 @@ func (source *LoginSource) PAM() *PAMConfig {
return source.Cfg.(*PAMConfig) return source.Cfg.(*PAMConfig)
} }
func (source *LoginSource) BeforeSet(colName string, val xorm.Cell) {
if colName == "type" {
ty := (*val).(int64)
switch LoginType(ty) {
case LDAP:
source.Cfg = new(LDAPConfig)
case SMTP:
source.Cfg = new(SMTPConfig)
case PAM:
source.Cfg = new(PAMConfig)
}
}
}
func CreateSource(source *LoginSource) error { func CreateSource(source *LoginSource) error {
_, err := x.Insert(source) _, err := x.Insert(source)
return err return err
} }
func GetAuths() ([]*LoginSource, error) { func GetAuths() ([]*LoginSource, error) {
var auths = make([]*LoginSource, 0, 5) auths := make([]*LoginSource, 0, 5)
err := x.Find(&auths) return auths, x.Find(&auths)
return auths, err
} }
func GetLoginSourceById(id int64) (*LoginSource, error) { func GetLoginSourceByID(id int64) (*LoginSource, error) {
source := new(LoginSource) source := new(LoginSource)
has, err := x.Id(id).Get(source) has, err := x.Id(id).Get(source)
if err != nil { if err != nil {
@@ -153,19 +153,19 @@ func GetLoginSourceById(id int64) (*LoginSource, error) {
} }
func UpdateSource(source *LoginSource) error { func UpdateSource(source *LoginSource) error {
_, err := x.Id(source.Id).AllCols().Update(source) _, err := x.Id(source.ID).AllCols().Update(source)
return err return err
} }
func DelLoginSource(source *LoginSource) error { func DelLoginSource(source *LoginSource) error {
cnt, err := x.Count(&User{LoginSource: source.Id}) cnt, err := x.Count(&User{LoginSource: source.ID})
if err != nil { if err != nil {
return err return err
} }
if cnt > 0 { if cnt > 0 {
return ErrAuthenticationUserUsed return ErrAuthenticationUserUsed
} }
_, err = x.Id(source.Id).Delete(&LoginSource{}) _, err = x.Id(source.ID).Delete(&LoginSource{})
return err return err
} }
@@ -206,21 +206,21 @@ func UserSignIn(uname, passwd string) (*User, error) {
for _, source := range sources { for _, source := range sources {
if source.Type == LDAP { if source.Type == LDAP {
u, err := LoginUserLdapSource(nil, uname, passwd, u, err := LoginUserLdapSource(nil, uname, passwd,
source.Id, source.Cfg.(*LDAPConfig), true) source.ID, source.Cfg.(*LDAPConfig), true)
if err == nil { if err == nil {
return u, nil return u, nil
} }
log.Warn("Fail to login(%s) by LDAP(%s): %v", uname, source.Name, err) log.Warn("Fail to login(%s) by LDAP(%s): %v", uname, source.Name, err)
} else if source.Type == SMTP { } else if source.Type == SMTP {
u, err := LoginUserSMTPSource(nil, uname, passwd, u, err := LoginUserSMTPSource(nil, uname, passwd,
source.Id, source.Cfg.(*SMTPConfig), true) source.ID, source.Cfg.(*SMTPConfig), true)
if err == nil { if err == nil {
return u, nil return u, nil
} }
log.Warn("Fail to login(%s) by SMTP(%s): %v", uname, source.Name, err) log.Warn("Fail to login(%s) by SMTP(%s): %v", uname, source.Name, err)
} else if source.Type == PAM { } else if source.Type == PAM {
u, err := LoginUserPAMSource(nil, uname, passwd, u, err := LoginUserPAMSource(nil, uname, passwd,
source.Id, source.Cfg.(*PAMConfig), true) source.ID, source.Cfg.(*PAMConfig), true)
if err == nil { if err == nil {
return u, nil return u, nil
} }
@@ -243,11 +243,11 @@ func UserSignIn(uname, passwd string) (*User, error) {
switch u.LoginType { switch u.LoginType {
case LDAP: case LDAP:
return LoginUserLdapSource(u, u.LoginName, passwd, source.Id, source.Cfg.(*LDAPConfig), false) return LoginUserLdapSource(u, u.LoginName, passwd, source.ID, source.Cfg.(*LDAPConfig), false)
case SMTP: case SMTP:
return LoginUserSMTPSource(u, u.LoginName, passwd, source.Id, source.Cfg.(*SMTPConfig), false) return LoginUserSMTPSource(u, u.LoginName, passwd, source.ID, source.Cfg.(*SMTPConfig), false)
case PAM: case PAM:
return LoginUserPAMSource(u, u.LoginName, passwd, source.Id, source.Cfg.(*PAMConfig), false) return LoginUserPAMSource(u, u.LoginName, passwd, source.ID, source.Cfg.(*PAMConfig), false)
} }
return nil, ErrUnsupportedLoginType return nil, ErrUnsupportedLoginType
} }
@@ -311,14 +311,17 @@ func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) {
return nil, nil return nil, nil
} }
var ( const (
SMTP_PLAIN = "PLAIN" SMTP_PLAIN = "PLAIN"
SMTP_LOGIN = "LOGIN" SMTP_LOGIN = "LOGIN"
SMTPAuths = []string{SMTP_PLAIN, SMTP_LOGIN}
) )
func SmtpAuth(host string, port int, a smtp.Auth, useTls bool) error { var (
c, err := smtp.Dial(fmt.Sprintf("%s:%d", host, port)) SMTPAuths = []string{SMTP_PLAIN, SMTP_LOGIN}
)
func SMTPAuth(a smtp.Auth, cfg *SMTPConfig) error {
c, err := smtp.Dial(fmt.Sprintf("%s:%d", cfg.Host, cfg.Port))
if err != nil { if err != nil {
return err return err
} }
@@ -328,10 +331,12 @@ func SmtpAuth(host string, port int, a smtp.Auth, useTls bool) error {
return err return err
} }
if useTls { if cfg.TLS {
if ok, _ := c.Extension("STARTTLS"); ok { if ok, _ := c.Extension("STARTTLS"); ok {
config := &tls.Config{ServerName: host} if err = c.StartTLS(&tls.Config{
if err = c.StartTLS(config); err != nil { InsecureSkipVerify: cfg.SkipVerify,
ServerName: cfg.Host,
}); err != nil {
return err return err
} }
} else { } else {
@@ -361,7 +366,7 @@ func LoginUserSMTPSource(u *User, name, passwd string, sourceId int64, cfg *SMTP
return nil, errors.New("Unsupported SMTP auth type") return nil, errors.New("Unsupported SMTP auth type")
} }
if err := SmtpAuth(cfg.Host, cfg.Port, auth, cfg.TLS); err != nil { if err := SMTPAuth(auth, cfg); err != nil {
if strings.Contains(err.Error(), "Username and Password not accepted") { if strings.Contains(err.Error(), "Username and Password not accepted") {
return nil, ErrUserNotExist{u.Id, u.Name} return nil, ErrUserNotExist{u.Id, u.Name}
} }
+4 -4
View File
@@ -48,10 +48,6 @@ var (
Gitignores, Licenses, Readmes []string Gitignores, Licenses, Readmes []string
) )
var (
DescPattern = regexp.MustCompile(`https?://\S+`)
)
func LoadRepoConfig() { func LoadRepoConfig() {
// Load .gitignore and license files and readme templates. // Load .gitignore and license files and readme templates.
types := []string{"gitignore", "license", "readme"} types := []string{"gitignore", "license", "readme"}
@@ -266,6 +262,10 @@ func (repo *Repository) IsOwnedBy(userID int64) bool {
return repo.OwnerID == userID return repo.OwnerID == userID
} }
var (
DescPattern = regexp.MustCompile(`https?://\S+`)
)
// DescriptionHtml does special handles to description and return HTML string. // DescriptionHtml does special handles to description and return HTML string.
func (repo *Repository) DescriptionHtml() template.HTML { func (repo *Repository) DescriptionHtml() template.HTML {
sanitize := func(s string) string { sanitize := func(s string) string {
+2 -1
View File
@@ -29,7 +29,8 @@ type AuthenticationForm struct {
SMTPHost string `form:"smtp_host"` SMTPHost string `form:"smtp_host"`
SMTPPort int `form:"smtp_port"` SMTPPort int `form:"smtp_port"`
TLS bool `form:"tls"` TLS bool `form:"tls"`
AllowAutoRegister bool `form:"allowautoregister"` SkipVerify bool
AllowAutoRegister bool `form:"allowautoregister"`
PAMServiceName string PAMServiceName string
} }
+2 -2
View File
@@ -4364,7 +4364,7 @@ func confLocaleLocale_deDeIni() (*asset, error) {
return a, nil return a, nil
} }
var _confLocaleLocale_enUsIni = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xc4\x7d\xfd\x92\xdb\x48\x8e\xe7\xff\x7c\x0a\xb6\x37\x7c\x76\x47\x94\xe5\xe8\xee\xb8\x8f\x98\xb0\xdd\x57\xae\x6a\x7f\xcc\xba\x5c\xb5\xae\xf2\xcc\xcd\x39\x1c\x1c\x4a\x64\x49\x1c\x4b\xa4\x9a\xa4\x2c\x6b\x36\x36\xe2\x5e\xe3\x5e\xef\x9e\xe4\x80\x1f\x80\xfc\x20\xa9\xb2\x3d\xbb\x71\xf7\x8f\x94\xcc\x44\x7e\x21\x91\x48\x24\x12\x89\xcc\xb7\xdb\xac\x28\xbb\x45\xfa\x34\x3d\x4d\xb7\x79\x55\xaf\xcb\xae\x4b\xbb\x72\x7d\xfb\x68\xd5\x74\x7d\x59\xa4\x2f\xab\x9e\xbe\xdb\xcf\xd5\xa2\x4c\x92\x55\xb3\x29\x09\xf4\x15\xfd\x25\x45\xde\xad\xe6\x4d\xde\x16\x14\x71\x6e\xe1\xa4\xfc\xb2\x5d\x37\x2d\x03\xfd\x26\xa1\x64\x55\xae\xb7\x9c\x87\xfe\x92\xae\x5a\xd6\x59\x55\xd3\xe7\x35\x85\xd2\xd7\x75\xd2\x35\x8b\x2a\x5f\x67\x41\x02\x22\x2c\xfd\x0f\xe9\xcf\x75\x91\x5e\xf7\xe5\x36\x7d\xd2\x6d\xf2\xf5\xfa\x59\xde\x21\x4b\x5f\xa6\xf9\x62\xd1\xec\xea\xfe\xc9\x63\x49\x90\xc2\x9b\x5d\x6f\xa5\x5f\xee\x7a\x89\xdb\x6d\x2d\xea\xfd\x36\x69\xcb\x65\x45\x1d\x6b\x29\xea\x9d\x06\x93\x7d\x39\xef\xaa\x9e\x1b\xfd\x67\x09\x25\x9f\xcb\xb6\xab\x1a\x6e\xcf\x9f\x24\x94\x6c\xf3\x25\x03\x5c\xd1\x5f\xd2\x97\x9b\xed\x3a\x47\x86\x1b\x0d\x26\xeb\xbc\x5e\xee\x04\xe6\x8d\x06\x93\x45\x5b\x52\x52\x56\x97\x7b\x8a\x3d\xc3\x47\x4a\x1f\xb3\xd9\x2c\xd9\x11\x4e\xb3\x6d\xdb\xdc\x56\xeb\x32\xcb\xeb\x22\xdb\x08\xd6\xde\x53\x7c\xaa\xf1\x29\xc5\xa7\x1c\x8f\x6e\x94\x05\x21\x28\xcb\x3b\xed\x0b\x0d\x0d\xe1\x2b\xef\x12\x14\x55\xe7\x1b\xcb\xcd\xc1\xa4\xdc\xe4\xd5\x9a\x07\xe1\x11\x07\xa8\xf1\x5d\xb7\x6f\x30\x54\x57\x1a\x24\x44\x64\xfd\x61\x5b\x02\x0f\x8f\x6e\x28\x94\x2c\xf2\x6d\xbf\x58\xe5\xdc\x56\x09\x25\x04\xb4\x6d\x08\x21\x4d\x7b\x00\x9c\x7d\x24\x4d\xbb\xcc\xeb\xea\xef\x79\x2f\x48\xba\x0c\x3e\x93\x4d\xd5\xb6\x0d\xe3\xf7\x02\x81\x84\x7a\x9c\x71\x39\x14\xf3\x96\x30\x11\x94\xc2\x29\x9b\x6a\xd9\x0a\x2a\x39\xf1\x02\x5f\x5c\x0a\xa7\xdd\x36\xed\x27\x4d\x78\xc1\xc1\x41\x56\x6a\x84\xa6\xc6\xf5\xe7\x35\x21\x5f\x53\x2f\xf0\x11\x01\x74\x49\x5e\x6c\x08\x95\xdb\xbc\x2e\x19\x47\xa7\xfc\x45\x78\xa1\xaf\x44\x69\x2a\xeb\xca\xbe\xaf\xea\x25\x23\xfb\x54\xa2\xd2\x6b\x8d\x4a\x82\x34\x17\x77\x68\x76\x6e\x38\x29\xfe\x2f\xf4\x99\x5e\xc9\xa7\xa4\x05\x99\x90\xe8\x72\x72\x4f\xba\xec\xb6\x2c\x0b\xe9\x4b\x97\xbe\xa0\x70\xb2\xdd\xad\xd7\x84\xb5\xdf\x77\x65\xd7\x73\xa6\x2b\xfa\xa6\xfe\xcb\x77\x52\x75\x1d\x05\x28\xfa\x35\x02\x09\x0d\x5d\xbd\x40\x67\xce\x10\x48\x92\x0f\x5d\x99\xb7\x8b\xd5\xc7\x44\xfe\xd1\x56\x0e\x30\xed\x1d\x1b\x54\x26\x24\x25\x22\xa9\xc1\x2a\x48\x16\x4d\xc1\x1f\x67\xf4\x47\x45\x57\x75\xd7\xd3\x8c\xfb\x98\x68\x80\xc1\x24\x24\x03\xd0\x57\x3d\xb0\xa0\x91\x98\xbe\x1d\x8f\x60\xfa\xa2\x6a\xbb\xfe\x51\x5f\x11\xb1\xbe\xdb\xd5\x09\xf7\x8f\x66\x5b\x56\xcc\x8d\x09\xbd\x6c\x08\x45\x88\x6e\xa9\x7f\x17\x87\xeb\x7f\x79\x73\x92\x5e\x11\x27\x5a\xb6\x25\x85\x53\x2a\x83\xfe\x28\xcf\x2f\xb3\x84\x72\x59\x4d\xe7\x79\x9f\xcf\xf3\xae\xf4\x68\xe5\x44\xa1\x6e\x97\x06\x1a\x67\xae\x06\x0e\xd6\xf5\x51\x7f\xa7\x66\x08\x95\xa1\xf3\xca\x95\xf1\x96\x27\x17\xc5\x33\x53\x43\xe6\xab\x75\xc9\xf1\x54\x54\xfa\xfa\xed\xdb\xcb\xf3\xe7\x69\x59\x2f\xab\xba\x4c\xf7\x55\xbf\x4a\x77\xfd\xed\x7f\xcb\x96\x65\x5d\xb6\xc4\xe3\x16\x55\x4a\x73\xaa\x25\x4a\x48\x89\xb0\xa5\x73\xb3\xa4\xeb\xd6\x34\xf7\x81\xde\xeb\xeb\x37\xe9\x05\xa3\x78\x9b\xf7\x2b\x34\xa4\x5f\x25\xdd\xef\x6b\x46\x91\xab\xf0\x66\x55\xa6\xa0\x32\x00\x35\xb7\x86\x8f\xb4\xd0\x36\xce\x92\xb2\x6d\x33\x62\x4b\xfd\x21\xd3\xcc\x5a\xde\x10\x52\x8a\x20\xd2\xa9\x9b\x3e\x9d\x97\x29\xf2\xcc\x92\xc4\x1a\x6c\xd8\x3d\xdd\x6e\xd7\xd5\x42\xe6\xfa\x4b\x49\xf3\x88\xe6\x15\x44\xb1\x14\xc2\x01\x51\x96\x16\xa0\x8b\xd8\x33\xcf\x87\x34\x62\x20\xc8\xbf\x2a\x89\x01\xae\x76\x4b\x61\x7b\xeb\x66\x57\xfc\x00\x4a\xb5\xd6\x7b\x42\x4d\xdf\x35\xd4\x60\x60\xc7\x01\xf8\x2a\x4e\x89\xe2\x78\xd1\x6a\xcb\x4d\x43\x7c\xc5\x11\x7b\x45\x04\xb5\xaf\x28\x91\x7a\xda\xe5\x9f\x69\xbe\xf5\x4d\xda\xaf\xaa\x2e\x2d\x88\xd8\x16\x5c\x30\x4d\x8d\x1d\x2d\x17\x42\x16\x44\xa0\x42\x1a\x16\x17\x8f\x01\xa0\x36\x3b\xa2\xa6\x15\x15\xc6\x8b\x11\xaf\x9c\x54\xe4\x54\x3b\xd1\x25\x2a\x07\xf4\x4d\x94\xdb\x10\x57\x66\xbe\x79\x8e\x80\x7e\x87\xe5\x53\xab\xf2\xdb\x5b\x6a\x55\x47\x54\xf1\x2a\x5d\xac\x1b\x22\xa9\xf7\xef\xde\x74\x4c\x30\xab\x6c\xdb\xb4\x58\xe6\x28\xe9\x8a\x82\x2e\x2e\x40\x34\x43\xd4\xbb\xcd\x9c\xbe\xf6\xab\x8a\x38\x00\xd0\xce\x39\x78\x35\xa7\x58\xaa\x62\xd7\xd1\x10\x9e\xa4\x44\xc2\xd4\x03\x42\x19\x08\x80\xfb\x50\x54\x5d\x3e\xa7\xb1\x67\xf0\x5b\x5a\xb6\x76\x2d\x91\xd5\xaa\xef\xb7\x56\xf3\xab\x9b\x9b\x2b\xa9\xda\xc5\xde\x55\x77\x1e\x50\x06\xc6\x60\xcd\x0b\x6f\x9d\x36\xf5\x0c\x44\xb2\x6b\xd7\x03\xfa\xa1\xbe\x5a\xca\x11\xbc\x70\x13\x1e\xf3\xcf\xb5\x47\x0f\xf0\xdc\x91\x74\xb2\x07\x35\x11\x8e\x4b\x2c\x80\x44\xd4\xcd\x96\xcb\x0d\xa8\xfa\x52\x23\x3c\x29\x63\xd1\x74\xe9\xb2\x74\x52\x2a\x64\x9f\x80\xfd\x6f\xa8\xc3\xca\x46\xae\x2f\x08\x0d\xe0\x25\x88\xbd\x6d\x9b\x0d\xc5\xbe\xa0\x3f\x1f\xe1\x9b\x7f\xc1\xe5\x01\x26\x2f\x0a\xe2\x6f\xdd\x49\xfa\xee\xc5\x59\xfa\x9f\x7f\xf9\xf9\xe7\x59\xfa\xba\xe7\x99\xc8\xc4\xf9\x37\x26\x2a\x0a\xca\x1a\xee\x40\x89\x65\xf4\x44\x77\xf7\x78\x66\xdd\x4b\x9f\x2Line truncated var _confLocaleLocale_enUsIni = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xc4\x7d\xfd\x92\xdb\x48\x8e\xe7\xff\x7c\x0a\xb6\x37\x7c\x76\x47\x94\xe5\xe8\xee\xb8\x8f\x98\xb0\xdd\x57\xae\x6a\x7f\xcc\xba\x5c\xb5\xae\xf2\xcc\xcd\x39\x1c\x1c\x4a\x64\x49\x1c\x4b\xa4\x9a\xa4\x2c\x6b\x36\x36\xe2\x5e\xe3\x5e\xef\x9e\xe4\x80\x1f\x80\xfc\x20\xa9\xb2\x3d\xbb\x71\xf7\x8f\x94\xcc\x44\x7e\x21\x91\x48\x24\x12\x89\xcc\xb7\xdb\xac\x28\xbb\x45\xfa\x34\x3d\x4d\xb7\x79\x55\xaf\xcb\xae\x4b\xbb\x72\x7d\xfb\x68\xd5\x74\x7d\x59\xa4\x2f\xab\x9e\xbe\xdb\xcf\xd5\xa2\x4c\x92\x55\xb3\x29\x09\xf4\x15\xfd\x25\x45\xde\xad\xe6\x4d\xde\x16\x14\x71\x6e\xe1\xa4\xfc\xb2\x5d\x37\x2d\x03\xfd\x26\xa1\x64\x55\xae\xb7\x9c\x87\xfe\x92\xae\x5a\xd6\x59\x55\xd3\xe7\x35\x85\xd2\xd7\x75\xd2\x35\x8b\x2a\x5f\x67\x41\x02\x22\x2c\xfd\x0f\xe9\xcf\x75\x91\x5e\xf7\xe5\x36\x7d\xd2\x6d\xf2\xf5\xfa\x59\xde\x21\x4b\x5f\xa6\xf9\x62\xd1\xec\xea\xfe\xc9\x63\x49\x90\xc2\x9b\x5d\x6f\xa5\x5f\xee\x7a\x89\xdb\x6d\x2d\xea\xfd\x36\x69\xcb\x65\x45\x1d\x6b\x29\xea\x9d\x06\x93\x7d\x39\xef\xaa\x9e\x1b\xfd\x67\x09\x25\x9f\xcb\xb6\xab\x1a\x6e\xcf\x9f\x24\x94\x6c\xf3\x25\x03\x5c\xd1\x5f\xd2\x97\x9b\xed\x3a\x47\x86\x1b\x0d\x26\xeb\xbc\x5e\xee\x04\xe6\x8d\x06\x93\x45\x5b\x52\x52\x56\x97\x7b\x8a\x3d\xc3\x47\x4a\x1f\xb3\xd9\x2c\xd9\x11\x4e\xb3\x6d\xdb\xdc\x56\xeb\x32\xcb\xeb\x22\xdb\x08\xd6\xde\x53\x7c\xaa\xf1\x29\xc5\xa7\x1c\x8f\x6e\x94\x05\x21\x28\xcb\x3b\xed\x0b\x0d\x0d\xe1\x2b\xef\x12\x14\x55\xe7\x1b\xcb\xcd\xc1\xa4\xdc\xe4\xd5\x9a\x07\xe1\x11\x07\xa8\xf1\x5d\xb7\x6f\x30\x54\x57\x1a\x24\x44\x64\xfd\x61\x5b\x02\x0f\x8f\x6e\x28\x94\x2c\xf2\x6d\xbf\x58\xe5\xdc\x56\x09\x25\x04\xb4\x6d\x08\x21\x4d\x7b\x00\x9c\x7d\x24\x4d\xbb\xcc\xeb\xea\xef\x79\x2f\x48\xba\x0c\x3e\x93\x4d\xd5\xb6\x0d\xe3\xf7\x02\x81\x84\x7a\x9c\x71\x39\x14\xf3\x96\x30\x11\x94\xc2\x29\x9b\x6a\xd9\x0a\x2a\x39\xf1\x02\x5f\x5c\x0a\xa7\xdd\x36\xed\x27\x4d\x78\xc1\xc1\x41\x56\x6a\x84\xa6\xc6\xf5\xe7\x35\x21\x5f\x53\x2f\xf0\x11\x01\x74\x49\x5e\x6c\x08\x95\xdb\xbc\x2e\x19\x47\xa7\xfc\x45\x78\xa1\xaf\x44\x69\x2a\xeb\xca\xbe\xaf\xea\x25\x23\xfb\x54\xa2\xd2\x6b\x8d\x4a\x82\x34\x17\x77\x68\x76\x6e\x38\x29\xfe\x2f\xf4\x99\x5e\xc9\xa7\xa4\x05\x99\x90\xe8\x72\x72\x4f\xba\xec\xb6\x2c\x0b\xe9\x4b\x97\xbe\xa0\x70\xb2\xdd\xad\xd7\x84\xb5\xdf\x77\x65\xd7\x73\xa6\x2b\xfa\xa6\xfe\xcb\x77\x52\x75\x1d\x05\x28\xfa\x35\x02\x09\x0d\x5d\xbd\x40\x67\xce\x10\x48\x92\x0f\x5d\x99\xb7\x8b\xd5\xc7\x44\xfe\xd1\x56\x0e\x30\xed\x1d\x1b\x54\x26\x24\x25\x22\xa9\xc1\x2a\x48\x16\x4d\xc1\x1f\x67\xf4\x47\x45\x57\x75\xd7\xd3\x8c\xfb\x98\x68\x80\xc1\x24\x24\x03\xd0\x57\x3d\xb0\xa0\x91\x98\xbe\x1d\x8f\x60\xfa\xa2\x6a\xbb\xfe\x51\x5f\x11\xb1\xbe\xdb\xd5\x09\xf7\x8f\x66\x5b\x56\xcc\x8d\x09\xbd\x6c\x08\x45\x88\x6e\xa9\x7f\x17\x87\xeb\x7f\x79\x73\x92\x5e\x11\x27\x5a\xb6\x25\x85\x53\x2a\x83\xfe\x28\xcf\x2f\xb3\x84\x72\x59\x4d\xe7\x79\x9f\xcf\xf3\xae\xf4\x68\xe5\x44\xa1\x6e\x97\x06\x1a\x67\xae\x06\x0e\xd6\xf5\x51\x7f\xa7\x66\x08\x95\xa1\xf3\xca\x95\xf1\x96\x27\x17\xc5\x33\x53\x43\xe6\xab\x75\xc9\xf1\x54\x54\xfa\xfa\xed\xdb\xcb\xf3\xe7\x69\x59\x2f\xab\xba\x4c\xf7\x55\xbf\x4a\x77\xfd\xed\x7f\xcb\x96\x65\x5d\xb6\xc4\xe3\x16\x55\x4a\x73\xaa\x25\x4a\x48\x89\xb0\xa5\x73\xb3\xa4\xeb\xd6\x34\xf7\x81\xde\xeb\xeb\x37\xe9\x05\xa3\x78\x9b\xf7\x2b\x34\xa4\x5f\x25\xdd\xef\x6b\x46\x91\xab\xf0\x66\x55\xa6\xa0\x32\x00\x35\xb7\x86\x8f\xb4\xd0\x36\xce\x92\xb2\x6d\x33\x62\x4b\xfd\x21\xd3\xcc\x5a\xde\x10\x52\x8a\x20\xd2\xa9\x9b\x3e\x9d\x97\x29\xf2\xcc\x92\xc4\x1a\x6c\xd8\x3d\xdd\x6e\xd7\xd5\x42\xe6\xfa\x4b\x49\xf3\x88\xe6\x15\x44\xb1\x14\xc2\x01\x51\x96\x16\xa0\x8b\xd8\x33\xcf\x87\x34\x62\x20\xc8\xbf\x2a\x89\x01\xae\x76\x4b\x61\x7b\xeb\x66\x57\xfc\x00\x4a\xb5\xd6\x7b\x42\x4d\xdf\x35\xd4\x60\x60\xc7\x01\xf8\x2a\x4e\x89\xe2\x78\xd1\x6a\xcb\x4d\x43\x7c\xc5\x11\x7b\x45\x04\xb5\xaf\x28\x91\x7a\xda\xe5\x9f\x69\xbe\xf5\x4d\xda\xaf\xaa\x2e\x2d\x88\xd8\x16\x5c\x30\x4d\x8d\x1d\x2d\x17\x42\x16\x44\xa0\x42\x1a\x16\x17\x8f\x01\xa0\x36\x3b\xa2\xa6\x15\x15\xc6\x8b\x11\xaf\x9c\x54\xe4\x54\x3b\xd1\x25\x2a\x07\xf4\x4d\x94\xdb\x10\x57\x66\xbe\x79\x8e\x80\x7e\x87\xe5\x53\xab\xf2\xdb\x5b\x6a\x55\x47\x54\xf1\x2a\x5d\xac\x1b\x22\xa9\xf7\xef\xde\x74\x4c\x30\xab\x6c\xdb\xb4\x58\xe6\x28\xe9\x8a\x82\x2e\x2e\x40\x34\x43\xd4\xbb\xcd\x9c\xbe\xf6\xab\x8a\x38\x00\xd0\xce\x39\x78\x35\xa7\x58\xaa\x62\xd7\xd1\x10\x9e\xa4\x44\xc2\xd4\x03\x42\x19\x08\x80\xfb\x50\x54\x5d\x3e\xa7\xb1\x67\xf0\x5b\x5a\xb6\x76\x2d\x91\xd5\xaa\xef\xb7\x56\xf3\xab\x9b\x9b\x2b\xa9\xda\xc5\xde\x55\x77\x1e\x50\x06\xc6\x60\xcd\x0b\x6f\x9d\x36\xf5\x0c\x44\xb2\x6b\xd7\x03\xfa\xa1\xbe\x5a\xca\x11\xbc\x70\x13\x1e\xf3\xcf\xb5\x47\x0f\xf0\xdc\x91\x74\xb2\x07\x35\x11\x8e\x4b\x2c\x80\x44\xd4\xcd\x96\xcb\x0d\xa8\xfa\x52\x23\x3c\x29\x63\xd1\x74\xe9\xb2\x74\x52\x2a\x64\x9f\x80\xfd\x6f\xa8\xc3\xca\x46\xae\x2f\x08\x0d\xe0\x25\x88\xbd\x6d\x9b\x0d\xc5\xbe\xa0\x3f\x1f\xe1\x9b\x7f\xc1\xe5\x01\x26\x2f\x0a\xe2\x6f\xdd\x49\xfa\xee\xc5\x59\xfa\x9f\x7f\xf9\xf9\xe7\x59\xfa\xba\xe7\x99\xc8\xc4\xf9\x37\x26\x2a\x0a\xca\x1a\xee\x40\x89\x65\xf4\x44\x77\xf7\x78\x66\xdd\x4b\x9f\x2Line truncated
func confLocaleLocale_enUsIniBytes() ([]byte, error) { func confLocaleLocale_enUsIniBytes() ([]byte, error) {
return bindataRead( return bindataRead(
@@ -4379,7 +4379,7 @@ func confLocaleLocale_enUsIni() (*asset, error) {
return nil, err return nil, err
} }
info := bindataFileInfo{name: "conf/locale/locale_en-US.ini", size: 39791, mode: os.FileMode(420), modTime: time.Unix(1440814918, 0)} info := bindataFileInfo{name: "conf/locale/locale_en-US.ini", size: 39831, mode: os.FileMode(420), modTime: time.Unix(1440833721, 0)}
a := &asset{bytes: bytes, info: info} a := &asset{bytes: bytes, info: info}
return a, nil return a, nil
} }
+39 -37
View File
@@ -63,27 +63,28 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
case models.LDAP: case models.LDAP:
u = &models.LDAPConfig{ u = &models.LDAPConfig{
Ldapsource: ldap.Ldapsource{ Ldapsource: ldap.Ldapsource{
Name: form.Name, Name: form.Name,
Host: form.Host, Host: form.Host,
Port: form.Port, Port: form.Port,
UseSSL: form.UseSSL, UseSSL: form.UseSSL,
BindDN: form.BindDN, BindDN: form.BindDN,
BindPassword: form.BindPassword, BindPassword: form.BindPassword,
UserBase: form.UserBase, UserBase: form.UserBase,
Filter: form.Filter, Filter: form.Filter,
AdminFilter: form.AdminFilter, AdminFilter: form.AdminFilter,
AttributeName: form.AttributeName, AttributeName: form.AttributeName,
AttributeSurname: form.AttributeSurname, AttributeSurname: form.AttributeSurname,
AttributeMail: form.AttributeMail, AttributeMail: form.AttributeMail,
Enabled: true, Enabled: true,
}, },
} }
case models.SMTP: case models.SMTP:
u = &models.SMTPConfig{ u = &models.SMTPConfig{
Auth: form.SMTPAuth, Auth: form.SMTPAuth,
Host: form.SMTPHost, Host: form.SMTPHost,
Port: form.SMTPPort, Port: form.SMTPPort,
TLS: form.TLS, TLS: form.TLS,
SkipVerify: form.SkipVerify,
} }
case models.PAM: case models.PAM:
u = &models.PAMConfig{ u = &models.PAMConfig{
@@ -123,7 +124,7 @@ func EditAuthSource(ctx *middleware.Context) {
ctx.Handle(404, "EditAuthSource", nil) ctx.Handle(404, "EditAuthSource", nil)
return return
} }
u, err := models.GetLoginSourceById(id) u, err := models.GetLoginSourceByID(id)
if err != nil { if err != nil {
ctx.Handle(500, "GetLoginSourceById", err) ctx.Handle(500, "GetLoginSourceById", err)
return return
@@ -150,27 +151,28 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
case models.LDAP: case models.LDAP:
config = &models.LDAPConfig{ config = &models.LDAPConfig{
Ldapsource: ldap.Ldapsource{ Ldapsource: ldap.Ldapsource{
Name: form.Name, Name: form.Name,
Host: form.Host, Host: form.Host,
Port: form.Port, Port: form.Port,
UseSSL: form.UseSSL, UseSSL: form.UseSSL,
BindDN: form.BindDN, BindDN: form.BindDN,
BindPassword: form.BindPassword, BindPassword: form.BindPassword,
UserBase: form.UserBase, UserBase: form.UserBase,
AttributeName: form.AttributeName, AttributeName: form.AttributeName,
AttributeSurname: form.AttributeSurname, AttributeSurname: form.AttributeSurname,
AttributeMail: form.AttributeMail, AttributeMail: form.AttributeMail,
Filter: form.Filter, Filter: form.Filter,
AdminFilter: form.AdminFilter, AdminFilter: form.AdminFilter,
Enabled: true, Enabled: true,
}, },
} }
case models.SMTP: case models.SMTP:
config = &models.SMTPConfig{ config = &models.SMTPConfig{
Auth: form.SMTPAuth, Auth: form.SMTPAuth,
Host: form.SMTPHost, Host: form.SMTPHost,
Port: form.SMTPPort, Port: form.SMTPPort,
TLS: form.TLS, TLS: form.TLS,
SkipVerify: form.SkipVerify,
} }
case models.PAM: case models.PAM:
config = &models.PAMConfig{ config = &models.PAMConfig{
@@ -182,7 +184,7 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
} }
u := models.LoginSource{ u := models.LoginSource{
Id: form.ID, ID: form.ID,
Name: form.Name, Name: form.Name,
IsActived: form.IsActived, IsActived: form.IsActived,
Type: models.LoginType(form.Type), Type: models.LoginType(form.Type),
@@ -207,7 +209,7 @@ func DeleteAuthSource(ctx *middleware.Context) {
return return
} }
a, err := models.GetLoginSourceById(id) a, err := models.GetLoginSourceByID(id)
if err != nil { if err != nil {
ctx.Handle(500, "GetLoginSourceById", err) ctx.Handle(500, "GetLoginSourceById", err)
return return
+6 -2
View File
@@ -12,9 +12,9 @@
<div class="panel-header"> <div class="panel-header">
<strong>{{.i18n.Tr "admin.auths.edit"}}</strong> <strong>{{.i18n.Tr "admin.auths.edit"}}</strong>
</div> </div>
<form class="form form-align panel-body" id="auth-setting-form" action="{{AppSubUrl}}/admin/auths/{{.Source.Id}}" data-delete-url="{{AppSubUrl}}/admin/auths/{{.Source.Id}}/delete" method="post"> <form class="form form-align panel-body" id="auth-setting-form" action="{{AppSubUrl}}/admin/auths/{{.Source.ID}}" data-delete-url="{{AppSubUrl}}/admin/auths/{{.Source.ID}}/delete" method="post">
{{.CsrfTokenHtml}} {{.CsrfTokenHtml}}
<input type="hidden" value="{{.Source.Id}}" name="id"/> <input type="hidden" value="{{.Source.ID}}" name="id"/>
{{$type := .Source.Type}} {{$type := .Source.Type}}
<div class="field"> <div class="field">
<label>{{.i18n.Tr "admin.auths.auth_type"}}</label> <label>{{.i18n.Tr "admin.auths.auth_type"}}</label>
@@ -109,6 +109,10 @@
<input name="tls" type="checkbox" {{if .Source.SMTP.TLS}}checked{{end}}> <input name="tls" type="checkbox" {{if .Source.SMTP.TLS}}checked{{end}}>
<strong>{{.i18n.Tr "admin.auths.enable_tls"}}</strong> <strong>{{.i18n.Tr "admin.auths.enable_tls"}}</strong>
<br> <br>
<label></label>
<input name="skip_verify" type="checkbox" {{if .Source.SMTP.SkipVerify}}checked{{end}}>
<strong>{{.i18n.Tr "admin.auths.skip_tls_verify"}}</strong>
<br>
{{end}} {{end}}
<label></label> <label></label>
<input name="allowautoregister" type="checkbox" {{if .Source.AllowAutoRegister}}checked{{end}}> <input name="allowautoregister" type="checkbox" {{if .Source.AllowAutoRegister}}checked{{end}}>
+3 -3
View File
@@ -30,13 +30,13 @@
<tbody> <tbody>
{{range .Sources}} {{range .Sources}}
<tr> <tr>
<td>{{.Id}}</td> <td>{{.ID}}</td>
<td><a href="{{AppSubUrl}}/admin/auths/{{.Id}}">{{.Name}}</a></td> <td><a href="{{AppSubUrl}}/admin/auths/{{.ID}}">{{.Name}}</a></td>
<td>{{.TypeString}}</td> <td>{{.TypeString}}</td>
<td><i class="fa fa{{if .IsActived}}-check{{end}}-square-o"></i></td> <td><i class="fa fa{{if .IsActived}}-check{{end}}-square-o"></i></td>
<td><span title="{{DateFmtLong .Updated}}">{{DateFmtShort .Updated}}</span></td> <td><span title="{{DateFmtLong .Updated}}">{{DateFmtShort .Updated}}</span></td>
<td><span title="{{DateFmtLong .Created}}">{{DateFmtShort .Created}}</span></td> <td><span title="{{DateFmtLong .Created}}">{{DateFmtShort .Created}}</span></td>
<td><a href="{{AppSubUrl}}/admin/auths/{{.Id}}"><i class="fa fa-pencil-square-o"></i></a></td> <td><a href="{{AppSubUrl}}/admin/auths/{{.ID}}"><i class="fa fa-pencil-square-o"></i></a></td>
</tr> </tr>
{{end}} {{end}}
</tbody> </tbody>
+4
View File
@@ -102,6 +102,10 @@
<input name="tls" type="checkbox" {{if .tls}}checked{{end}}> <input name="tls" type="checkbox" {{if .tls}}checked{{end}}>
<strong>{{.i18n.Tr "admin.auths.enable_tls"}}</strong> <strong>{{.i18n.Tr "admin.auths.enable_tls"}}</strong>
<br> <br>
<label></label>
<input name="skip_verify" type="checkbox" {{if .skip_verify}}checked{{end}}>
<strong>{{.i18n.Tr "admin.auths.skip_tls_verify"}}</strong>
<br>
</div> </div>
<label></label> <label></label>
<input name="allowautoregister" type="checkbox" {{if .allowautoregister}}checked{{end}}> <input name="allowautoregister" type="checkbox" {{if .allowautoregister}}checked{{end}}>