Return a hash of permissions for the user in the format of:
   {
     can: can_hash,
     cannot: cannot_hash
   }

 Where can_hash and cannot_hash are formatted thusly:
   {
     action: { subject: [attributes] }
   }
501970
def permissions
      permissions_list = {
        can: Hash.new { |actions, k1| actions[k1] = Hash.new { |subjects, k2| subjects[k2] = [] } },
        cannot: Hash.new { |actions, k1| actions[k1] = Hash.new { |subjects, k2| subjects[k2] = [] } }
      }
      rules.each { |rule| extract_rule_in_permissions(permissions_list, rule) }
      permissions_list
    end
531207
def add_permission(target, *args)
      raise '#can and #can_not have to be used inside a role block' unless @role
      options = args.last.is_a?(Hash) ? args.pop : {}
      tasks = []
      models = []

      models << args.pop if args.last == :any
      args.each {|arg| arg.is_a?(Symbol) ? tasks << arg : models << arg}

      tasks.each do |task|
        models.each do |model|
          if permission = target[task][model][@role]
            permission.load_options(options)
          else
            target[task][model][@role] = Permission.new(@role, task, model, options)
          end
        end
      end
    end
1313119
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_download_files(obj, user)
58153
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_unsubscribe_from_topic(obj, user)
802882
def permissions(self, course_id, permissions=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """ID"""
        path["course_id"] = course_id

        # OPTIONAL - permissions
        """List of permissions to check against authenticated user"""
        if permissions is not None:
            params["permissions"] = permissions

        self.logger.debug("GET /api/v1/courses/{course_id}/permissions with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("GET", "/api/v1/courses/{course_id}/permissions".format(**path), data=data, params=params, no_data=True)
1204963
def index
      raise CanCan::AccessDenied.new unless current_user
      @scratches = ImageScratch.where(ownable: current_user).all
      (authorize! :read, @scratches[0]) unless @scratches.empty?
    end
287092
def permitted?(requested_flags = 0)
      current_user_roles.any?{|ug| ug.admin?} ||
      current_model_permissions.any?{|cp| cp.permitted?(requested_flags)}
    end
354976
def get_actions_permission_description(view, method):
    
    action = getattr(view, 'action', None)
    if action is None:
        return ''

    if hasattr(view, action + '_permissions'):
        permission_types = (action,)
    elif method in SAFE_METHODS:
        permission_types = ('safe_methods', '%s_extra' % action)
    else:
        permission_types = ('unsafe_methods', '%s_extra' % action)

    description = ''
    for permission_type in permission_types:
        action_perms = getattr(view, permission_type + '_permissions', [])
        for permission in action_perms:
            action_perm_description = get_entity_description(permission)
            description += '\n' + action_perm_description if description else action_perm_description

    return description
984114
def _check_permission(self, request):
        

        if self.access_controller:
            self.access_controller.check_perm(request, self)
88835
def _get_permission_description(permission_name):
    

    parts = permission_name.split('_')
    parts.pop(0)
    method = parts.pop()
    resource = ('_'.join(parts)).lower()
    return 'Can %s %s' % (method.upper(), resource)
267788
def to_s
      t('permission_string', action: t(self.permission_type.to_s),
        model: t(self.model.underscore.humanize))
    end
1005011
def get_permissions(self):
        '''
        
        '''
        response = self.client.getHelper(self.url, acl='true')
        if response.status_code != 200:
            raise DataApiError('Unable to get permissions:' + str(response.content))
        content = response.json()
        if 'acl' in content:
            return Acl.from_acl_response(content['acl'])
        else:
            return None
1088384
def can(self, *args, **kwargs):
        ''''''
        if isinstance(self.require, auth.Permission):
            return self.require.can()
        elif callable(self.require):
            return self.require()
        elif isinstance(self.require, bool):
            return self.require
        else:
            return True
944968
def object_permission_set(self):
        ''''''
        return Or(
            AllowOnlySafeHttpMethod,
            AllowAdmin,
            And(
                AllowPermission('org:admin'),
                ObjAttrTrue(lambda _, u: not u.is_superuser),
                ObjAttrTrue(
                    lambda r, _: r.data.get('admin') is not True)
            ),
            And(
                AllowModify,
                ObjAttrTrue(
                    lambda req, user: user == req.user),
                ObjAttrTrue(
                    lambda r, _: r.data.get('admin') is not True)
            ),
        )
621284
def get_permissions_description(view, method):
    
    if not hasattr(view, 'permission_classes'):
        return ''

    description = ''
    for permission_class in view.permission_classes:
        if permission_class == core_permissions.ActionsPermission:
            actions_perm_description = get_actions_permission_description(view, method)
            if actions_perm_description:
                description += '\n' + actions_perm_description if description else actions_perm_description
            continue
        perm_description = get_entity_description(permission_class)
        description += '\n' + perm_description if description else perm_description

    return '### Permissions:\n' + description if description else ''
1222047
function(user, action, model, body) {
    return function(obj) {
      return new Promise(function(resolve, reject) {
        Model.findOne({
          identity: model
        }).then(function(model) {
         return Permission.find({
            model: model.id,
            action: action,
            relation: 'user',
            user: user
          }).populate('criteria');
        }).then(function(permission) {
          if (permission.length > 0 && PermissionService.hasPassingCriteria(obj, permission, body)) {
            resolve(true);
          } else {
            resolve(false);
          }
        }).catch(reject);
      });
    };
  }
1218328
function(options) {
    var action = PermissionService.getMethod(options.method);

    //console.log('findModelPermissions options', options)
    //console.log('findModelPermissions action', action)

    return User.findOne(options.user.id)
      .populate('roles')
      .then(function(user) {
        var permissionCriteria = {
          model: options.model.id,
          action: action,
          or: [
            { role: _.pluck(user.roles, 'id') },
            { user: user.id }
          ]
        };
        
        return Permission.find(permissionCriteria).populate('criteria')
      });
  }