// Authorize runs the authorize action.
338906
func (c *LoginController) Authorize(ctx *app.AuthorizeLoginContext) error {
	return redirectWithParams(ctx, c.configuration, ctx.ResponseData.Header(), ctx.Params, authservice.LoginLoginPath())
}
1083665
func (s *storage) LoadAuthorize(code string) (*osin.AuthorizeData, error) {
	authorize, err := s.authorizetoken.Get(code, metav1.GetOptions{})
	if kerrors.IsNotFound(err) {
		klog.V(5).Info("Authorization code not found")
		return nil, nil
	}
	if err != nil {
		return nil, err
	}
	return s.convertFromAuthorizeToken(authorize)
}
576156
func (m *Manager) UpdateAuthorization(authorization *Authorization) (err error) {
	_, err = m.getAuthorizationCollection().Upsert(bson.M{"username": authorization.Username, "grantedto": authorization.GrantedTo}, authorization)
	return
}
1213650
func Authorize(sarClient v1.SubjectAccessReviewInterface, user user.Info, resourceAttributes *authorizationv1.ResourceAttributes) error {
	sar := AddUserToSAR(user, &authorizationv1.SubjectAccessReview{
		Spec: authorizationv1.SubjectAccessReviewSpec{
			ResourceAttributes: resourceAttributes,
		},
	})

	resp, err := sarClient.Create(sar)
	if err == nil && resp != nil && resp.Status.Allowed {
		return nil
	}

	if err == nil {
		err = errors.New(resp.Status.Reason)
	}
	return kerrors.NewForbidden(schema.GroupResource{Group: resourceAttributes.Group, Resource: resourceAttributes.Resource}, resourceAttributes.Name, err)
}
836969
func (this *AuthorizationServer) HandlerAuthorize(request http.Request, response http.Response) (string, error) {
	reponseType := request.GetParam(util.OAUTH_RESPONSE_TYPE)
	if reponseType == "" {
		reponseType = request.GetParamUri(util.OAUTH_RESPONSE_TYPE)
	}

	if reponseType == "" {
		return "", util.NewInvalidRequestError(util.OAUTH_RESPONSE_TYPE)
	}

	if _, ok := this.authzs[reponseType]; !ok {
		return "", util.NewUnSupportedGrantTypeError(reponseType)
	}

	result, err := this.authzs[reponseType].HandleResponse(request)
	if err != nil {
		return "", err
	}

	return result, nil
}
904869
func (authzHandler unionAuthzHandler) Authorize(a authorizer.Attributes) (authorizer.Decision, string, error) {
	var (
		errlist    []error
		reasonlist []string
	)

	for _, currAuthzHandler := range authzHandler {
		decision, reason, err := currAuthzHandler.Authorize(a)

		if err != nil {
			errlist = append(errlist, err)
		}
		if len(reason) != 0 {
			reasonlist = append(reasonlist, reason)
		}
		switch decision {
		case authorizer.DecisionAllow, authorizer.DecisionDeny:
			return decision, reason, err
		case authorizer.DecisionNoOpinion:
			// continue to the next authorizer
		}
	}

	return authorizer.DecisionNoOpinion, strings.Join(reasonlist, "\n"), utilerrors.NewAggregate(errlist)
}
1070878
func (c *cookie) Authorize(ctx context.Context, w http.ResponseWriter, p Principal) error {
	// Principal will be issued at Now() and will expire
	// c.Inactivity into the future
	now := c.Now()
	p.IssuedAt = now
	p.ExpiresAt = now.Add(c.Inactivity)

	token, err := c.Tokens.Create(ctx, p)
	if err != nil {
		return err
	}

	// The time when the cookie expires
	exp := now.Add(c.Lifespan)
	c.setCookie(w, string(token), exp)

	return nil
}
91619
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) {
	p := provider.(*Provider)
	accessToken, err := p.consumer.AuthorizeToken(s.RequestToken, params.Get("oauth_verifier"))
	if err != nil {
		return "", err
	}

	s.AccessToken = accessToken
	return accessToken.Token, err
}
662923
func (c *Client) Authorize(password string) (response *Packet, err error) {
	if response, err = c.Send(Auth, password); nil == err {
		if response.Header.Type == AuthResponse {
			c.Authorized = true
		} else {
			err = ErrFailedAuthorization
			response = nil
			return
		}
	}

	return
}
1011347
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) {
	p := provider.(*Provider)
	v := url.Values{
		"grant_type":   {"authorization_code"},
		"code":         CondVal(params.Get("code")),
		"redirect_uri": CondVal(p.config.RedirectURL),
		"scope":        CondVal(strings.Join(p.config.Scopes, " ")),
	}
	//Cant use standard auth2 implementation as yammer returns access_token as json rather than string
	//stand methods are throwing exception
	//token, err := p.config.Exchange(goth.ContextForClient(p.Client), params.Get("code"))
	autData, err := retrieveAuthData(p, tokenURL, v)
	if err != nil {
		return "", err
	}
	token := autData["access_token"]["token"].(string)
	s.AccessToken = token
	return token, err
}
723144
func (s *storage) SaveAuthorize(data *osin.AuthorizeData) error {
	token, err := s.convertToAuthorizeToken(data)
	if err != nil {
		return err
	}
	_, err = s.authorizetoken.Create(token)
	return err
}
691865
func (a *alwaysAllowAuth) Authorize(_ context.Context, req *server.NodeRegistration) error {
	req.Status.Allowed = true

	return nil
}
16492
func (s *Storage) SaveAuthorize(data *osin.AuthorizeData) (err error) {
	extra, err := assertToString(data.UserData)
	if err != nil {
		return err
	}

	if _, err = s.db.Exec(
		"INSERT INTO authorize (client, code, expires_in, scope, redirect_uri, state, created_at, extra) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
		data.Client.GetId(),
		data.Code,
		data.ExpiresIn,
		data.Scope,
		data.RedirectUri,
		data.State,
		data.CreatedAt,
		extra,
	); err != nil {
		return errors.New(err)
	}
	return nil
}
1232697
func (s *UsersService) UpdateAuthorization(grantedTo, username string, body Authorization, headers, queryParams map[string]interface{}) (*http.Response, error) {
	var err error

	resp, err := s.client.doReqWithBody("PUT", s.client.BaseURI+"/users/"+username+"/authorizations/"+grantedTo, &body, headers, queryParams)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	return resp, err
}
903633
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) {
	p := provider.(*Provider)
	sess, err := p.GetSession(params.Get("token"))
	if err != nil {
		return "", err
	}

	s.AccessToken = sess["token"]
	s.Login = sess["login"]
	return sess["token"], err
}
154836
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) {
	p := provider.(*Provider)
	token, err := p.config.Exchange(goth.ContextForClient(p.Client()), params.Get("code"))
	if err != nil {
		return "", err
	}

	if !token.Valid() {
		return "", errors.New("Invalid token received from provider")
	}

	email, ok := token.Extra("email").(string)
	if !ok {
		return "", errors.New("Cannot fetch user email")
	}

	s.AccessToken = token.AccessToken
	s.ExpiresAt = token.Expiry
	s.email = email
	return s.AccessToken, err
}
662287
func (d *DigestAuth) Authorize(c *Client, method string, path string) {
	d.digestParts["uri"] = path
	d.digestParts["method"] = method
	d.digestParts["username"] = d.user
	d.digestParts["password"] = d.pw
	c.headers.Set("Authorization", getDigestAuthorization(d.digestParts))
}