Various fixes in login sources (#10428)

This commit is contained in:
guillep2k 2020-02-23 16:52:05 -03:00 committed by GitHub
parent 542bd59239
commit 09dbd85a3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 66 additions and 21 deletions

View file

@ -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)
}

View file

@ -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")
}

View file

@ -35,7 +35,7 @@ func TestIncludesAllRepositoriesTeams(t *testing.T) {
// Create org.
org := &models.User{
Name: "All repo",
Name: "All_repo",
IsActive: true,
Type: models.UserTypeOrganization,
Visibility: structs.VisibleTypePublic,