Giter VIP home page Giter VIP logo

api_authorization's Introduction

Api Authorization (The gem is in development)

A multiple role-based authorization, based on controller actions. api_authorization gem acts as a middleware and checks if current_user has the right to visit the controller actions. It does it by checking the roles of current_user if it has any realationships with permissions table.

This work has been inspired by a very similar implementation I've worked on with Lorenzo Pagano and Andrea Pavoni. They taught me the Ruby art and I'll be forever grateful for this.

Tests License: MIT

Database Model

db_model

Installation

Add this line to your application's Gemfile:

gem 'api_authorization'

And then execute:

$ bundle

Or install it yourself as:

$ gem install api_authorization

Usage

  1. After you have created your users_table(through devise or manually) next run
$ rails api_auth:install
  1. Next populate permissions table with your controllers and actions run:
$ rails api_auth:re_populate_permissions
  1. Include the Authorization module on your ApplicationController :
  include ActionController::Helpers
  include ApiAuthorization
  enable_role_authorization

Make sure that current_user is not nil before putting the snippet above.

  1. You can create/read/update/delete roles and permissions for the user through CLI commands or by using the dashboard which is depended on rails_admin gem you need to install seperately by running:
rails api_auth:install_dashboard
  1. add rails_admin on your Gemfile:
  gem 'rails_admin', '~> 2.0'
  1. And after running bundle instal and starting the rails app visit:
http://localhost:3000/auth_dashboard

Managing Roles and Permissions

There are two ways to manage your roles and

Contributing

Feel free to suggest a feature or report a bug.

License

The gem is available as open source under the terms of the MIT License.

api_authorization's People

Contributors

azdrenymeri avatar giovapanasiti 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.