MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / AuthenticateUser

Method AuthenticateUser

auth/auth.go:774–792  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
774func (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
794func (auth *Authenticator) AuthenticateUntrustedJWT(rawToken string, oidcProviders OIDCProviderMap, localJWT LocalJWTProviderMap, callbackURLFunc OIDCCallbackURLFunc) (User, PrincipalConfig, error) {
795

Callers 1

setUserForPublicAuthMethod · 0.80

Calls 5

GetUserMethod · 0.95
IsDocNotFoundErrorFunction · 0.92
InfofCtxFunction · 0.92
UDFunction · 0.92

Tested by

no test coverage detected