Code Monkey home page Code Monkey logo

aegis's Introduction

Aegis - A complete authorization solution for Rails

Aegis is an authorization solution for Ruby on Rails that supports roles and a RESTish, resource-style declaration of permission rules. Getting started with Aegis is easy and requires very little integration. As your authorization requirements become more complex, Aegis will grow with you.

Getting started

All your permissions live in a single class Permissions. Permissions are described using resources, similiar to your routes. Your permission resources can match those in your routes, but don’t have to.

Access to resources or individual actions can be granted or denied to specific roles.

class Permissions < Aegis::Permissions
  role :user
  role :admin
  resources :projects do
    allow :everyone
  end
  resources :users do
    allow :admin
  end
end

To give your user model a role, it needs to have an attribute role_name. The has_role macro wires everything together:

class User < ActiveRecord::Base
  has_role
end

You can now check if a user has permission to access a given action in your controllers and views:

<% if current_user.may_update_project? @project %>
  <%= link_to 'Edit', edit_project_path(@project) %>
<% end %>

You can protect all actions in a controller through an Aegis resource with a single line:

class ProjectsController < ApplicationController
  permissions :projects
end

Further reading

You are now familiar with the basic use case. Aegis can do a lot more than that. There is an awesome documentation wiki with detailed information on many basic and advanced topics, including:

Installation

Aegis is a gem, which you can install with

sudo gem install aegis

In Rails 2, add the following to your environment.rb:

config.gem 'aegis'

In Rails 3, add the following to your Gemfile:

gem 'aegis'

Rails 3 compatibility

We cannot guarantee Rails 3 compatibility at this point, but we will upgrade the gem when Rails 3 is released.

Credits

Henning Koch, Tobias Kraze

makandra.com

gem-session.com

aegis's People

Contributors

cee-dub avatar foobear avatar josh-m-sharpe avatar kraatob avatar kratob avatar triskweline avatar

Stargazers

 avatar

Watchers

 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.