this only returns user permissions, but not group permissions and proxy users
339565
private void ajaxGetPermissions(final Project project, final HashMap<String, Object> ret) {
    final ArrayList<HashMap<String, Object>> permissions =
        new ArrayList<>();
    for (final Pair<String, Permission> perm : project.getUserPermissions()) {
      final HashMap<String, Object> permObj = new HashMap<>();
      final String userId = perm.getFirst();
      permObj.put("username", userId);
      permObj.put("permission", perm.getSecond().toStringArray());

      permissions.add(permObj);
    }

    ret.put("permissions", permissions);
  }
625484
def _get_permission_set_tree(user):
    
    if hasattr(user, CACHED_PSET_PROPERTY_KEY):
        return getattr(user, CACHED_PSET_PROPERTY_KEY)
    if user.is_authenticated():
        try:
            return user.permissionset.first().tree()
        except AttributeError:
            raise ObjectDoesNotExist
    return PermissionSet.objects.get(anonymous_user=True).tree()
151274
def get_user_groups(user):
    """"""
    if user.is_active and user.is_authenticated():
        if user.is_superuser:
            return TenantGroup.objects.all()
        else:
            return TenantGroup.objects.filter(tenantrole__user=user).distinct()
    else:
        return TenantGroup.objects.none()
609237
def permissions(self):
        """"""
        perms = set()
        for g in self.groups:
            perms = perms | set(g.permissions)
        return perms
844650
def _get_group_cached_perms(self):
        
        if not self.group:
            return {}
        perms = Permission.objects.filter(
            group=self.group,
        )
        group_permissions = {}
        for perm in perms:
            group_permissions[(
                perm.object_id,
                perm.content_type_id,
                perm.codename,
                perm.approved,
            )] = True
        return group_permissions
1347708
def get_user_permissions(self, username):
        

        path = Client.urls['user_permissions'] % (username,)
        conns = self._call(path, 'GET')
        return conns
612511
def perms_for_user(cls, instance, user, db_session=None):
        
        db_session = get_db_session(db_session, instance)
        query = db_session.query(
            cls.models_proxy.GroupResourcePermission.group_id.label("owner_id"),
            cls.models_proxy.GroupResourcePermission.perm_name,
            sa.literal("group").label("type"),
        )
        query = query.filter(
            cls.models_proxy.GroupResourcePermission.group_id.in_(
                [gr.id for gr in user.groups]
            )
        )
        query = query.filter(
            cls.models_proxy.GroupResourcePermission.resource_id == instance.resource_id
        )

        query2 = db_session.query(
            cls.models_proxy.UserResourcePermission.user_id.label("owner_id"),
            cls.models_proxy.UserResourcePermission.perm_name,
            sa.literal("user").label("type"),
        )
        query2 = query2.filter(
            cls.models_proxy.UserResourcePermission.user_id == user.id
        )
        query2 = query2.filter(
            cls.models_proxy.UserResourcePermission.resource_id == instance.resource_id
        )
        query = query.union(query2)

        groups_dict = dict([(g.id, g) for g in user.groups])
        perms = [
            PermissionTuple(
                user,
                row.perm_name,
                row.type,
                groups_dict.get(row.owner_id) if row.type == "group" else None,
                instance,
                False,
                True,
            )
            for row in query
        ]

        # include all perms if user is the owner of this resource
        if instance.owner_user_id == user.id:
            perms.append(
                PermissionTuple(
                    user, ALL_PERMISSIONS, "user", None, instance, True, True
                )
            )
        groups_dict = dict([(g.id, g) for g in user.groups])
        if instance.owner_group_id in groups_dict:
            perms.append(
                PermissionTuple(
                    user,
                    ALL_PERMISSIONS,
                    "group",
                    groups_dict.get(instance.owner_group_id),
                    instance,
                    True,
                    True,
                )
            )

        return perms
641742
def get_all_users(resource_root, view=None):
  
  return call(resource_root.get, USERS_PATH, ApiUser, True,
      params=view and dict(view=view) or None)
945189
def check_permissions(self, request):
        """"""
        objs = [None]
        if hasattr(self, 'get_perms_objects'):
            objs = self.get_perms_objects()
        else:
            if hasattr(self, 'get_object'):
                try:
                    objs = [self.get_object()]
                except Http404:
                    raise
                except:
                    pass
            if objs == [None]:
                objs = self.get_queryset()
            if len(objs) == 0:
                objs = [None]

        if (hasattr(self, 'permission_filter_queryset') and
           self.permission_filter_queryset is not False and
           self.request.method == 'GET'):
            if objs != [None]:
                self.perms_filter_queryset(objs)
        else:
            has_perm = check_perms(self.request.user,
                                   self.get_permission_required(),
                                   objs, self.request.method)

            if not has_perm:
                msg = self.get_permission_denied_message(
                    default="Permission denied."
                )
                if isinstance(msg, Sequence):
                    msg = msg[0]
                self.permission_denied(request, message=msg)
