Dancer-Plugin-Auth-RBAC-Credentials-Catmandu

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

INSTALLATION AND CONFIGURATION
  install the following perl modules
    Catmandu
    Catmandu::DBI

  add the yaml file 'catmandu.yml' to the root directory of your Dancer project
    store: default: package: Catmandu::Store::DBI options: data_source:
    "dbi:mysql:database=myapp" username: "admin" password: "admin"

  adjust your Dancer config.yml
    plugins: Auth::RBAC: credentials: class: Catmandu options: #name of
    store in catmandu.yml store: 'default' #name of table bag: 'users'

  The table 'users' will be created if not exists already, and will have the following format
    id  identifier of the user

    data
        json data, in the following form:

        {

lib/Dancer/Plugin/Auth/RBAC/Credentials/Catmandu.pm  view on Meta::CPAN

sub bag {
    my($self,$args)=@_;
    state $bag = store($args->{store})->bag($args->{bag});
}

sub authorize {
    my($self,$options,@arguments) = @_;
    my($login,$password) = @arguments;

    #what are you doing here? You're already in!
    my $user = $self->credentials;
    if(is_hash_ref($user) && ($user->{id} || $user->{login}) && !@{$user->{error}}){

        return $user;

    }

    if(!(is_string($login) && is_string($password))){

        $self->errors('login and password are required');
        return;

    }

    # authorize a new account using supplied credentials
    my $account = $self->bag($options)->get($login);

    if(!is_hash_ref($account)){

        $self->errors('login and/or password is invalid');
        return;

    }

    if(!is_string($account->{password})){

lib/Dancer/Plugin/Auth/RBAC/Credentials/Catmandu.pm  view on Meta::CPAN

    }

    my $session_data = {
        id    => $account->{_id},
        name  => $account->{name} || ucfirst($login),
        login => $account->{login},
        roles => [@{$account->{roles}}],
        error => []
    };

    return $self->credentials($session_data);

}

=head1 NAME

Dancer::Plugin::Auth::RBAC::Credentials::Catmandu - Catmandu store backend for Dancer::Plugin::RBAC::Credentials

=head1 INSTALLATION AND CONFIGURATION

=head2 install the following perl modules

lib/Dancer/Plugin/Auth/RBAC/Credentials/Catmandu.pm  view on Meta::CPAN

  package: Catmandu::Store::DBI
  options:
   data_source: "dbi:mysql:database=myapp"
   username: "admin"
   password: "admin"

=head2 adjust your Dancer config.yml

plugins:
 Auth::RBAC:
  credentials:
   class: Catmandu
   options:
    #name of store in catmandu.yml
    store: 'default'
    #name of table
    bag: 'users'

=head2 The table 'users' will be created if not exists already, and will have the following format

=over



( run in 0.232 second using v1.01-cache-2.11-cpan-4d50c553e7e )