Giter VIP home page Giter VIP logo

permissions's Introduction

permissions

A permissions plugin for Rails.

It lets you mark specific controller methods as accessible only by users who are members of specific groups.

Installing

script/plugin install git://github.com/epitron/permissions.git

Usage

This plugin adds the permit classmethod to ActionController::Base, so that you can specify permissions in your controllers. It works almost the same as before_filter.

permit(roles, options={})

For example:

permit :user, :only=>[:show, :index]

This rule gives users access to read in your standard CRUD controller.

You can specify multiple roles at the same time:

permit [:admin, :manager]

This will permit admin and managers for all actions.

The plugin checks the user's permissions by reading current_user.roles and seeing if any of the roles on the user match the roles on the rule. If they do, the rule becomes active.

You can specify a rule that applies to all users with the special role :all.

The options you can pass are:

  • :only => <symbol or array of symbols> -- only protect specified method(s)
  • :except => <symbol or array of symbols> -- protect everything except specified method(s)

More Examples

Allow all users to access all methods (overrides previous permissions):

permit :all

Allow the user with role :role to access only the "show" method:

permit :role, :only => :show

Users with the roles :role2 or :role3 can access all methods except :method1 and :method2.

permit [:role2, :role3], :except => [:method1, :method2]

permissions's People

Contributors

epitron avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.