1063460
def get_group_permissions(self, user_obj, obj=None):
        
        if user_obj.is_anonymous() or obj is not None:
            return set()
        if not hasattr(user_obj, '_group_perm_cache'):
            if user_obj.is_superuser:
                perms = Permission.objects.all()
            else:
                user_groups_field = get_user_class()._meta.get_field('groups')  # pylint: disable=W0212
                user_groups_query = 'group__%s' % user_groups_field.related_query_name()
                perms = Permission.objects.filter(**{user_groups_query: user_obj})
            perms = perms.values_list('content_type__app_label', 'codename').order_by()
            user_obj._group_perm_cache = set(["%s.%s" % (ct, name) for ct, name in perms])  # pylint: disable=W0212
        return user_obj._group_perm_cache
134301
def group_perms_for_user(cls, instance, user, db_session=None):
        
        db_session = get_db_session(db_session, instance)
        perms = resource_permissions_for_users(
            cls.models_proxy,
            ANY_PERMISSION,
            resource_ids=[instance.resource_id],
            user_ids=[user.id],
            db_session=db_session,
        )
        perms = [p for p in perms if p.type == "group"]
        # include all perms if user is the owner of this resource
        groups_dict = dict([(g.id, g) for g in user.groups])
        if instance.owner_group_id in groups_dict:
            perms.append(
                PermissionTuple(
                    user,
                    ALL_PERMISSIONS,
                    "group",
                    groups_dict.get(instance.owner_group_id),
                    instance,
                    True,
                    True,
                )
            )
        return perms
696542
def create_api_object_group_permission_general(self):
        """"""

        return ApiObjectGroupPermissionGeneral(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
1163699
def get_permissions(FunctionName, Qualifier=None,
                    region=None, key=None, keyid=None, profile=None):
    '''
    
    '''

    try:
        conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
        kwargs = {}
        if Qualifier is not None:
            kwargs['Qualifier'] = Qualifier
        # The get_policy call is not symmetric with add/remove_permissions. So
        # massage it until it is, for better ease of use.
        policy = conn.get_policy(FunctionName=FunctionName,
                                 **kwargs)
        policy = policy.get('Policy', {})
        if isinstance(policy, six.string_types):
            policy = salt.utils.json.loads(policy)
        if policy is None:
            policy = {}
        permissions = {}
        for statement in policy.get('Statement', []):
            condition = statement.get('Condition', {})
            principal = statement.get('Principal', {})
            if 'AWS' in principal:
                principal = principal['AWS'].split(':')[4]
            else:
                principal = principal.get('Service')
            permission = {
                'Action': statement.get('Action'),
                'Principal': principal,
            }
            if 'ArnLike' in condition:
                permission['SourceArn'] = condition[
                    'ArnLike'].get('AWS:SourceArn')
            if 'StringEquals' in condition:
                permission['SourceAccount'] = condition[
                    'StringEquals'].get('AWS:SourceAccount')
            permissions[statement.get('Sid')] = permission
        return {'permissions': permissions}
    except ClientError as e:
        err = __utils__['boto3.get_error'](e)
        if e.response.get('Error', {}).get('Code') == 'ResourceNotFoundException':
            return {'permissions': None}
        return {'permissions': None, 'error': err}
87337
def group_permissions(self, group, perm, obj, approved=True):
        
        return self.get_for_model(obj).select_related(
            'user', 'group', 'creator').filter(group=group, codename=perm,
                                               approved=approved)
559084
def get_all_permissions(self):
        """"""
        perms = set()
        for role in self.get_user_roles():
            for perm_view in role.permissions:
                t = (perm_view.permission.name, perm_view.view_menu.name)
                perms.add(t)
        return perms
124674
function (req) {
	var session = l_getSession(req);
	if (session.hasOwnProperty('_user')) {
		var login = session._user;
		login.admin = (session._user.account === 'admin');
		return login;
	}
	
	LOG.warn('user not yet logined...');
	return {control: {groups: [], permissions: []}};
}
1007956
def object_permission_set(self):
        '''
        
        '''
        return Or(
            AllowAdmin,
            AllowObjectPermission('team:admin'),
            AllowObjectPermission('org:admin', lambda t: t.organization_id),
            And(
                AllowOnlySafeHttpMethod,
                Or(
                    ObjAttrTrue(
                        lambda r, t: t.users.filter(pk=r.user.pk).exists()),
                    ObjAttrTrue(
                        lambda r, t: t.organization.users.filter(
                            pk=r.user.pk).exists())
                )
            )
        )