Thoughts Heap

A Blog by Roman Gonzalez.-

RSS
Jul
15th
Wed
permalink

walruz: Simple but powerful authorization framework in Ruby

You have been there already… your kick-ass app suddenly becomes an insatiable beast when you have to add special conditions for authorized access, roles types, etc. And as soon as a new kind of user is added, or new more specific conditions are created for the existing authorizations, you just want to shoot your application just to put it out of its misery.

Well it doesn’t have to be that way anymore…

Introducing walruz.

walruz is an authorization framework that helps you on that creepy process of adding new authorization policies to your application, without having to change each piece of code that is related to it.

You see, the authorization process is divided in two sub-processes, the authorization checking and the action execution. walruz divides this 2 processes so that you can change without pain, the checking implementation from the execution implementation.

walruz Architecture.

In order to understand how walruz works, we need to clarify the architecture it has in order to achieve it’s goals. We have the three following components.

  • Subject. Object that is going to be managed (Posts, Profiles, Todos).
  • Actor. Entity that wants to perform an action on a subject (User, Admin).
  • Policy. A set of rules that tells if the Actor can perform the desired action on the Subject.

The framework represent this concepts with the following modules/classes:

  • Walruz::Subject. Module that when it is included makes the class a subject.
  • Walruz::Actor. Module that when it is included makes the class an actor.
  • Walruz::Policy. Class that will hold the authorization checking process.

This is all for now folks… I will be explaining the framework in short post, so that we don’t make this a very long hard read process.

A word of notice: The purpose of this series of posts is to serve as a tutorial to learn step by step all the goodies of the walruz framework. If you want something more technical, I suggest you read the README document that comes with the walruz gem. To install just do sudo gem install walruz, or download from github.

Next Post: How to create and use authorization policies.

blog comments powered by Disqus