From 182003aa417ba67661c6743e0fabe6e1f67efd1c Mon Sep 17 00:00:00 2001 From: Paolo Borelli Date: Thu, 23 Apr 2015 13:58:57 +0200 Subject: Add PAM authentication --- modules/auth/pam/pam.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 modules/auth/pam/pam.go (limited to 'modules/auth/pam/pam.go') 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 +} -- cgit v1.2.3 From 81adbe17caf4ff8d7fc920dfe661640ab248ad12 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 14 Jul 2015 19:47:20 +0800 Subject: use pam and update TRANSLATORS --- .travis.yml | 2 +- conf/locale/TRANSLATORS | 1 + gogs.go | 2 +- modules/auth/pam/pam.go | 2 +- modules/auth/pam/pam_stub.go | 2 +- templates/.VERSION | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) (limited to 'modules/auth/pam/pam.go') diff --git a/.travis.yml b/.travis.yml index 113773d6..b6b815c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ before_install: - sudo apt-get update -qq - sudo apt-get install -y libpam-dev -script: go build -v +script: go build -v -tags "pam" notifications: email: diff --git a/conf/locale/TRANSLATORS b/conf/locale/TRANSLATORS index 6680539e..c94b6226 100644 --- a/conf/locale/TRANSLATORS +++ b/conf/locale/TRANSLATORS @@ -2,6 +2,7 @@ # Order of name is meaningless. Akihiro YAGASAKI +Alexander Steinhöfer Christoph Kisfeld Huimin Wang Thomas Fanninger diff --git a/gogs.go b/gogs.go index ecd93275..958792e0 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.6.1.0710 Beta" +const APP_VER = "0.6.1.0714 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/modules/auth/pam/pam.go b/modules/auth/pam/pam.go index 7d150b1c..7f326d42 100644 --- a/modules/auth/pam/pam.go +++ b/modules/auth/pam/pam.go @@ -1,4 +1,4 @@ -// +build !windows +// +build pam // Copyright 2014 The Gogs Authors. All rights reserved. // Use of this source code is governed by a MIT-style diff --git a/modules/auth/pam/pam_stub.go b/modules/auth/pam/pam_stub.go index 2f210bf6..33ac751a 100644 --- a/modules/auth/pam/pam_stub.go +++ b/modules/auth/pam/pam_stub.go @@ -1,4 +1,4 @@ -// +build windows +// +build !pam // Copyright 2014 The Gogs Authors. All rights reserved. // Use of this source code is governed by a MIT-style diff --git a/templates/.VERSION b/templates/.VERSION index 02495355..627dda90 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.6.1.0710 Beta \ No newline at end of file +0.6.1.0714 Beta \ No newline at end of file -- cgit v1.2.3