NAME
Dancer::Plugin::Authorize::Permissions - Dancer::Plugin::Authorize Permissions base class and guide!
VERSION
version 0.02
SYNOPSIS
package Dancer::Plugin::Authorize::Permissions::MyPermissionsClass;
use base 'Dancer::Plugin::Authorize::Permissions';
# every permissions class must have subject_asa and subject_can routines
sub subject_asa {
my ($self, $options, @arguments) = @_;
my $role = shift @arguments;
my $settings = $class::settings;
# Note! for permissions classes interacting with a database, storing all
# roles and actions with the user session will boost application
# performance and prevent polling repetitive information, e.g.
# $self->permissions($all_roles);
if ($role) {
my $user = $self->credentials;
if (grep { /$role/ } @{$user->{roles}} ) {
return 1;
}
}
}
sub subject_can {
...
}
1;
DESCRIPTION
The Dancer::Plugin::Authorize::Permissions class should be used as a base class in your custom role-based acess control/permissions classes. When used as a base class, this class provides instantiation and simple error handling for your classes.
AUTHOR
Al Newkirk <awncorp@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by awncorp.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.