Catalyst::Plugin::Authorization::RoleAbilities - Ability based authorization for Catalyst (using only Roles)
version 0.002
use Catalyst qw/ Authentication Authorization::RoleAbilities /; sub delete : Local { my ( $self, $c ) = @_; $c->assert_user_ability( qw/delete_user/ ); # only users with roles that can perform this action can delete $c->model("User")->delete_it(); }
Ability based authorization allows more flexibility than role based authorization. Users can have roles, which then have many actions associated. An action can be associated with several roles. With this you don't check whether a user has specific roles, but instead whether the roles can perform specific actions.
Catalyst::Plugin::Authorization::RoleAbilities extends Catalyst::Plugin::Authorization::Roles so every method of Catalyst::Plugin::Authorization::Roles still can be used.
See "SEE ALSO" for other authorization modules.
Checks that the roles of the user (as supplied by the first argument, or, if omitted, $c->user) has the ability to perform specified actions.
$c->user
If for any reason ($c->user is not defined, the user's roles are missing the appropriate action, etc.) the check fails, an error is thrown.
You can either catch these errors with an eval, or clean them up in your end action.
end
Takes the same args as assert_user_ability, and performs the same check, but instead of throwing errors returns a boolean value.
assert_user_ability
Table name: actions
actions
Columns:
id, as integer, Primary Key
id
integer
name, as character varying or text
name
character varying
text
Table name: role_actions
role_actions
role_id, as integer, Foreign Key to roles.id
role_id
roles.id
action_id, as integer, Foreign Key to actions.id
action_id
actions.id
Catalyst::Plugin::Authorization::Roles
Catalyst::Plugin::Authorization::Abilities - A more complex ability based authorization module
Matthias Dietrich <perl@rainboxx.de>
This software is copyright (c) 2012 by Matthias Dietrich.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Catalyst::Plugin::Authorization::RoleAbilities, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Plugin::Authorization::RoleAbilities
CPAN shell
perl -MCPAN -e shell install Catalyst::Plugin::Authorization::RoleAbilities
For more information on module installation, please visit the detailed CPAN module installation guide.