package auth

import "github.com/msteinert/pam"

func Authenticate(username, password string) error {
	t, err := pam.StartFunc(PAMService, username, func(s pam.Style, msg string) (string, error) {
		if s == pam.PromptEchoOff {
			return password, nil
		}
		return "", nil
	})

	if err != nil {
		return err
	}

	return t.Authenticate(0)
}
