mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-05-31 07:08:06 +08:00
Various fixes in login sources (#10428)
This commit is contained in:
@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
// Auth pam auth service
|
||||
func Auth(serviceName, userName, passwd string) error {
|
||||
func Auth(serviceName, userName, passwd string) (string, error) {
|
||||
t, err := pam.StartFunc(serviceName, userName, func(s pam.Style, msg string) (string, error) {
|
||||
switch s {
|
||||
case pam.PromptEchoOff:
|
||||
@ -25,12 +25,14 @@ func Auth(serviceName, userName, passwd string) error {
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
|
||||
if err = t.Authenticate(0); err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
|
||||
return nil
|
||||
// PAM login names might suffer transformations in the PAM stack.
|
||||
// We should take whatever the PAM stack returns for it.
|
||||
return t.GetItem(pam.User)
|
||||
}
|
||||
|
@ -11,6 +11,6 @@ import (
|
||||
)
|
||||
|
||||
// Auth not supported lack of pam tag
|
||||
func Auth(serviceName, userName, passwd string) error {
|
||||
return errors.New("PAM not supported")
|
||||
func Auth(serviceName, userName, passwd string) (string, error) {
|
||||
return "", errors.New("PAM not supported")
|
||||
}
|
||||
|
Reference in New Issue
Block a user