Amon2::Auth::Site::LINE - LINE integration for Amon2
# in your configuration file
+{ Auth => { LINE => { client_id => '123456789Z',, client_secret => '01234567889abcdef0123456789abcdx', scope => [qw(profile)], } } }
# in your web app
__PACKAGE__->load_plugin('Web::Auth', { module => 'LINE', on_finished => sub { my($c, $token, $user) = @_; my $user_id = $user->{userId}; my $name = $user->{displayName}; $c->session->set(user_id => $user_id); $c->session->set(name => $name); return $c->redirect('/'); }, on_error => sub { my($c, $error_message) = @_; ... } });
This is a LINE Login authentication module for Amon2. It uses LINE Login v2.1 APIs.
Following attributes are set in your configuration file such like `config/production.pl` and so on.
Mandatory. It is issued on LINE Developers Console.
Optional. It's used for some API's `redirect_uri` parameter. If it's ommited, `callback_path` which is passed as an attribute for argument is used instead of it.
Optional. If you don't set nothing, it generates a random string. The `state` parameter is used a system for preventing CSRF on OAuth 2.0. This attribute should not be set some foreseeable fixed value.
API scope as an array-ref. Available values are: `profile`, `openid` and `email`. See detail: https://developers.line.biz/en/docs/line-login/integrate-line-login/#scope Default value is `['profile']`
Optional. If you don't set nothing, it generates a random string. The `nonce` parameter is used a system for preventing replay attack / token interception attack on OpenID Connect. This attribute should not be set some foreseeable fixed value.
Optional. `consent` is acceptable.
Optional. Specified on OpenID Conjnect Core 1.0.
Optional. `normal` and `aggressive` are acceptable.
Optional. `state` parameter is kept on session with this specified session key during authentication. Default values `line_login_state`.
Optional. `nonce` parameter is kept on session with this specified session key during. Default values `line_login_nonce`.
Optional. Default value is `/auth/line/authenticate`. The path works for "login link".
Optional. Default value is `/auth/line/callback`.
Mandatory. The details are described following.
Optional. The details are described following.
Optional. If it's true, this module fetches the user information after authentication.
$auth->auth_uri($c:Amon2::Web, $callback_uri : Str) :Str
Get a authenticate URI.
$auth->callback($c:Amon2::Web, $callback:HashRef) : Plack::Response
Process the authentication callback dispatching.
$callback MUST have two keys.
$callback
on_error callback function is called when an error occurs.
The arguments are following:
sub { my ($c, $error_message) = @_; ... }
on_finished callback function is called if an authentication was finished.ck function is called After successful authentication.
sub { my ($c, $access_token, $user) = @_; ... }
$user contains user information. This code contains a information like https://developers.line.biz/en/reference/line-login/#get-profile-response.
$user
If you set $auth-user_info> as a false value, authentication engine does not pass $user.
Koichi Taniguchi (a.k.a. nipotan) <taniguchi@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
LINE Login v2.1 API Reference
https://developers.line.biz/en/reference/line-login/
Amon2::Plugin::Web::Auth
https://metacpan.org/pod/Amon2::Plugin::Web::Auth
To install Amon2::Auth::Site::LINE, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Amon2::Auth::Site::LINE
CPAN shell
perl -MCPAN -e shell install Amon2::Auth::Site::LINE
For more information on module installation, please visit the detailed CPAN module installation guide.