| 1 | package Catalyst::ActionRole::OAuth2::RequestAuth; | ||
| 2 | 9 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 9 | ▶ | use Try::Tiny; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 9 | ▶ | use URI; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 9 | ▶ | use CatalystX::OAuth2::Request::RequestAuth; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | # ABSTRACT: Authorization grant endpoint for OAuth2 authentication flows | ||
| 8 | |||
| 9 | |||
| 10 | 9 | with 'CatalystX::OAuth2::ActionRole::Grant'; | |
| 11 | |||
| 12 | 9 | has enable_client_secret => ( isa => 'Bool', is => 'ro', default => 0 ); | |
| 13 | |||
| 14 | sub build_oauth2_request { | ||
| 15 | 8 | ▶ | my ( $self, $controller, $c ) = @_; |
|
Subroutine
build_oauth2_request: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 16 | |||
| 17 | 8 | my $store = $controller->store; | |
| 18 | 8 | my $req; | |
| 19 | try { | ||
| 20 | $req = CatalystX::OAuth2::Request::RequestAuth->new( | ||
| 21 | 8 | ▶ | %{ $c->req->query_parameters } ); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 22 | 5 | $req->enable_client_secret($self->enable_client_secret); | |
| 23 | 5 | $req->store($store); | |
| 24 | } | ||
| 25 | catch { | ||
| 26 | 3 | ▶ | $c->log->error($_); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 27 | # need to figure out a better way, but this will do for now | ||
| 28 | 3 | $c->res->body(qq{warning: response_type/client_id invalid or missing}); | |
| 29 | |||
| 30 | 3 | $c->detach; | |
| 31 | 8 | }; | |
| 32 | 5 | return $req; | |
| 33 | } | ||
| 34 | |||
| 35 | 9 | 1; | |
| 36 | |||
| 37 | __END__ | ||
| 38 | |||
| 39 | =pod | ||
| 40 | |||
| 41 | =head1 NAME | ||
| 42 | |||
| 43 | Catalyst::ActionRole::OAuth2::RequestAuth - Authorization grant endpoint for OAuth2 authentication flows | ||
| 44 | |||
| 45 | =head1 VERSION | ||
| 46 | |||
| 47 | version 0.001006 | ||
| 48 | |||
| 49 | =head1 SYNOPSIS | ||
| 50 | |||
| 51 | package AuthServer::Controller::OAuth2::Provider; | ||
| 52 | use Moose; | ||
| 53 | BEGIN { extends 'Catalyst::Controller::ActionRole' } | ||
| 54 | |||
| 55 | with 'CatalystX::OAuth2::Controller::Role::Provider'; | ||
| 56 | |||
| 57 | __PACKAGE__->config( | ||
| 58 | store => { | ||
| 59 | class => 'DBIC', | ||
| 60 | client_model => 'DB::Client' | ||
| 61 | } | ||
| 62 | ); | ||
| 63 | |||
| 64 | sub request : Chained('/') Args(0) Does('OAuth2::RequestAuth') {} | ||
| 65 | |||
| 66 | =head1 DESCRIPTION | ||
| 67 | |||
| 68 | This action role implements the initial endpoint that triggers the | ||
| 69 | authorization grant flow. It generates an inactive authorization code | ||
| 70 | redirects to the next action in the workflow if all parameters are valid. The | ||
| 71 | authorization code is used to verify the validity of the arguments in the | ||
| 72 | subsequent request of the flow and prevent users of this library from creating | ||
| 73 | potentially unsafe front-end forms for user confirmation of the authorization. | ||
| 74 | |||
| 75 | =head1 AUTHOR | ||
| 76 | |||
| 77 | Eden Cardim <edencardim@gmail.com> | ||
| 78 | |||
| 79 | =head1 COPYRIGHT AND LICENSE | ||
| 80 | |||
| 81 | This software is copyright (c) 2017 by Suretec Systems Ltd. | ||
| 82 | |||
| 83 | This is free software; you can redistribute it and/or modify it under | ||
| 84 | the same terms as the Perl 5 programming language system itself. | ||
| 85 | |||
| 86 | =cut | ||