RBAC::Tiny - Tiny Role-Based Access Control (RBAC) implementation
version 0.003
my $rbac = RBAC::Tiny->new( roles => { author => { can => [ qw<read write publish> ], }, limited_author => { all_from => ['author'], except => ['publish'], }, admin => { all_from => ['author'], can => ['create_users'], }, }, ); $rbac->can_role( author => 'publish' ); # true $rbac->can_role( author => 'create_users' ); # false $rbac->can_role( admin => 'write' ); # true $rbac->can_role( limited_author => 'publish' ); # false $rbac->can_role( limited_author => 'create_users' ); # false $rbac->can_role( author => 'create_users' ); # false
This module implements a tiny simple implementation of Role-Based Access Control, allowing you to specify roles and what each can do.
Each role has three optional parameters:
all_from
Will gather all the permissions from a list of roles.
can
Add permissions for a role. Will add to permissions provided by all_from.
except
Remove permissions from a role. Will remove permissions provided by either all_from or except.
my $roles = $rbac->roles;
Retrieves all the role definitions.
Create a new object. See synopsis.
my $role = $rbac->role('author');
Retrieves the role definition.
if ( $rbac->can_role( author => 'write' ) ) { ... }
Checks whether a role has a certain permission.
Sawyer X <xsawyerx@cpan.org>
Andre Walker <andre@cpan.org>
This software is Copyright (c) 2015 by Sawyer X.
This is free software, licensed under:
The MIT (X11) License
To install RBAC::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RBAC::Tiny
CPAN shell
perl -MCPAN -e shell install RBAC::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.