new()get_all_access_keys()
Data::LazyACL - Simple and Easy Access Control List
I am tired of having multiple flags or columns or whatever to implement Access Control List , so I create this module.
This module is simple and easy to use, a user only need to have a token to check having access or not.
my $acl = Data::LazyACL->new(); $acl->set_all_access_keys( [qw/edit insert view/]);
my ( $edit , insert , view ) = $s->get_all_access_keys();
# maybe you want to store this token into user record. my $token = $acl->generate_token([qw/view insert/]);
$acl->set_token( $token );
if ( $acl->has_privilege( 'view' ) ) { print "You can view me!!\n"; }
if ( $acl->has_privilege( 'edit' ) ) { print "Never Dispaly\n"; } my $access_keys_ref = $acl->retrieve_access_keys_for( $token ); my $access_keys_hash_ref = $acl->retrieve_access_keys_in_hash_for( $token );
new()Constractor.
Set all access keys. You can never change this array of order once you generate token , otherwise you will messup permissins. When you want to add new keys then just append.
Generate token. You may want to save this token for per user.
get_all_access_keys()Get access keys which you set with set_all_access_keys() .. means not include
'admin'.
You need to set $token to use has_privilege() method. the has_privilege()
method check privilege based on this token.
If you want to have all access then use reserve keyword 'admin' .
my $admin_token = $acl->set_token( 'admin' );
check having privilege or not for the access_key.
Get access keys array ref for a token.
Get access keys as hash key. value is 1.
Token can be big number when you add a lot of access keys, so I suggest you treat Token as String not Integer when you want to store it into database.
Tomohiro Teranishi <tomohiro.teranishi+cpan@gmail.com>
This program is free software. you can redistribute it and/or modify it under the same terms as Perl itself.