with set for roles (protected to be hidden in js ctrls)
777129
protected Apikey createFromMap(@Nullable String user, long start, long duration, @Nullable List<String> roles, Map<String, Object> nameAndValMap) {
		return createFromMap(user, start, duration, toArr(roles), nameAndValMap);
	}
984913
public void setRole(java.lang.String role) {
        getStateHelper().put(PropertyKeys.role, role);
        handleAttribute("role", role);
    }
994539
def has_any_roles(self, *roles):
        
        roles = map(utils.slugify, list(roles))

        return True \
            if AuthUserRole.query() \
            .join(AuthUser) \
            .filter(AuthUserRole.name.in_(roles)) \
            .filter(AuthUser.id == self.id) \
            .count() \
            else False
992284
def role_admin():
    """"""
    identity = g.identity
    actions = {}
    for action in access.actions.values():
        actions[action.value] = DynamicPermission(action).allows(identity)

    message = 'You are opening a page requiring the "admin-access" permission'
    return render_template("invenio_access/limited.html",
                           message=message,
                           actions=actions,
                           identity=identity)
54429
def roles_required(*required_rolenames):
    
    def decorator(method):
        @functools.wraps(method)
        def wrapper(*args, **kwargs):
            role_set = set([str(n) for n in required_rolenames])
            _verify_and_add_jwt()
            try:
                MissingRoleError.require_condition(
                    current_rolenames().issuperset(role_set),
                    "This endpoint requires all the following roles: {}",
                    [', '.join(role_set)],
                )
                return method(*args, **kwargs)
            finally:
                remove_jwt_data_from_app_context()
        return wrapper
    return decorator
55945
function Roler() {

        /**
         * ### Roler.roles
         *
         * List of all available roles
         *
         * @see Roler.setRoles
         */
        this.roles = {};

        /**
         * ### Roler.rolesArray
         *
         * The array of currently available roles
         *
         * @see Roler.setRoles
         * @see Roler.clear
         */
        this.rolesArray = [];

        /**
         * ### Roler.rolifiedMatches
         *
         * Array of arrays of roles assigned for all matches in all rounds
         *
         * For example:
         * ```javascript
         * [
         *     // Round 1.
         *     [  [ 'ROLE_A', 'ROLE_B' ], [ 'ROLE_A', 'ROLE_B' ], ... ],
         *     // Round 2.
         *     [  [ 'ROLE_A', 'ROLE_B' ], [ 'ROLE_A', 'ROLE_B' ], ... ],
         *     ...
         * ]
         * ```
         *
         * @see Roler.rolifyAll
         * @see Roler.setRolifiedMatches
         */
        this.rolifiedMatches = null;

        /**
         * ### Roler.role2IdMatches
         *
         * Array of arrays of maps role to id/s for all matches in all rounds
         *
         * For example:
         * ```javascript
         * [
         *     [ { ROLE_A: 'ID1', ROLE_B: 'ID2' }, ... ], // Round 1.
         *     [ { ROLE_A: [ 'ID1', 'ID2' ] }, ... ], // Round 2.
         *     ...
         * ]
         * ```
         *
         * @see Roler.rolifyAll
         * @see Roler.setRolifiedMatches
         */
        this.role2IdMatches = null;

        /**
         * ### Roler.id2RoleMatches
         *
         * Array of arrays of maps id to role for all matches in all rounds
         *
         * For example:
         * ```javascript
         * [
         *     [ { ID1: 'ROLE_A', ID2: 'ROLE_B' }, ... ], // Round 1.
         *     [ { ID1: 'ROLE_A', ID2: 'ROLE_A' }, ... ], // Round 2.
         *     ...
         * ]
         * ```
         *
         * @see Roler.rolifyAll
         * @see Roler.setRolifiedMatches
         */
        this.id2RoleMatches = null;

        /**
         * ### Roler.role2IdRoundMap
         *
         * Array of maps of role to id/s per each round
         *
         * For example:
         * ```javascript
         * [
         *     // Round 1.
         *     [ { ROLE_A: [ 'ID1', 'ID3', ... ], ROLE_B: 'ID2', ... } ],
         *     // Round 2.
         *     [ { ROLE_A: [ 'ID1', 'ID2', ... ], ROLE_B: 'ID3', ... } ],
         *     ...
         * ]
         * ```
         */
        this.role2IdRoundMap = [];

        /**
         * ### Roler.rolify
         *
         * Callback that assigns roles to a single match
         *
         * @see Roler.linearRolifier
         */
        this.rolify = Roler.linearRolifier;

        /**
         * ### Roler.missingId
         *
         * The id indicating a skipped match (i.e. a bye in a match)
         *
         * @see Matcher.missingId
         */
        this.missingId = 'bot';
    }
