Skip to content

Commit 25b5722

Browse files
authored
Merge pull request #274 from lunny/lunny/golint_modules_auth
Golint fixed for modules/auth
2 parents e6da2cf + d0bef01 commit 25b5722

File tree

16 files changed

+103
-24
lines changed

16 files changed

+103
-24
lines changed

cmd/web.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func runWeb(ctx *cli.Context) error {
280280

281281
m.Group("/users", func() {
282282
m.Get("", admin.Users)
283-
m.Combo("/new").Get(admin.NewUser).Post(bindIgnErr(auth.AdminCrateUserForm{}), admin.NewUserPost)
283+
m.Combo("/new").Get(admin.NewUser).Post(bindIgnErr(auth.AdminCreateUserForm{}), admin.NewUserPost)
284284
m.Combo("/:userid").Get(admin.EditUser).Post(bindIgnErr(auth.AdminEditUserForm{}), admin.EditUserPost)
285285
m.Post("/:userid/delete", admin.DeleteUser)
286286
})

models/login_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC
502502
// LoginViaPAM queries if login/password is valid against the PAM,
503503
// and create a local user if success when enabled.
504504
func LoginViaPAM(user *User, login, password string, sourceID int64, cfg *PAMConfig, autoRegister bool) (*User, error) {
505-
if err := pam.PAMAuth(cfg.ServiceName, login, password); err != nil {
505+
if err := pam.Auth(cfg.ServiceName, login, password); err != nil {
506506
if strings.Contains(err.Error(), "Authentication failure") {
507507
return nil, ErrUserNotExist{0, login, 0}
508508
}

modules/auth/admin.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import (
1010
"github.com/go-macaron/binding"
1111
)
1212

13-
type AdminCrateUserForm struct {
13+
// AdminCreateUserForm form for admin to create user
14+
type AdminCreateUserForm struct {
1415
LoginType string `binding:"Required"`
1516
LoginName string
1617
UserName string `binding:"Required;AlphaDashDot;MaxSize(35)"`
@@ -19,10 +20,12 @@ type AdminCrateUserForm struct {
1920
SendNotify bool
2021
}
2122

22-
func (f *AdminCrateUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
23+
// Validate validates form fields
24+
func (f *AdminCreateUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
2325
return validate(errs, ctx.Data, f, ctx.Locale)
2426
}
2527

28+
// AdminEditUserForm form for admin to create user
2629
type AdminEditUserForm struct {
2730
LoginType string `binding:"Required"`
2831
LoginName string
@@ -39,6 +42,7 @@ type AdminEditUserForm struct {
3942
ProhibitLogin bool
4043
}
4144

45+
// Validate validates form fields
4246
func (f *AdminEditUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
4347
return validate(errs, ctx.Data, f, ctx.Locale)
4448
}

modules/auth/auth.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"code.gitea.io/gitea/modules/setting"
2222
)
2323

24+
// IsAPIPath if URL is an api path
2425
func IsAPIPath(url string) bool {
2526
return strings.HasPrefix(url, "/api/")
2627
}
@@ -110,9 +111,8 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (*models.User, bool)
110111
// FIXME: should I create a system notice?
111112
log.Error(4, "CreateUser: %v", err)
112113
return nil, false
113-
} else {
114-
return u, false
115114
}
115+
return u, false
116116
}
117117
}
118118
return u, false
@@ -148,6 +148,7 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (*models.User, bool)
148148
return u, false
149149
}
150150

151+
// Form form binding interface
151152
type Form interface {
152153
binding.Validator
153154
}
@@ -190,18 +191,22 @@ func getRuleBody(field reflect.StructField, prefix string) string {
190191
return ""
191192
}
192193

194+
// GetSize get size int form tag
193195
func GetSize(field reflect.StructField) string {
194196
return getRuleBody(field, "Size(")
195197
}
196198

199+
// GetMinSize get minimal size in form tag
197200
func GetMinSize(field reflect.StructField) string {
198201
return getRuleBody(field, "MinSize(")
199202
}
200203

204+
// GetMaxSize get max size in form tag
201205
func GetMaxSize(field reflect.StructField) string {
202206
return getRuleBody(field, "MaxSize(")
203207
}
204208

209+
// GetInclude get include in form tag
205210
func GetInclude(field reflect.StructField) string {
206211
return getRuleBody(field, "Include(")
207212
}

modules/auth/auth_form.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"gopkg.in/macaron.v1"
1010
)
1111

12+
// AuthenticationForm form for authentication
1213
type AuthenticationForm struct {
1314
ID int64
1415
Type int `binding:"Range(2,5)"`
@@ -37,6 +38,7 @@ type AuthenticationForm struct {
3738
PAMServiceName string
3839
}
3940

41+
// Validate validates fields
4042
func (f *AuthenticationForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
4143
return validate(errs, ctx.Data, f, ctx.Locale)
4244
}

modules/auth/ldap/ldap.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"code.gitea.io/gitea/modules/log"
1717
)
1818

19+
// SecurityProtocol protocol type
1920
type SecurityProtocol int
2021

2122
// Note: new type must be added at the end of list to maintain compatibility.
@@ -25,7 +26,7 @@ const (
2526
SecurityProtocolStartTLS
2627
)
2728

28-
// Basic LDAP authentication service
29+
// Source Basic LDAP authentication service
2930
type Source struct {
3031
Name string // canonical name (ie. corporate.ad)
3132
Host string // LDAP host
@@ -148,7 +149,7 @@ func bindUser(l *ldap.Conn, userDN, passwd string) error {
148149
return err
149150
}
150151

151-
// searchEntry : search an LDAP source if an entry (name, passwd) is valid and in the specific filter
152+
// SearchEntry : search an LDAP source if an entry (name, passwd) is valid and in the specific filter
152153
func (ls *Source) SearchEntry(name, passwd string, directBind bool) (string, string, string, string, bool, bool) {
153154
l, err := dial(ls)
154155
if err != nil {

modules/auth/org.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ import (
1616
// \_______ /__| \___ (____ /___| /__/_____ \(____ /__| |__|\____/|___| /
1717
// \/ /_____/ \/ \/ \/ \/ \/
1818

19+
// CreateOrgForm form for creating organization
1920
type CreateOrgForm struct {
2021
OrgName string `binding:"Required;AlphaDashDot;MaxSize(35)" locale:"org.org_name_holder"`
2122
}
2223

24+
// Validate valideates the fields
2325
func (f *CreateOrgForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
2426
return validate(errs, ctx.Data, f, ctx.Locale)
2527
}
2628

29+
// UpdateOrgSettingForm form for updating organization settings
2730
type UpdateOrgSettingForm struct {
2831
Name string `binding:"Required;AlphaDashDot;MaxSize(35)" locale:"org.org_name_holder"`
2932
FullName string `binding:"MaxSize(100)"`
@@ -33,6 +36,7 @@ type UpdateOrgSettingForm struct {
3336
MaxRepoCreation int
3437
}
3538

39+
// Validate valideates the fields
3640
func (f *UpdateOrgSettingForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
3741
return validate(errs, ctx.Data, f, ctx.Locale)
3842
}
@@ -44,12 +48,14 @@ func (f *UpdateOrgSettingForm) Validate(ctx *macaron.Context, errs binding.Error
4448
// |____| \___ >____ /__|_| /
4549
// \/ \/ \/
4650

51+
// CreateTeamForm form for creating team
4752
type CreateTeamForm struct {
4853
TeamName string `binding:"Required;AlphaDashDot;MaxSize(30)"`
4954
Description string `binding:"MaxSize(255)"`
5055
Permission string
5156
}
5257

58+
// Validate valideates the fields
5359
func (f *CreateTeamForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
5460
return validate(errs, ctx.Data, f, ctx.Locale)
5561
}

modules/auth/pam/pam.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import (
1212
"github.com/msteinert/pam"
1313
)
1414

15-
func PAMAuth(serviceName, userName, passwd string) error {
15+
// Auth pam auth service
16+
func Auth(serviceName, userName, passwd string) error {
1617
t, err := pam.StartFunc(serviceName, userName, func(s pam.Style, msg string) (string, error) {
1718
switch s {
1819
case pam.PromptEchoOff:

modules/auth/pam/pam_stub.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"errors"
1111
)
1212

13-
func PAMAuth(serviceName, userName, passwd string) error {
13+
// Auth not supported lack of pam tag
14+
func Auth(serviceName, userName, passwd string) error {
1415
return errors.New("PAM not supported")
1516
}

0 commit comments

Comments
 (0)