¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !
Mojolicious::Plugin::RoutesAuthDBI::Access - Generation routes, authentication and controll access to routes trought sintax of ->requires(...), see Mojolicious::Routes::Route#requires
See https://github.com/mche/Mojolicious-Plugin-RoutesAuthDBI/blob/master/Diagram.svg
route -> actions.action <- controllers [ <- namespaces]
Route to action method on controller. If no ref from namespace to controller then controller will find on $app->routes->namespaces as usual.
routes -> actions.callback
Route to callback (no ref to controller, defined callback column (as text "sub {...}") in db table actions)
There are two ways of flow: explicit and implicit.
Explicit access
Check by tables ids: routes, actions, controllers, namespaces. Check refs to profile roles ids.
Implicit access
Access to routes by names: action, controller, namespace, role. This way used for db route to access namespace and for non db routes by syntax:
$r->any('/foo')->...->to('foo#bar')->requires(access=>{auth=>1})->...;
or
$r->...->requires(access=>{auth=>1, role => <id|name>})->...; # access to route by role id|name
See detail Mojolicious::Plugin::RoutesAuthDBI#access
$app->plugin('RoutesAuthDBI', ... access => {< hashref options list below >}, ... );
Default 'Mojolicious::Plugin::RoutesAuthDBI'.
Default 'Access' (this module).
Both above options determining the module which will play as manager of authentication, accessing and generate routing from DBI source.
fail_auth_cb => sub {my $c = shift;...}
This callback invoke when request need auth route but authentication was failure.
fail_access_cb => sub {my ($c, $route, $r_hash, $u) = @_;...}
This callback invoke when request need auth route but access was failure. $route - Mojolicious::Routes::Route object, $r_hash - route hashref db item, $u - useer hashref.
Hashref of any DB tables names. See Mojolicious::Plugin::RoutesAuthDBI::Schema#Default-variables-for-SQL-templates.
Fetch user record from table profiles by COOKIES. Import for Mojolicious::Plugin::Authentication. Required.
Fetch login record from table logins by Mojolicious::Plugin::Authentication. Required. If hashref $extradata->{id} then no fetch and $extradata->{id} will return.
As child of Mojolicious::Controller inherits all parent methods and following ones:
Return new access object.
Select from db table namespaces ns thus app_ns=1 and push them to $app->namespaces()
Heart of routes generation from db tables and not only. Insert to app->routes an hash item $r_hash. DB schema specific. Return new Mojolicious route.
Fetch records for apply_routes. Must return arrayref of hashrefs routes.
Check access to route ($id1 arrayref - either route id or action id or controller id or namespace id) by roles ids ($id2 arrayref). Must return false for deny access or true - allow access.
Check implicit access to route by $namespace for profile roles ids ($id2 arrayref). Must return false for deny access or true - allow access to all actions of this namespace.
Check implicit access to route by $namespace and $controller for profile roles ids ($id2 arrayref). Must return false for deny access or true - allow access to all actions of this controller.
Check implicit access to route by $namespace and $controller and $action for profile roles ids ($id2 arrayref). Must return false for deny access or true - allow access to this action.
Check implicit access to route by $role (id|name) and profile roles ids ($id2 arrayref). Must return false for deny access or true - allow access.
Returns $c->cookie($cookie_name) unless $cookie_value.
$c->cookie($cookie_name)
Returns authenticate profile for $cookie_value. I use this method for cordova mobile app then cookie lost on any reasons.
$cookie_name has defaults to $c->app->sessions->cookie_name
$cookie_name
$c->app->sessions->cookie_name
Mojolicious::Plugin::RoutesAuthDBI
Михаил Че (Mikhail Che), <mche [on] cpan.org>
<mche [on] cpan.org>
Please report any bugs or feature requests at https://github.com/mche/Mojolicious-Plugin-RoutesAuthDBI/issues. Pull requests welcome also.
Copyright 2016+ Mikhail Che.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Mojolicious::Plugin::RoutesAuthDBI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::RoutesAuthDBI
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::RoutesAuthDBI
For more information on module installation, please visit the detailed CPAN module installation guide.