NAME
Dancer::Plugin::Authorize::Permissions::Config - Dancer::Plugin::Authorize access control via the Dancer configuration file!
VERSION
version 0.02
SYNOPSIS
my $datastore = {
control => {
admin => {
permissions => {
"manage accounts" => [qw/create view update delete/]
}
},
user => {
permissions => {
"manage accounts" => [qw/create view/]
}
},
guest => {
permissions => {
"manage accounts" => [qw/view/]
}
}
}
};
my $class = "Dancer::Plugin::Authorize::Permissions::Config";
print 'Im good!' if $class->new->subject_can($datastore, 'manage accounts', 'create');
The Dancer application configuration file will be used as the role-based access control datastore, the permissions should be defined in the configuration file as follows:
plugins:
Authorize:
auth: # keyword allows one to setup multiple authentication schemes
permissions:
class: Config
options: # under permissions options control is where permissions should be defined
control:
admin:
permissions:
manage accounts:
operations:
- view
- create
- update
- delete
user:
permissions:
manage accounts:
operations:
- view
- create
guests:
permissions:
manage accounts:
operations:
- view
DESCRIPTION
Dancer::Plugin::Authorize::Permissions::Config uses your Dancer application configuration file as the datastore where the application's permissions are stored and retrieved from.
METHODS
subject_asa
The subject_asa method (found in every permissions class) validates whether a user has the role defined in the supplied argument.
return 1 if subject_asa($self, $options, $role);
subject_can
The subject_can method (found in every permissions class) validates whether a user is responsible for (or is authorized to operate) a particular operation and can perform the specified action under that operation.
return 1 if subject_can($self, $options, $operation, $action);
METHODS
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.