// WithRequiredScopes builds a context containing the given required scopes.
12550
func WithRequiredScopes(ctx context.Context, scopes []string) context.Context {
	return context.WithValue(ctx, securityScopesKey, scopes)
}
1329879
func getSecurityScopes(ss raml.DefinitionChoice) ([]string, error) {
	scopes := []string{}

	// check if there is scopes
	v, ok := ss.Parameters["scopes"]
	if !ok {
		return scopes, nil
	}

	// cast it to []string, return error if failed
	scopesArr, ok := v.([]interface{})
	if !ok {
		return scopes, fmt.Errorf("scopes must be array")
	}

	// build []string
	for _, s := range scopesArr {
		scopes = append(scopes, s.(string))
	}
	return scopes, nil
}
827679
func GetQuotedScopes(ss raml.DefinitionChoice) ([]string, error) {
	var quoted []string
	scopes, err := getSecurityScopes(ss)
	if err != nil {
		return quoted, err
	}
	for _, s := range scopes {
		quoted = append(quoted, fmt.Sprintf(`"%v"`, s))
	}
	return quoted, nil
}
634099
func Scopes() []string {
	// E-mail scope needed for Coordinator authentication.
	scopes := []string{auth.OAuthScopeEmail}
	// Publisher scope needed to publish to Pub/Sub transport.
	scopes = append(scopes, ps.PublisherScopes...)

	return scopes
}
942350
func (s composedScope) scope(db *gorm.DB) *gorm.DB {
	for _, s := range s {
		db = s.scope(db)
	}

	return db
}
442403
func (c *EncodedConn) RequestWithContext(ctx context.Context, subject string, v interface{}, vPtr interface{}) error {
	if ctx == nil {
		return ErrInvalidContext
	}

	b, err := c.Enc.Encode(subject, v)
	if err != nil {
		return err
	}
	m, err := c.Conn.RequestWithContext(ctx, subject, b)
	if err != nil {
		return err
	}
	if reflect.TypeOf(vPtr) == emptyMsgType {
		mPtr := vPtr.(*Msg)
		*mPtr = *m
	} else {
		err := c.Enc.Decode(m.Subject, m.Data, vPtr)
		if err != nil {
			return err
		}
	}

	return nil
}
1206172
func WithResources(ctx context.Context, resources []Resource) context.Context {
	return resourceContext{
		Context:   ctx,
		resources: resources,
	}
}
243135
func (api OrganizationsAPI) AddRequiredScope(w http.ResponseWriter, r *http.Request) {
	globalID := mux.Vars(r)["globalid"]
	var requiredScope organization.RequiredScope
	if err := json.NewDecoder(r.Body).Decode(&requiredScope); err != nil {
		log.Debug("Error while adding a required scope: ", err.Error())
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}
	if !requiredScope.IsValid() {
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}
	mgr := organization.NewManager(r)
	organisation, err := mgr.GetByName(globalID)
	if err == mgo.ErrNotFound {
		writeErrorResponse(w, http.StatusNotFound, "organization_not_found")
		return
	}
	for _, scope := range organisation.RequiredScopes {
		if scope.Scope == requiredScope.Scope {
			writeErrorResponse(w, http.StatusConflict, "required_scope_already_exists")
			return
		}
	}
	err = mgr.AddRequiredScope(globalID, requiredScope)
	if err != nil {
		handleServerError(w, "adding a required scope", err)
	} else {
		w.WriteHeader(http.StatusCreated)
	}
}
462680
func (m *MockRequester) AppendRequestedScope(arg0 string) {
	m.ctrl.Call(m, "AppendRequestedScope", arg0)
}
1336074
func (o *objectCountEvaluator) UncoveredQuotaScopes(limitedScopes []corev1.ScopedResourceSelectorRequirement, matchedQuotaScopes []corev1.ScopedResourceSelectorRequirement) ([]corev1.ScopedResourceSelectorRequirement, error) {
	return []corev1.ScopedResourceSelectorRequirement{}, nil
}
98669
func (call *GetUserRichMenuCall) WithContext(ctx context.Context) *GetUserRichMenuCall {
	call.ctx = ctx
	return call
}
1210737
func (s *permissionServiceImpl) RequireScope(ctx context.Context, identityID uuid.UUID, resourceID string, scopeName string) error {
	result, err := s.HasScope(ctx, identityID, resourceID, scopeName)
	if err != nil {
		return errors.NewInternalError(ctx, err)
	}

	if !result {
		return errors.NewForbiddenError(fmt.Sprintf("identity with ID %s does not have required scope %s for resource %s", identityID.String(), scopeName, resourceID))
	}

	return nil
}
187486
func (call *CreateRichMenuCall) WithContext(ctx context.Context) *CreateRichMenuCall {
	call.ctx = ctx
	return call
}
260969
func WithRetries(req *http.Request, n int) *http.Request {
	ctx := req.Context()
	ctx = context.WithValue(ctx, contextKeyRetries, n)

	return req.WithContext(ctx)
}
429644
func (p *PUPolicy) Scopes() []string {
	p.Lock()
	defer p.Unlock()

	return p.scopes
}
1348654
func Convert_core_ScopedResourceSelectorRequirement_To_v1_ScopedResourceSelectorRequirement(in *core.ScopedResourceSelectorRequirement, out *v1.ScopedResourceSelectorRequirement, s conversion.Scope) error {
	return autoConvert_core_ScopedResourceSelectorRequirement_To_v1_ScopedResourceSelectorRequirement(in, out, s)
}
934901
func (m *Manager) DeleteRequiredScope(globalId string, requiredScope string) error {
	return m.collection.Update(bson.M{"globalid": globalId},
		bson.M{"$pull": bson.M{"requiredscopes": bson.M{"scope": requiredScope}}})
}