Allow given group access to a given subject.
335767
def AuthorizeGroup(self, group, subject):
    """"""

    # Add the subject to the dict if is isn't present, so it will get checked in
    # CheckPermissions
    self.authorized_users.setdefault(subject, set())
    self.group_access_manager.AuthorizeGroup(group, subject)
819240
def update_security_group(self, security_group, body=None):
        """"""
        return self.put(self.security_group_path %
                        security_group, body=body)
777681
void checkTopicPublishPermission(String topic) {
        SecurityManager sm = System.getSecurityManager();
        if (sm == null)
            return;

        sm.checkPermission(new TopicPermission(topic, PUBLISH));
    }
326492
def process_allow_action(processors, action, argument):
    """"""
    for processor in processors:
        processor(action, argument)
    db.session.commit()
780072
function (thing, group) {
            var pname = kb.any(thing, ns.vcard('fn'))
            var gname = kb.any(group, ns.vcard('fn'))
            var groups = kb.each(null, ns.vcard('hasMember'), thing)
            if (groups.length < 2) {
              alert('Must be a member of at least one group.  Add to another group first.')
              return
            }
            var message = 'Remove ' + pname + ' from group ' + gname + '?'
            if (confirm(message)) {
              var del = [ $rdf.st(group, ns.vcard('hasMember'), thing, group.doc()),
                $rdf.st(thing, ns.vcard('fn'), pname, group.doc())]
              kb.updater.update(del, [], function (uri, ok, err) {
                if (!ok) return complain('Error removing member from group ' + group + ': ' + err)
                console.log('Removed ' + pname + ' from group ' + gname)
                syncGroupList()
              })
            }
          }
185444
def allow(ctx, foreign_account, permission, weight, threshold, account):
    
    if not foreign_account:
        from peerplaysbase.account import PasswordKey

        pwd = click.prompt(
            "Password for Key Derivation", hide_input=True, confirmation_prompt=True
        )
        foreign_account = format(
            PasswordKey(account, pwd, permission).get_public(), "PPY"
        )
    pprint(
        ctx.peerplays.allow(
            foreign_account,
            weight=weight,
            account=account,
            permission=permission,
            threshold=threshold,
        )
    )
1072223
def permitted_query(self, query, group, operations):
        ''''''
        session = query.session
        models = session.router
        user = group.user
        if user.is_superuser:   # super-users have all permissions
            return query
        roles = group.roles.query()
        roles = group.roles.query()  # query on all roles for group
        # The throgh model for Role/Permission relationship
        throgh_model = models.role.permissions.model
        models[throgh_model].filter(role=roles,
                                    permission__model_type=query.model,
                                    permission__operations=operations)

        # query on all relevant permissions
        permissions = router.permission.filter(model_type=query.model,
                                               level=operations)

        owner_query = query.filter(user=user)
        # all roles for the query model with appropriate permission level
        roles = models.role.filter(model_type=query.model, level__ge=level)
        # Now we need groups which have these roles
        groups = Role.groups.throughquery(
            session).filter(role=roles).get_field('group')
        # I need to know if user is in any of these groups
        if user.groups.filter(id=groups).count():
            # it is, lets get the model with permissions less
            # or equal permission level
            permitted = models.instancerole.filter(
                role=roles).get_field('object_id')
            return owner_query.union(model.objects.filter(id=permitted))
        else:
            return owner_query
114049
def user_in_group(user, group):
    """"""
    if isinstance(group, Group):
        return user_is_superuser(user) or group in user.groups.all()
    elif isinstance(group, six.string_types):
        return user_is_superuser(user) or user.groups.filter(name=group).exists()
    raise TypeError("'group' argument must be a string or a Group instance")
696542
def create_api_object_group_permission_general(self):
        """"""

        return ApiObjectGroupPermissionGeneral(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
1218474
def grant_member(context, request):
    """"""
    mapping = request.json['mapping']
    for entry in mapping:
        user = entry['user']
        roles = entry['roles']
        username = user.get('username', None)
        userid = user.get('userid', None)
        if userid:
            u = context.get_user_by_userid(userid)
        elif username:
            u = context.get_user_by_username(username)
        else:
            u = None
        if u is None:
            raise UnprocessableError(
                'User %s does not exists' % (userid or username))
        for rolename in roles:
            context.grant_member_role(u.userid, rolename)
    return {'status': 'success'}
820531
def required_permission(f, level):
    """"""

    @functools.wraps(f)
    def wrapper(request, pid, *args, **kwargs):
        d1_gmn.app.auth.assert_allowed(request, level, pid)
        return f(request, pid, *args, **kwargs)

    return wrapper
369556
def is_allowed(self, subject_id, action, resource_id, policy_sets=[]):
        
        body = {
            "action": action,
            "subjectIdentifier": subject_id,
            "resourceIdentifier": resource_id,
        }

        if policy_sets:
            body['policySetsEvaluationOrder'] = policy_sets

        # Will return a 200 with decision
        uri = self.uri + '/v1/policy-evaluation'

        logging.debug("URI=" + str(uri))
        logging.debug("BODY=" + str(body))

        response = self.service._post(uri, body)

        if 'effect' in response:
            if response['effect'] in ['NOT_APPLICABLE', 'PERMIT']:
                return True

        return False
395722
private void checkTopicSubscribePermission(String topic) {
        SecurityManager sm = System.getSecurityManager();
        if (sm == null)
            return;

        sm.checkPermission(new TopicPermission(topic, SUBSCRIBE));
    }
986735
def allow_staff_or_superuser(func):
    
    is_object_permission = "has_object" in func.__name__

    @wraps(func)
    def func_wrapper(*args, **kwargs):
        request = args[0]
        # use second parameter if object permission
        if is_object_permission:
            request = args[1]

        if request.user.is_staff or request.user.is_superuser:
            return True

        return func(*args, **kwargs)

    return func_wrapper
926005
def allow_rwe(self, name):
        """"""
        assert name in PERMISSIONS.keys()
        os.chmod(self.file_path, PERMISSIONS[name]['all'])
1028100
protected function assignGroup()
    {
        if (!$this->config()->get('grant_user_access')) {
            return;
        }

        $group = $this->getUserGroup();

        // Must check if the method exists or else an error occurs when changing page type
        if ($this->hasMethod('Editors')) {
            foreach ([$this->Editors(), $this->Writers(), $this->Contributors()] as $levels) {
                foreach ($levels as $user) {
                    if (!$user->inGroup($group)) {
                        $user->Groups()->add($group);
                    }
                }
            }
        }
    }
773849
def allow(ip,
        port=None,
        proto='tcp',
        direction='in',
        port_origin='d',
        ip_origin='s',
        ttl=None,
        comment=''):
    '''
    
    '''
    return _access_rule('allow',
                        ip,
                        port=port,
                        proto=proto,
                        direction=direction,
                        port_origin=port_origin,
                        ip_origin=ip_origin,
                        comment=comment)