aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/auth/auth_form.go1
-rw-r--r--modules/auth/pam/pam.go35
-rw-r--r--modules/auth/pam/pam_stub.go15
-rw-r--r--modules/middleware/context.go7
-rw-r--r--modules/setting/setting.go2
5 files changed, 60 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")
+}
diff --git a/modules/middleware/context.go b/modules/middleware/context.go
index b580de50..200a74cb 100644
--- a/modules/middleware/context.go
+++ b/modules/middleware/context.go
@@ -139,6 +139,13 @@ func (ctx *Context) Handle(status int, title string, err error) {
ctx.HTML(status, base.TplName(fmt.Sprintf("status/%d", status)))
}
+func (ctx *Context) HandleText(status int, title string) {
+ if (status / 100 == 4) || (status / 100 == 5) {
+ log.Error(4, "%s", title)
+ }
+ ctx.RenderData(status, []byte(title))
+}
+
func (ctx *Context) HandleAPI(status int, obj interface{}) {
var message string
if err, ok := obj.(error); ok {
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index aefc3520..3ce27b2e 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -53,6 +53,7 @@ var (
HttpAddr, HttpPort string
DisableSSH bool
SSHPort int
+ SSHDomain string
OfflineMode bool
DisableRouterLog bool
CertFile, KeyFile string
@@ -232,6 +233,7 @@ func NewConfigContext() {
HttpAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
HttpPort = sec.Key("HTTP_PORT").MustString("3000")
DisableSSH = sec.Key("DISABLE_SSH").MustBool()
+ SSHDomain = sec.Key("SSH_DOMAIN").MustString(Domain)
SSHPort = sec.Key("SSH_PORT").MustInt(22)
OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()