Works similar to the permitted_to? method, but doesn't accept a block
 and throws the authorization exceptions, just like Engine#permit!
182819
def permitted_to! (privilege, options = {} )
      options = {
        :user =>  Authorization.current_user,
        :object => self
      }.merge(options)
      Authorization::Engine.instance.permit!(privilege,
          {:user => options[:user],
           :object => options[:object]})
    end
102662
def allowed(self, url, agent):
        ''''''
        return self.get(url).allowed(url, agent)
960214
private function _denyAccess()
    {
        if (isset($env['auth.JSONerrors']) && $env['auth.JSONerrors'] == true) {
            throw new Exception(
                'Resource '.$this->app->request->getResourceUri().' using '.$this->app->request->getMethod().' method is forbidden',
                403
            );
        } else {
            throw new Exception(
                'You are not authorized to access '.$this->app->request->getResourceUri(),
                403
            );
        }
    }
532388
def assert_allowed(request, level, pid):
    
    if not d1_gmn.app.models.ScienceObject.objects.filter(pid__did=pid).exists():
        raise d1_common.types.exceptions.NotFound(
            0,
            'Attempted to perform operation on non-existing object. pid="{}"'.format(
                pid
            ),
        )
    if not is_allowed(request, level, pid):
        raise d1_common.types.exceptions.NotAuthorized(
            0,
            'Operation is denied. level="{}", pid="{}", active_subjects="{}"'.format(
                level_to_action(level), pid, format_active_subjects(request)
            ),
        )
367658
def allowed_methods(self, path_info=None):
        
        try:
            self.match(path_info, method="--")
        except MethodNotAllowed as e:
            return e.valid_methods
        except HTTPException:
            pass
        return []
980510
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_edit_post(obj, user)
1116969
def allowed?(to_url, from_url)
      to_url.host.nil? || (to_url.host == from_url.host)
    end
420081
def method_missing(name, *args, &block)
      string_name = name.to_s

      if string_name =~ /can_(.+)\?/
        self.can?(name, *args)
      else
        super(name, *args, &block)
      end
    end
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
523581
def authorize!(action, subject, *args)
      message = args.last.is_a?(Hash) && args.last.key?(:message) ? args.pop[:message] : nil
      if cannot?(action, subject, *args)
        message ||= unauthorized_message(action, subject)
        raise AccessDenied.new(message, action, subject, args)
      end
      subject
    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
380223
def check_authorized
      if state == :expired
        raise Exceptions::RetryableError, "Authorization expired"
      elsif state != :authorized
        raise Exceptions::Unauthorized, "Not authorized with RightScale" if state != :authorized
      end
      true
    end
47615
def check_method_allowed(cls, request):
        
        if not request.method in cls._meta.allowed_methods:
            raise HttpError(
                'Method \'%s\' not allowed on this resource.' % request.method,
                status=status.HTTP_405_METHOD_NOT_ALLOWED)
387814
def authorize_for(opts = {})
      authorize! opts[:action], opts[:resource] if opts[:resource].present?
      authorize! opts[:action], opts[:object] if opts[:object].present?
    end
831070
def authorize(action, subject)
      context.send(:authorize, subject, normalize(action)) && subject
    rescue ::Pundit::NotAuthorizedError
      Rails.logger.info I18n.t('errors.unauthorized', user: user, action: action, subject: subject)
      raise Forbidden
    end
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)
652668
function authorize(route, req, res, next) {
  var allowed = true;

  if (type.is(route.allows, Array)) {
    allowed = route.allows.indexOf(req.session.authorized) > -1;
  } else if (type.is(route.allows, String)) {
    allowed = route.allows === req.session.authorized;
  }

  debug(req.method + " " + req.path + " [" + route.allows + "][" + req.session.authorized + "] : " + (allowed ? "OK" : "DENY"));

  if (allowed) {
    return next();
  }

  res.status(403).end();
}