Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xsawyerx/rbac-tiny

Tiny Role Based Access Control (RBAC) implementation
https://github.com/xsawyerx/rbac-tiny

Last synced: 28 days ago
JSON representation

Tiny Role Based Access Control (RBAC) implementation

Awesome Lists containing this project

README

        

=pod

=encoding UTF-8

=head1 NAME

RBAC::Tiny - Tiny Role-Based Access Control (RBAC) implementation

=head1 VERSION

version 0.003

=head1 SYNOPSIS

my $rbac = RBAC::Tiny->new(
roles => {
author => {
can => [ qw ],
},

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

=head1 DESCRIPTION

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:

=over 4

=item * all_from

Will gather all the permissions from a list of roles.

=item * can

Add permissions for a role. Will add to permissions provided by
C.

=item * except

Remove permissions from a role. Will remove permissions provided
by either C or C.

=back

=head1 ATTRIBUTES

=head2 roles

my $roles = $rbac->roles;

Retrieves all the role definitions.

=head1 METHODS

=head2 new

Create a new object. See synopsis.

=head2 role

my $role = $rbac->role('author');

Retrieves the role definition.

=head2 can_role

if ( $rbac->can_role( author => 'write' ) ) {
...
}

Checks whether a role has a certain permission.

=head1 AUTHORS

=over 4

=item *

Sawyer X

=item *

Andre Walker

=back

=head1 COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by Sawyer X.

This is free software, licensed under:

The MIT (X11) License

=cut