diff options
author | Unknwon <u@gogs.io> | 2015-04-24 05:21:10 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-04-24 05:21:10 -0400 |
commit | c08baee0855807d24a1b86adfcea86d0731e2a3a (patch) | |
tree | c033d0fd4a4c4104b0b6304ec9f2a26c6047ce10 /modules/auth | |
parent | 7a7c096fd09035f759168800402389457648f47e (diff) | |
parent | f92bdf875b4ccb2a8eadaa571d112ebf653986d6 (diff) |
Merge branch 'develop' of github.com:gogits/gogs into develop
Diffstat (limited to 'modules/auth')
-rw-r--r-- | modules/auth/auth_form.go | 1 | ||||
-rw-r--r-- | modules/auth/pam/pam.go | 35 | ||||
-rw-r--r-- | modules/auth/pam/pam_stub.go | 15 |
3 files changed, 51 insertions, 0 deletions
diff --git a/modules/auth/auth_form.go b/modules/auth/auth_form.go index 7d459999..1102dc34 100644 --- a/modules/auth/auth_form.go +++ b/modules/auth/auth_form.go @@ -30,6 +30,7 @@ type AuthenticationForm struct { SMTPPort int `form:"smtp_port"` TLS bool `form:"tls"` AllowAutoRegister bool `form:"allowautoregister"` + PAMServiceName string } func (f *AuthenticationForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { diff --git a/modules/auth/pam/pam.go b/modules/auth/pam/pam.go new file mode 100644 index 00000000..7d150b1c --- /dev/null +++ b/modules/auth/pam/pam.go @@ -0,0 +1,35 @@ +// +build !windows + +// Copyright 2014 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package pam + +import ( + "errors" + + "github.com/msteinert/pam" +) + +func PAMAuth(serviceName, userName, passwd string) error { + t, err := pam.StartFunc(serviceName, userName, func(s pam.Style, msg string) (string, error) { + switch s { + case pam.PromptEchoOff: + return passwd, nil + case pam.PromptEchoOn, pam.ErrorMsg, pam.TextInfo: + return "", nil + } + return "", errors.New("Unrecognized PAM message style") + }) + + if err != nil { + return err + } + + if err = t.Authenticate(0); err != nil { + return err + } + + return nil +} diff --git a/modules/auth/pam/pam_stub.go b/modules/auth/pam/pam_stub.go new file mode 100644 index 00000000..2f210bf6 --- /dev/null +++ b/modules/auth/pam/pam_stub.go @@ -0,0 +1,15 @@ +// +build windows + +// Copyright 2014 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package pam + +import ( + "errors" +) + +func PAMAuth(serviceName, userName, passwd string) error { + return errors.New("PAM not supported") +} |