243754
private RoleSet rolesForAccessId(String accessId) {
        if (AccessIdUtil.isServerAccessId(accessId)) {
            return ADMIN_ROLE_SET;
        }

        RoleSet roles = accessIdToRoles.get(accessId);
        if (roles == null) {
            return findRolesForAccessId(accessId);
        } else {
            return roles;
        }
    }
535875
static SafeHtml roleItem(final String css, final Role role) {
        if (role.isStandard()) {
            return ITEMS.item(css, role.getName(), role.getName());
        } else {
            return ITEMS.scopedRole(css, role.getName(), baseAndScope(role), shortBaseAndScope(role));
        }
    }
1273235
def set_roles *roles
      roles = roles.flatten
      raise ArgumentError, "For a single role strategy you can only set one role, was: #{roles.flatten}" if roles.empty? || (roles.size > 1)
      set_role roles.first
    end
1327453
function setRuleModule (roles, rule, rules, origRule) {
    // allow/deny is last element of rule
    var allow = rule.pop()
    // blanket rule for all modules
    if (rule.length === 0) {
        // create role access rule map
        if (!rules.allow) {
            rules.allow = {}
        }
        // set rule for each role
        _.each(roles, role => {
            rules.allow[role] = allow
        })
        // break
        return
    }

    // module name is first clause of rule
    var module = rule.shift()
    // create map of models
    if (!rules.module) {
        rules.module = {}
    }
    // create entry for module
    if (!rules.module[module]) {
        rules.module[module] = {}
    }

    // blanket rule for single module
    if (rule.length === 0) {
        // create role access rule map
        if (!rules.module[module].allow) {
            rules.module[module].allow = {}
        }
        // set rule for each role
        _.each(roles, role => {
            rules.module[module].allow[role] = allow
        })
    }
    // rule for method
    else if (rule.length === 1) {
        var method = rule.shift()
        // create map of methods
        if (!rules.module[module].method) {
            rules.module[module].method = {}
        }
        // create method entry
        if (!rules.module[module].method[method]) {
            rules.module[module].method[method] = {}
        }
        // create role access rule map
        if (!rules.module[module].method[method].allow) {
            rules.module[module].method[method].allow = {}
        }
        // set rule for each role
        _.each(roles, role => {
            rules.module[module].method[method].allow[role] = allow
        })
    }
    // invalid rule
    else {
        throw new Error('invalid rule '+origRule)
    }
}
306456
def process_role(ctx, param, value):
    """"""
    role = Role.query.filter(Role.name == value).first()
    if not role:
        raise click.BadParameter('Role with name \'%s\' not found.', value)
    return role
169124
def set_roles *roles
      raise ArgumentError, "A single role strategy can only allow setting a single role, was: #{roles}" if (roles.size > 1)
      set_role roles.flat_uniq.first
    end
1246741
def get_roles(self, groups):
        """"""
        roles = set([])
        parentroles = set([])
        notroles = set([])
        tmp = set([])
        usedgroups = {}
        unusedgroups = {}
        ret = {}
        # determine roles membership
        for role in self.roles:
            if self._check_member(
                    role, groups, notroles,
                    tmp, parentroles, usedgroups):
                roles.add(role)
        # determine standalone groups not matching any roles
        for b in groups:
            for g in groups[b]:
                if b not in usedgroups or g not in usedgroups[b]:
                    if b not in unusedgroups:
                        unusedgroups[b] = set([])
                    unusedgroups[b].add(g)

        ret['roles'] = roles
        ret['unusedgroups'] = unusedgroups
        return ret
190638
function getParent(role) {
        var result = [];

        for (var parentRole in permissions) {
            if (permissions[parentRole].indexOf(role) > -1) {
                result.push(parentRole);
                result = result.concat(getParent(parentRole));
            }
        }
        return result;
    }
973708
function getAriaQueryAttributes() {
				const ariaKeys = Array.from(props).map(([key]) => key);
				const roleAriaKeys = Array.from(roles).reduce((out, [name, rule]) => {
					return [...out, ...Object.keys(rule.props)];
				}, []);
				return new Set(axe.utils.uniqueArray(roleAriaKeys, ariaKeys));
			}
592220
function removeRolePrivilege (access, role, privilege) {
  if (role === true) {
    access[privilege] = {
      role: []
    }
    return
  }

  if (access[privilege].role === true) {
    access[privilege].role = true
  }

  _.pullAll(access[privilege].role, _.concat(role))
}
1330016
def has_roles_mask_accessors?
      instance_method_names = instance_methods.map { |method_name| method_name.to_s }
      [roles_attribute_name.to_s, "#{roles_attribute_name}="].all? do |accessor| 
        instance_method_names.include?(accessor)
      end
    end