Skip to content

artha42/watchman

Repository files navigation

Watchman

Watchman is a simple solution for doing Authentication and Authorization. This plugin is far from complete however it has the features below.

A simple generator to create Auth and Auth models.


$ script/generate watchman_migrations

This generates about 6 tables and sets a few unique indices. Run the migration and relax.

Simple API for declaring roles

Watchman believes that roles belong to models and so it lets you declare roles and permissions in the model.


  class Document < ActiveRecord::Base
    has_roles :owner, :collaborator
    permit :owner, :to => [:edit, :delete, :share]
    permit :collaborator, :to => [:share]
  end

The plugin includes an assign method in every model.


document=Document.new(params[:document]) document.assign :role, :to=>current_user

These roles and permissions can then be used in the controller and various other parts of your rails app. Watchman provides the following convenience methods on the User class included in the plugin.


@User.in_role? :owner, Document.find(:first)
#checks if the user has role for the document instance
#it takes the logged in user as default from the UserSession object
#this searches both the groups and users associated with the role

user.can? :collaborate, @document

TODO

- Optimize the query for a bazillion users. Get rid of loops.

Copyright © 2009 Artha42 Technology Solutions Pvt. Ltd., released under the MIT license

About

An auth & auth framework built on Authlogic

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages