// GetAuthenticatedUser will retrieve the Authentication User from the
// http.Request object.
164155
func (self *GoogleProvider) GetAuthenticatedUser(w http.ResponseWriter, r *http.Request) (User, Token, error) {
	// Get the OAuth2 Access Token
	token, err := self.GetAccessToken(r)
	if err != nil {
		return nil, nil, err
	}

	user := GoogleUser{}
	err = self.OAuth2Mixin.GetAuthenticatedUser("https://www.googleapis.com/oauth2/v2/userinfo", token.AccessToken, &user)
	return &user, token, err
}
319597
func JWTAuthentication(userName, password string) Authentication {
	return &userNameAuthentication{
		authType: AuthenticationTypeJWT,
		userName: userName,
		password: password,
	}
}
860145
func (r Network_Firewall_Update_Request) GetAuthorizingUser() (resp datatypes.User_Interface, err error) {
	err = r.Session.DoRequest("SoftLayer_Network_Firewall_Update_Request", "getAuthorizingUser", nil, &r.Options, &resp)
	return
}
28664
func NewAuthenticatedClient() Client {
	authenticator := newMockAuthenticator(func(request *http.Request) error {
		request.Header.Set("Authorization", "fake-authorization")
		return nil
	})

	return NewClient(authenticator)
}
195891
func (a authenticator) localUserAuth() *authentication.UserAuthenticator {
	localUserIdentityLocation := url.URL{
		Scheme: "https",
		Host:   a.serverHost,
		Path:   localUserIdentityLocationPath,
	}
	return &authentication.UserAuthenticator{
		Service:                   a.ctxt.localUserBakeryService,
		Clock:                     a.ctxt.clock,
		LocalUserIdentityLocation: localUserIdentityLocation.String(),
	}
}
424636
func (a *AuthServer) GetUser(name string) (user services.User, err error) {
	return a.GetCache().GetUser(name)
}
763050
func (c *Client) GetUser(token string) (*User, error) {
	req, err := c.NewRequest("GET", "/user", nil)
	if err != nil {
		return nil, err
	}

	tokenAuth(req, token)

	var u User

	_, err = c.Do(req, &u)
	if err != nil {
		return nil, err
	}

	return &u, nil
}
47936
func (provider *GitlabProvider) GetUser(creds *common.Credentials) (common.User, error) {

	profileData, err := provider.Get(creds, gitlabEndpointProfile)

	if err != nil {
		return nil, err
	}

	// build user
	user := NewUser(profileData, creds, provider)

	return user, nil
}
507115
func (web *webAPIHandlers) GetAuth(r *http.Request, args *WebGenericArgs, reply *GetAuthReply) error {
	_, owner, authErr := webRequestAuthenticate(r)
	if authErr != nil {
		return toJSONError(authErr)
	}
	if !owner {
		return toJSONError(errAccessDenied)
	}
	creds := globalServerConfig.GetCredential()
	reply.AccessKey = creds.AccessKey
	reply.SecretKey = creds.SecretKey
	reply.UIVersion = browser.UIVersion
	return nil
}
1135690
func (provider *HerokuProvider) GetUser(creds *common.Credentials) (common.User, error) {

	profileData, err := provider.Get(creds, herokuEndpointProfile)

	if err != nil {
		return nil, err
	}

	// build user
	user := NewUser(profileData, creds, provider)

	return user, nil
}
1112064
func (mgr *IdentityManager) GetUser(username string) (*User, error) { //nolint

	u, err := mgr.loadUserFromStore(username)
	if err != nil {
		if err != msp.ErrUserNotFound {
			return nil, errors.WithMessage(err, "loading user from store failed")
		}
		// Not found, continue
	}

	if u == nil {
		certBytes := mgr.getEmbeddedCertBytes(username)
		if certBytes == nil {
			certBytes, err = mgr.getCertBytesFromCertStore(username)
			if err != nil && err != msp.ErrUserNotFound {
				return nil, errors.WithMessage(err, "fetching cert from store failed")
			}
		}
		if certBytes == nil {
			return nil, msp.ErrUserNotFound
		}
		privateKey, err := mgr.getEmbeddedPrivateKey(username)
		if err != nil {
			return nil, errors.WithMessage(err, "fetching embedded private key failed")
		}
		if privateKey == nil {
			privateKey, err = mgr.getPrivateKeyFromCert(username, certBytes)
			if err != nil {
				return nil, errors.WithMessage(err, "getting private key from cert failed")
			}
		}
		if privateKey == nil {
			return nil, fmt.Errorf("unable to find private key for user [%s]", username)
		}
		mspID, ok := comm.MSPID(mgr.config, mgr.orgName)
		if !ok {
			return nil, errors.New("MSP ID config read failed")
		}
		u = &User{
			id:                    username,
			mspID:                 mspID,
			enrollmentCertificate: certBytes,
			privateKey:            privateKey,
		}
	}
	return u, nil
}
420417
func HttpAuthenticator(handler func(*http.Request) (bool, interface{}, error)) runtime.Authenticator {
	return runtime.AuthenticatorFunc(func(params interface{}) (bool, interface{}, error) {
		if request, ok := params.(*http.Request); ok {
			return handler(request)
		}
		if scoped, ok := params.(*ScopedAuthRequest); ok {
			return handler(scoped.Request)
		}
		return false, nil, nil
	})
}
438559
func (provider *FacebookProvider) GetUser(creds *common.Credentials) (common.User, error) {

	profileData, err := provider.Get(creds, facebookEndpointProfile)

	if err != nil {
		return nil, err
	}

	// build user
	user := NewUser(profileData, creds, provider)

	return user, nil
}
470881
func (auth *AuthProxy) GetSignedUser(userID int64) (*models.SignedInUser, *Error) {
	query := &models.GetSignedInUserQuery{
		OrgId:  auth.orgID,
		UserId: userID,
	}

	if err := bus.Dispatch(query); err != nil {
		return nil, newError(err.Error(), nil)
	}

	return query.Result, nil
}
1247407
func getUserName(ctx context.Context, r *http.Request) string {
	username := dcontext.GetStringValue(ctx, auth.UserNameKey)

	// Fallback to request user with basic auth
	if username == "" {
		var ok bool
		uname, _, ok := basicAuth(r)
		if ok {
			username = uname
		}
	}

	return username
}
753904
func (service *Service) GetOauthUser(r *http.Request, w http.ResponseWriter) (username string, err error) {
	oauthSession, err := service.GetSession(r, SessionOauth, "oauthsession")
	if err != nil {
		log.Error(err)
		return
	}
	err = oauthSession.Save(r, w)
	if err != nil {
		log.Error(err)
		return
	}
	savedusername := oauthSession.Values["username"]
	if savedusername != nil {
		username, _ = savedusername.(string)
	}
	return
}
904807
func (ctxt *httpContext) stateForRequestAuthenticated(r *http.Request) (
	resultSt *state.PooledState,
	resultEntity state.Entity,
	err error,
) {
	authInfo, ok := httpcontext.RequestAuthInfo(r)
	if !ok {
		return nil, nil, common.ErrPerm
	}
	st, err := ctxt.stateForRequestUnauthenticated(r)
	if err != nil {
		return nil, nil, errors.Trace(err)
	}
	defer func() {
		// Here err is the named return arg.
		if err != nil {
			st.Release()
		}
	}()
	return st, authInfo.Entity, nil
}