Socket
Book a DemoInstallSign in
Socket

jrun-rails_doorman

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jrun-rails_doorman

0.0.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

== rails_doorman

+rails_doorman+ is an authorization plugin for Ruby on Rails applications.

This code was orignally written by Michael D. Ivey for Merb.

== Resources

Development

  • http://github.com/jrun/rails_doorman

Source

  • git://github.com/jrun/rails_doorman.git

Bugs

== Usage

=== Controllers

class Admin::ArticlesController < AdminController allow :role => :admin end

allow :role => :admin # current_user.has_role?(:admin) deny :role => :troll allow :role => :admin, :exclude => :show allow :role => :troll, :only => :index

+rails_doorman+ supports more than roles.

allow :user => :nancy # current_user.login.to_sym == 'nancy'.to_sym allow :host => 'allowed.example.org' # request.host =~ Regexp.new('allowed.example.org') deny :host => 'denied.example.org' deny :user_agent => /MSIE/ # request.user_agent =~ Regexp.new(/MSIE/)

=== Views

All rules can be used in views.

<% allow(:role => :admin) do %>

Allowed

<% end %>

<% deny(:role => :troll) do %>

Allowed

<% end %>

=== Unauthorized

When a rule fails a Doorman::Unauthorized error is raised. The error can be caught in ApplicationController#rescue_action_in_public.

class ApplicationController < ActionController::Base private def rescue_action_in_public(exception) case exception when Doorman::InvalidRule render :text => 'Invalid Rule', :status => '500 Internal Server Error' when Doorman::Unauthorized render :text => 'Unauthorized', :status => '401 Unauthorized' else super(exception) end end end

== TODO

=== Rule inheritance

Controller subclasses do not inherit its parents rules. This is more like a bug than a todo.

=== More configurable

+rails_doorman+ should be configurable. For example, the :user rule uses +login+ for comparison. Often times +username+ is used instead of +login+.

This type of configuration is partially implementd but it is half baked and not tested.

FAQs

Package last updated on 11 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.