summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/login_source.go44
-rw-r--r--routers/admin/auths.go18
2 files changed, 31 insertions, 31 deletions
diff --git a/models/login_source.go b/models/login_source.go
index 20cd89899b..3140d35c54 100644
--- a/models/login_source.go
+++ b/models/login_source.go
@@ -31,16 +31,16 @@ const (
LoginNotype LoginType = iota
LoginPlain // 1
LoginLdap // 2
- LOGIN_SMTP // 3
- LOGIN_PAM // 4
- LOGIN_DLDAP // 5
+ LoginSmtp // 3
+ LoginPam // 4
+ LoginDldap // 5
)
var LoginNames = map[LoginType]string{
LoginLdap: "LDAP (via BindDN)",
- LOGIN_DLDAP: "LDAP (simple auth)", // Via direct bind
- LOGIN_SMTP: "SMTP",
- LOGIN_PAM: "PAM",
+ LoginDldap: "LDAP (simple auth)", // Via direct bind
+ LoginSmtp: "SMTP",
+ LoginPam: "PAM",
}
var SecurityProtocolNames = map[ldap.SecurityProtocol]string{
@@ -139,11 +139,11 @@ func (source *LoginSource) BeforeSet(colName string, val xorm.Cell) {
switch colName {
case "type":
switch LoginType(Cell2Int64(val)) {
- case LoginLdap, LOGIN_DLDAP:
+ case LoginLdap, LoginDldap:
source.Cfg = new(LDAPConfig)
- case LOGIN_SMTP:
+ case LoginSmtp:
source.Cfg = new(SMTPConfig)
- case LOGIN_PAM:
+ case LoginPam:
source.Cfg = new(PAMConfig)
default:
panic("unrecognized login source type: " + com.ToStr(*val))
@@ -169,15 +169,15 @@ func (source *LoginSource) IsLDAP() bool {
}
func (source *LoginSource) IsDLDAP() bool {
- return source.Type == LOGIN_DLDAP
+ return source.Type == LoginDldap
}
func (source *LoginSource) IsSMTP() bool {
- return source.Type == LOGIN_SMTP
+ return source.Type == LoginSmtp
}
func (source *LoginSource) IsPAM() bool {
- return source.Type == LOGIN_PAM
+ return source.Type == LoginPam
}
func (source *LoginSource) HasTLS() bool {
@@ -188,9 +188,9 @@ func (source *LoginSource) HasTLS() bool {
func (source *LoginSource) UseTLS() bool {
switch source.Type {
- case LoginLdap, LOGIN_DLDAP:
+ case LoginLdap, LoginDldap:
return source.LDAP().SecurityProtocol != ldap.SECURITY_PROTOCOL_UNENCRYPTED
- case LOGIN_SMTP:
+ case LoginSmtp:
return source.SMTP().TLS
}
@@ -199,9 +199,9 @@ func (source *LoginSource) UseTLS() bool {
func (source *LoginSource) SkipVerify() bool {
switch source.Type {
- case LoginLdap, LOGIN_DLDAP:
+ case LoginLdap, LoginDldap:
return source.LDAP().SkipVerify
- case LOGIN_SMTP:
+ case LoginSmtp:
return source.SMTP().SkipVerify
}
@@ -293,7 +293,7 @@ func composeFullName(firstname, surname, username string) string {
// LoginViaLDAP queries if login/password is valid against the LDAP directory pool,
// and create a local user if success when enabled.
func LoginViaLDAP(user *User, login, passowrd string, source *LoginSource, autoRegister bool) (*User, error) {
- username, fn, sn, mail, isAdmin, succeed := source.Cfg.(*LDAPConfig).SearchEntry(login, passowrd, source.Type == LOGIN_DLDAP)
+ username, fn, sn, mail, isAdmin, succeed := source.Cfg.(*LDAPConfig).SearchEntry(login, passowrd, source.Type == LoginDldap)
if !succeed {
// User not in LDAP, do nothing
return nil, ErrUserNotExist{0, login}
@@ -445,7 +445,7 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC
Name: strings.ToLower(username),
Email: login,
Passwd: password,
- LoginType: LOGIN_SMTP,
+ LoginType: LoginSmtp,
LoginSource: sourceID,
LoginName: login,
IsActive: true,
@@ -479,7 +479,7 @@ func LoginViaPAM(user *User, login, password string, sourceID int64, cfg *PAMCon
Name: login,
Email: login,
Passwd: password,
- LoginType: LOGIN_PAM,
+ LoginType: LoginPam,
LoginSource: sourceID,
LoginName: login,
IsActive: true,
@@ -493,11 +493,11 @@ func ExternalUserLogin(user *User, login, password string, source *LoginSource,
}
switch source.Type {
- case LoginLdap, LOGIN_DLDAP:
+ case LoginLdap, LoginDldap:
return LoginViaLDAP(user, login, password, source, autoRegister)
- case LOGIN_SMTP:
+ case LoginSmtp:
return LoginViaSMTP(user, login, password, source.ID, source.Cfg.(*SMTPConfig), autoRegister)
- case LOGIN_PAM:
+ case LoginPam:
return LoginViaPAM(user, login, password, source.ID, source.Cfg.(*PAMConfig), autoRegister)
}
diff --git a/routers/admin/auths.go b/routers/admin/auths.go
index 44fe0ee9fb..7fbd1296a2 100644
--- a/routers/admin/auths.go
+++ b/routers/admin/auths.go
@@ -49,9 +49,9 @@ type dropdownItem struct {
var (
authSources = []dropdownItem{
{models.LoginNames[models.LoginLdap], models.LoginLdap},
- {models.LoginNames[models.LOGIN_DLDAP], models.LOGIN_DLDAP},
- {models.LoginNames[models.LOGIN_SMTP], models.LOGIN_SMTP},
- {models.LoginNames[models.LOGIN_PAM], models.LOGIN_PAM},
+ {models.LoginNames[models.LoginDldap], models.LoginDldap},
+ {models.LoginNames[models.LoginSmtp], models.LoginSmtp},
+ {models.LoginNames[models.LoginPam], models.LoginPam},
}
securityProtocols = []dropdownItem{
{models.SecurityProtocolNames[ldap.SECURITY_PROTOCOL_UNENCRYPTED], ldap.SECURITY_PROTOCOL_UNENCRYPTED},
@@ -125,13 +125,13 @@ func NewAuthSourcePost(ctx *context.Context, form auth.AuthenticationForm) {
hasTLS := false
var config core.Conversion
switch models.LoginType(form.Type) {
- case models.LoginLdap, models.LOGIN_DLDAP:
+ case models.LoginLdap, models.LoginDldap:
config = parseLDAPConfig(form)
hasTLS = ldap.SecurityProtocol(form.SecurityProtocol) > ldap.SECURITY_PROTOCOL_UNENCRYPTED
- case models.LOGIN_SMTP:
+ case models.LoginSmtp:
config = parseSMTPConfig(form)
hasTLS = true
- case models.LOGIN_PAM:
+ case models.LoginPam:
config = &models.PAMConfig{
ServiceName: form.PAMServiceName,
}
@@ -208,11 +208,11 @@ func EditAuthSourcePost(ctx *context.Context, form auth.AuthenticationForm) {
var config core.Conversion
switch models.LoginType(form.Type) {
- case models.LoginLdap, models.LOGIN_DLDAP:
+ case models.LoginLdap, models.LoginDldap:
config = parseLDAPConfig(form)
- case models.LOGIN_SMTP:
+ case models.LoginSmtp:
config = parseSMTPConfig(form)
- case models.LOGIN_PAM:
+ case models.LoginPam:
config = &models.PAMConfig{
ServiceName: form.PAMServiceName,
}