// verifyTarget allows requests to be executed even in non-serving state.
960935
func (tsv *TabletServer) verifyTarget(ctx context.Context, target *querypb.Target) error {
	tsv.mu.Lock()
	defer tsv.mu.Unlock()

	if target != nil {
		// a valid target needs to be used
		switch {
		case target.Keyspace != tsv.target.Keyspace:
			return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "invalid keyspace %v", target.Keyspace)
		case target.Shard != tsv.target.Shard:
			return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "invalid shard %v", target.Shard)
		case target.TabletType != tsv.target.TabletType:
			for _, otherType := range tsv.alsoAllow {
				if target.TabletType == otherType {
					return nil
				}
			}
			return vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "invalid tablet type: %v, want: %v or %v", target.TabletType, tsv.target.TabletType, tsv.alsoAllow)
		}
	} else if !tabletenv.IsLocalContext(ctx) {
		return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "No target")
	}
	return nil
}
897034
func (c *UsersController) VerifyEmail(ctx *app.VerifyEmailUsersContext) error {
	verifiedCode, err := c.EmailVerificationService.VerifyCode(ctx, ctx.Code)
	var errResponse string
	isVerified := true
	if err != nil {
		errResponse = err.Error()
		isVerified = false
	} else if verifiedCode == nil {
		errResponse = "unable to verify code"
		isVerified = false
	}
	redirectURL, err := rest.AddParam(c.config.GetEmailVerifiedRedirectURL(), "verified", fmt.Sprint(isVerified))
	if err != nil {
		return err
	}
	if errResponse != "" {
		redirectURL, err = rest.AddParam(redirectURL, "error", errResponse)
		if err != nil {
			return err
		}
	}

	ctx.ResponseData.Header().Set("Location", redirectURL)
	return ctx.TemporaryRedirect()
}
876858
func (s *ScraperTargetStoreService) AddTarget(ctx context.Context, st *influxdb.ScraperTarget, userID influxdb.ID) error {
	p, err := influxdb.NewPermission(influxdb.WriteAction, influxdb.ScraperResourceType, st.OrgID)
	if err != nil {
		return err
	}

	if err := IsAllowed(ctx, *p); err != nil {
		return err
	}

	return s.s.AddTarget(ctx, st, userID)
}
195295
func (s *Session) SetTarget(v string) *Session {
	s.Target = &v
	return s
}
60637
func (c *Client) RemoveTarget(ctx context.Context, id influxdb.ID) error {
	err := c.db.Update(func(tx *bolt.Tx) error {
		_, pe := c.findTargetByID(ctx, tx, id)
		if pe != nil {
			return pe
		}
		encID, err := id.Encode()
		if err != nil {
			return &influxdb.Error{
				Code: influxdb.EInvalid,
				Err:  err,
			}
		}
		if err = tx.Bucket(scraperBucket).Delete(encID); err != nil {
			return nil
		}
		return c.deleteUserResourceMappings(ctx, tx, influxdb.UserResourceMappingFilter{
			ResourceID:   id,
			ResourceType: influxdb.ScraperResourceType,
		})
	})
	if err != nil {
		return &influxdb.Error{
			Err: err,
			Op:  OpPrefix + influxdb.OpRemoveTarget,
		}
	}
	return nil
}
178033
func (s *UpdateRouteInput) SetTarget(v string) *UpdateRouteInput {
	s.Target = &v
	return s
}
691627
func (launcher *Launcher) SetTarget(target string) {
	launcher.Mutex.Lock()
	launcher.target = target
	launcher.Mutex.Unlock()
}
1144357
func (actor Actor) CheckTarget(targetedOrganizationRequired bool, targetedSpaceRequired bool) error {
	if !actor.IsLoggedIn() {
		return actionerror.NotLoggedInError{
			BinaryName: actor.Config.BinaryName(),
		}
	}

	if targetedOrganizationRequired {
		if !actor.IsOrgTargeted() {
			return actionerror.NoOrganizationTargetedError{
				BinaryName: actor.Config.BinaryName(),
			}
		}

		if targetedSpaceRequired {
			if !actor.IsSpaceTargeted() {
				return actionerror.NoSpaceTargetedError{
					BinaryName: actor.Config.BinaryName(),
				}
			}
		}
	}

	return nil
}
149894
func Verify(r *http.Request, opts ...VerifyOption) error {
	o := &VerifyOptions{
		cookieName:    XSRFCookieName,
		headerName:    XSRFHeaderName,
		formFieldName: XSRFFormFieldName,
	}
	for _, opt := range opts {
		opt(o)
	}

	if contains(safeMethods, r.Method) {
		return nil
	}

	referer, err := url.Parse(r.Header.Get("Referer"))
	if err != nil {
		return err
	}
	if referer.String() == "" {
		return ErrNoReferer
	}

	if !(r.Host == referer.Host) {
		return ErrInvalidReferer
	}

	token, err := r.Cookie(o.cookieName)
	if err != nil {
		if err.Error() == "http: named cookie not present" {
			return ErrMissingCookie
		}
		return err
	}

	if contains([]string{"application/x-www-form-urlencoded", "multipart/form-data"}, r.Header.Get("Content-Type")) {
		if r.FormValue(o.formFieldName) == token.Value {
			return nil
		}
	}

	if token.Value == "" {
		return ErrMissingToken
	}

	header := r.Header.Get(o.headerName)

	if header == "" {
		return ErrMissingHeader
	}

	if header == token.Value {
		return nil
	}

	return ErrInvalidToken
}
1251230
func (g *Cloud) ListTargetHTTPProxies() ([]*compute.TargetHttpProxy, error) {
	ctx, cancel := cloud.ContextWithCallTimeout()
	defer cancel()

	mc := newTargetProxyMetricContext("list")
	v, err := g.c.TargetHttpProxies().List(ctx, filter.None)
	return v, mc.Observe(err)
}
538192
func (s *StartSessionInput) SetTarget(v string) *StartSessionInput {
	s.Target = &v
	return s
}
21940
func (s *SecurityProfileTargetMapping) SetTarget(v *SecurityProfileTarget) *SecurityProfileTargetMapping {
	s.Target = v
	return s
}
184734
func (s *StatusEvent) GetTargetURL() string {
	if s == nil || s.TargetURL == nil {
		return ""
	}
	return *s.TargetURL
}
306870
func (m *MockConnector) ReplyTarget(msg *Message) string {
	ret := m.ctrl.Call(m, "ReplyTarget", msg)
	ret0, _ := ret[0].(string)
	return ret0
}
532919
func (s *Service) RemoveTarget(ctx context.Context, id influxdb.ID) error {
	return s.kv.Update(ctx, func(tx Tx) error {
		return s.removeTarget(ctx, tx, id)
	})
}
1266016
func (verify *VerifyClientController) InitialKeyVerifyRequest() io.Reader {
	out := util.NewTLV8Container()
	out.SetByte(TagPairingMethod, 0)
	out.SetByte(TagSequence, VerifyStepStartRequest.Byte())
	out.SetBytes(TagPublicKey, verify.session.PublicKey[:])

	fmt.Println("<-     A:", hex.EncodeToString(out.GetBytes(TagPublicKey)))

	return out.BytesBuffer()
}
10645
func (g *Cloud) GetTargetHTTPProxy(name string) (*compute.TargetHttpProxy, error) {
	ctx, cancel := cloud.ContextWithCallTimeout()
	defer cancel()

	mc := newTargetProxyMetricContext("get")
	v, err := g.c.TargetHttpProxies().Get(ctx, meta.GlobalKey(name))
	return v, mc.Observe(err)
}