Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michal-josef-spacek/plack-middleware-auth-oauth2
Plack OAuth2 middleware.
https://github.com/michal-josef-spacek/plack-middleware-auth-oauth2
oauth2 plack
Last synced: 16 days ago
JSON representation
Plack OAuth2 middleware.
- Host: GitHub
- URL: https://github.com/michal-josef-spacek/plack-middleware-auth-oauth2
- Owner: michal-josef-spacek
- License: bsd-2-clause
- Created: 2022-05-30T09:11:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-21T22:30:51.000Z (over 1 year ago)
- Last Synced: 2024-05-02T01:28:38.253Z (9 months ago)
- Topics: oauth2, plack
- Language: Perl
- Homepage:
- Size: 46.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
NAME
Plack::Middleware::Auth::OAuth2 - Plack OAuth2 middleware.SYNOPSIS
use Plack::Builder;
use Plack::App::Env;
use Plack::App::Login;my $app = Plack::App::Env->new;
builder {
enable 'Session';
enable 'Auth::OAuth2',
'client_id' => '__CLIENT_ID__',
'client_secret => '__CLIENT_SECRET__',
'app_login' => Plack::App::Login->new,
'app_login_url' => sub { $_[0]->login_link($_[1]); },
'logout_path' => 'logout',
'provider' => 'Google',
'redirect_path' => 'code',
'scope' => 'email',
;
$app;
};DESCRIPTION
This middleware provides OAuth2 authentication for web application. Uses
LWP::Authen::OAuth2 for implementation.Prerequisity is use of Plack session management and result is saved to
session.ACCESSORS
"app_login"
Plack application to login.It's required.
"app_login_url"
Callback to set URL from OAuth2 provider to "app_login()" Plack
application.First argument is "app_login()" application. Second argument is $url
variable from OAuth2 provider.It's required.
"client_id"
OAuth2 client id.It's required.
"client_secret"
OAuth2 client secret.It's required.
"logout_path"
Logout path for creating of endpoint, which logout from OAuth2.Default value is 'logout' (/logout).
"lwp_user_agent"
Explicit LWP::UserAgent instance.Default value is LWP::UserAgent instance inside of LWP::Authen::OAuth2.
"redirect_path"
Redirect path for creating of endpoint, which is created for service
provider use to set authentication.It's required.
"scope"
OAuth2 scopes in string.Requirement is defined by provider. It's optional.
"service_provider"
Service provider.Possible providers:
Dwolla
Via module LWP::Authen::OAuth2::ServiceProvider::Dwolla.
Via module LWP::Authen::OAuth2::ServiceProvider::Google.Line
Via module LWP::Authen::OAuth2::ServiceProvider::Line.MediaWiki
Via module LWP::Authen::OAuth2::ServiceProvider::MediaWiki.Strava
Via module LWP::Authen::OAuth2::ServiceProvider::Strava.Wikimedia
Via module LWP::Authen::OAuth2::ServiceProvider::Wikimedia.Withings
Via module LWP::Authen::OAuth2::ServiceProvider::Withings.Yahoo
Via module LWP::Authen::OAuth2::ServiceProvider::Yahoo.ENDPOINTS
Logout
Logout endpoint is defined inside of this module by setting
"logout_path" (/__LOGOUT_PATH__).Redirect
Redirect endpoint is defined inside of this module by setting
"redirect_path" (/__REDIRECT_PATH__).SESSION VARIABLES
oauth2.obj
Value is instance of LWP::Authen::OAuth2 used for authentization.oauth2.service_provider
Value is authenticated service provider.oauth2.token_string
Value is token string.ERRORS
prepare_app():
No OAuth2 'client_id' setting.
No OAuth2 'client_secret' setting.
No login application.
No login url call.
No redirect path.
No service provider.DEPENDENCIES
English, Error::Pure, JSON::XS, LWP::Authen::OAuth2, Plack::Middleware,
Plack::Response, Plack::Session, Plack::Util::Accessor.SEE ALSO
LWP::Authen::OAuth2
Make requests to OAuth2 APIs.REPOSITORY
AUTHOR
Michal Josef Špaček
LICENSE AND COPYRIGHT
© 2020-2023 Michal Josef ŠpačekBSD 2-Clause License
VERSION
0.02