NAME

OpusVL::AppKit::RolesFor::UserSetupResultSet

VERSION

version 6

SYNOPSIS

package OpusVL::App::Schema::ResultSet::Role;

use Moose;
extends 'DBIx::Class::ResultSet';
with 'OpusVL::AppKit::RolesFor::UserSetupResultSet';

sub initdb
{
    my $self = shift;

    my $permissions = {
        "AppKit/Home Page" => ["Admin"],
        ...
        "System Parameters/System Parameters" => ["Admin"],
    };
    my $role_permissions = {
        "modules/audittrail/events/all_events" => ["Admin"],
        ...
        "modules/resultsetsearch/search_results" => ["Admin"],
    };
    my $users = [
        { 
            username => 'appkitadmin',
            ...
            name => 'AppKit Admin',
            roles => [ 'Admin' ],
        }
    ];
    $self->setup_users({
        users => $users, 
        feature_permissions => $permissions,
        role_permissions => $role_permissions,
    });
}

DESCRIPTION

This role provides a simple way to setup default users and set of roles for an AppKit auth database. The idea is to call it from an initdb function which gets called when the database is built by your script.

NAME

OpusVL::AppKit::RolesFor::UserSetupResultSet

METHODS

setup_users

my $permissions = {
    "AppKit/Home Page" => ["Admin"],
    "AppKit/Password Change" => ["Admin"],
    "AppKit/Role Administration" => ["Admin"],
    "AppKit/User Administration" => ["Admin"],
    "AppKit/User Password Administration" => ["Admin"],
    "Search/Search box" => ["Admin"],
    "System Parameters/System Parameters" => ["Admin"],
};
my $role_permissions = {
    "modules/audittrail/events/all_events" => ["Admin"],
    "modules/audittrail/events/event_search" => ["Admin"],
    "modules/audittrail/events/home" => ["Admin"],
    "modules/resultsetsearch/search_results" => ["Admin"],
};
my $users = [
    { 
        username => 'appkitadmin',
        ...
        name => 'AppKit Admin',
        roles => [ 'Admin' ],
    }
];
$self->setup_users({
    users => $users, 
    feature_permissions => $permissions,
    role_permissions => $role_permissions,
});

This method takes a hash containing the feature permissions and a list of users and the role to give those users, and creates the permissions and users.

To generate the permissions hash use the "permission_extract.sh" in scripts script.

AUTHOR

Colin Newell <colin@opusvl.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by OpusVL.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.