Authenticates a user given the username and password. If the username and password are both "", it will return a default empty User object, not nil.
(username string, password string)
| 772 | // Authenticates a user given the username and password. |
| 773 | // If the username and password are both "", it will return a default empty User object, not nil. |
| 774 | func (auth *Authenticator) AuthenticateUser(username string, password string) (User, error) { |
| 775 | user, err := auth.GetUser(username) |
| 776 | if err != nil && !base.IsDocNotFoundError(err) { |
| 777 | return nil, err |
| 778 | } |
| 779 | |
| 780 | if user == nil { |
| 781 | base.InfofCtx(auth.LogCtx, base.KeyAuth, "HTTP auth failed for username=%q: user not found", base.UD(username)) |
| 782 | return nil, nil |
| 783 | } |
| 784 | |
| 785 | authenticated, reason := user.AuthenticateWithReason(password) |
| 786 | if !authenticated { |
| 787 | base.InfofCtx(auth.LogCtx, base.KeyAuth, "HTTP auth failed for username=%q: %s", base.UD(username), reason) |
| 788 | return nil, nil |
| 789 | } |
| 790 | |
| 791 | return user, nil |
| 792 | } |
| 793 | |
| 794 | func (auth *Authenticator) AuthenticateUntrustedJWT(rawToken string, oidcProviders OIDCProviderMap, localJWT LocalJWTProviderMap, callbackURLFunc OIDCCallbackURLFunc) (User, PrincipalConfig, error) { |
| 795 |
no test coverage detected