// Scopes returns the scopes of the policy.
429644
func (p *PUPolicy) Scopes() []string {
	p.Lock()
	defer p.Unlock()

	return p.scopes
}
479090
func verifyScopes(scopeString string, username string, clientID string, orgMgr *organization.Manager) (string, error) {
	scopes := strings.Split(scopeString, ",")
	for i, scope := range scopes {
		// If the scope is memberof:clientid, where clientid is the globalid of the
		// organization requesting authorization, verify if we really have this scope
		// or if we have the scope on one or more children. In case of the latter, replace
		// the scopes by the appropriate ones
		if scope == "user:memberof:"+clientID {
			inOrg, err := orgMgr.IsInOrgs(username, clientID)
			if err != nil {
				return scopeString, err
			}
			// Should only have 1 result, and result MUST be clientID
			if len(inOrg) == 1 && inOrg[0] == clientID {
				return scopeString, nil
			}

			log.Debugf("Access token contains scope %v, but user is not a member of %v - parse suborganizations",
				scope, clientID)
			// Remove the memberof:parentOrg scope
			scopes = append(scopes[:i], scopes[i+1:]...)
			var subOrgScopes []string
			subOrgScopes, err = findSuborgScopes(clientID, username, orgMgr)
			if err != nil {
				return scope, err
			}
			// Add the correct memberof scopes
			scopes = append(scopes, subOrgScopes...)
			scopeString = strings.Join(scopes, ",")
		}
	}
	return scopeString, nil
}
500413
func (s *GetLifecyclePoliciesOutput) SetPolicies(v []*LifecyclePolicySummary) *GetLifecyclePoliciesOutput {
	s.Policies = v
	return s
}
231754
func (c *ResourceController) Scopes(ctx *app.ScopesResourceContext) error {
	// Load the identity from the context
	currentIdentity, err := c.app.UserService().LoadContextIdentityIfNotBanned(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}

	// Check if the resource exists
	err = c.app.ResourceRepository().CheckExists(ctx, ctx.ResourceID)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}

	// Load the scopes
	pc, err := c.app.PrivilegeCacheService().CachedPrivileges(ctx, currentIdentity.ID, ctx.ResourceID)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}

	scopes := []*app.ResourceScopes{}

	for _, scope := range pc.ScopesAsArray() {
		scopes = append(scopes, &app.ResourceScopes{
			ID:   scope,
			Type: "user_resource_scope",
		})
	}

	res := &app.ResourceScopesData{
		Data: scopes,
	}

	return ctx.OK(res)
}
535813
func (scope *ArgScope) Keys() ([]string, error) {
	keys := make([]string, len(scope.data))
	i := 0
	for key := range scope.data {
		keys[i] = key
		i++
	}
	return keys, nil
}
1048528
func (s *UpdateRouteInput) SetAuthorizationScopes(v []*string) *UpdateRouteInput {
	s.AuthorizationScopes = v
	return s
}
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
}
654490
func policyExtensions(runtime policy.RuntimeReader) (extensions policy.ExtendedMap) {

	if runtime == nil {
		return nil
	}

	if runtime.Options().PolicyExtensions == nil {
		return nil
	}

	if extensions, ok := runtime.Options().PolicyExtensions.(policy.ExtendedMap); ok {
		return extensions
	}
	return nil
}
515029
func (o *Application) Monitorscopes(info *bambou.FetchingInfo) (MonitorscopesList, *bambou.Error) {

	var list MonitorscopesList
	err := bambou.CurrentSession().FetchChildren(o, MonitorscopeIdentity, &list, info)
	return list, err
}
338408
func (claims *Claims) HasScope(scope string) bool {
	return claims != nil && contains(claims.Scope, scope)
}
321182
func (q DomainsQuery) scope(db *gorm.DB) *gorm.DB {
	var scope composedScope

	if q.Hostname != nil {
		scope = append(scope, fieldEquals("hostname", *q.Hostname))
	}

	if q.App != nil {
		scope = append(scope, forApp(q.App))
	}

	return scope.scope(db)
}
128321
func RoleScopeFilterByScope(id uuid.UUID) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		return db.Where("scope_id = ?", id)
	}
}
731829
func (s *CreateUserPoolInput) SetPolicies(v *UserPoolPolicyType) *CreateUserPoolInput {
	s.Policies = v
	return s
}
1204367
func (m *MockAuthorizeRequester) SetRequestedScopes(arg0 fosite.Arguments) {
	m.ctrl.Call(m, "SetRequestedScopes", arg0)
}
789078
func (c *adminClient) Scope(scope string) AdminClient {
	c.scope = scope
	return c
}
1017713
func ScopesToRules(scopes []string, namespace string, clusterRoleGetter rbaclisters.ClusterRoleLister) ([]rbacv1.PolicyRule, error) {
	rules := append([]rbacv1.PolicyRule{}, authorizationapi.DiscoveryRule)

	errors := []error{}
	for _, scope := range scopes {
		found := false

		for _, evaluator := range ScopeEvaluators {
			if evaluator.Handles(scope) {
				found = true
				currRules, err := evaluator.ResolveRules(scope, namespace, clusterRoleGetter)
				if err != nil {
					errors = append(errors, err)
					continue
				}

				rules = append(rules, currRules...)
			}
		}

		if !found {
			errors = append(errors, fmt.Errorf("no scope evaluator found for %q", scope))
		}
	}

	return rules, kutilerrors.NewAggregate(errors)
}
1057941
func CheckScopes(possibleScopes []string, authorizedScopes []string) bool {
	if len(possibleScopes) == 0 {
		return true
	}

	for _, allowed := range possibleScopes {
		for _, scope := range authorizedScopes {
			if scope == allowed {
				return true
			}
		}
	}
	return false
}