Доброго всем
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !
Mojolicious::Plugin::RoutesAuthDBI::OAuth - is a Mojolicious::Controller for oauth2 logins to project. Its has two route: for login and logout.
See https://github.com/mche/Mojolicious-Plugin-RoutesAuthDBI/blob/master/Diagram.svg
$app->plugin('RoutesAuthDBI', ... oauth => {< hashref options list below >}, ... );
Namespace (string). Defaults to 'Mojolicious::Plugin::RoutesAuthDBI'.
Module controller name. Defaults to 'OAuth'.
Hashref for key/value per each need provider. Required.
providers => {google=>{key=> ..., secret=>..., }, ...},
See Mojolicious::Plugin::OAuth2. But two additional parameters (keys of provider hash) are needs:
Abs url string to fetch profile info after success oauth.
profile_url=> 'https://www.googleapis.com/oauth2/v1/userinfo',
Coderef which prepare additional query params for profile_url
profile_url
Example for google:
profile_query => sub { my ($c, $auth, ) = @_; { alt => 'json', access_token => $auth->{access_token}, }; },
In: $auth hash ref with access_token.
Out: hashref profile_url query params.
Hashref of any DB tables names. See Mojolicious::Plugin::RoutesAuthDBI::Schema#Default-variables-for-SQL-templates.
oauth = > { namespace => 'Mojolicious::Plugin::RoutesAuthDBI', module => 'OAuth', },
disable oauth module
oauth => undef,
This oauth controller routes. Return array of hashrefs routes records for apply route on app. Plugin internal use.
There are number of app routes on this controller:
Main route of this controller. Stash site is the name of the hash key of the providers config above. Example html link:
providers
<a href="<%= $c->url_for('oauth-login', site=> 'google')->query(redirect=>'profile') %>">Login by google</a>
This route has builtin name 'oauth-login'. This route accept param 'redirect' and will use for $c->redirect_to after success oauith and also failed oauth clauses with param 'err'.
Remove attached oauth user to profile. Stash site and param 'redirect' as above. Route has builtin name 'oauth-detach'.
Get remote oauth data site only configured.
Usefull for cordova mobile app oauth connect.
IN: json data {access_token="..."}> that got from oauth authorize_url API request.
{access_token=
OUT: stored remote oauth API profile.
The "trust" in Mojolicious::Plugin::RoutesAuthDBI::Admin option.
Returns text dump current hash of "providers" in Mojolicious::Plugin::OAuth2.
Mojolicious::Plugin::RoutesAuthDBI
Mojolicious::Plugin::RoutesAuthDBI::Admin
Михаил Че (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 also welcome.
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.