File Coverage

blib/lib/Catalyst/ActionRole/OAuth2/AuthToken/ViaAuthGrant.pm
Criterion Covered Total %
statement 18 21 85.7
branch n/a
condition n/a
subroutine 5 6 83.3
pod 0 1 0.0
total 23 28 82.1


line stmt bran cond sub pod time code
1             package Catalyst::ActionRole::OAuth2::AuthToken::ViaAuthGrant;
2 8     8   22833 use Moose::Role;
  8         26  
  8         82  
3 8     8   43376 use Try::Tiny;
  8         24  
  8         555  
4 8     8   3862 use CatalystX::OAuth2::Request::AuthToken;
  8         37  
  8         1721  
5              
6             # ABSTRACT: Authorization token provider endpoint for OAuth2 authentication flows
7              
8              
9             with 'CatalystX::OAuth2::ActionRole::Token';
10              
11             sub build_oauth2_request {
12 5     5 0 23 my ( $self, $controller, $c ) = @_;
13              
14 5         179 my $store = $controller->store;
15 5         16 my $req;
16              
17             try {
18             $req = CatalystX::OAuth2::Request::AuthToken->new(
19 5     5   309 %{ $c->req->query_parameters } );
  5         29  
20 5         230 $req->store($store);
21 5         132 $req->refresh_token(exists $self->attributes->{Refresh});
22             }
23             catch {
24 0     0   0 $c->log->error($_);
25              
26             # need to figure out a better way, but this will do for now
27 0         0 $c->res->body('warning: response_type/client_id invalid or missing');
28              
29 0         0 $c->detach;
30 5         79 };
31              
32 5         119 return $req;
33             }
34              
35             1;
36              
37             __END__
38              
39             =pod
40              
41             =head1 NAME
42              
43             Catalyst::ActionRole::OAuth2::AuthToken::ViaAuthGrant - Authorization token provider 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              
54             BEGIN { extends 'Catalyst::Controller::ActionRole' }
55              
56             use URI;
57              
58             with 'CatalystX::OAuth2::Controller::Role::Provider';
59              
60             __PACKAGE__->config(
61             store => {
62             class => 'DBIC',
63             client_model => 'DB::Client'
64             }
65             );
66              
67             sub token : Chained('/') Args(0) Does('OAuth2::AuthToken::ViaAuthGrant') {}
68              
69             1;
70              
71             =head1 DESCRIPTION
72              
73             This action role implements an endpoint that exchanges an authorization code
74             for an access token.
75              
76             =head1 AUTHOR
77              
78             Eden Cardim <edencardim@gmail.com>
79              
80             =head1 COPYRIGHT AND LICENSE
81              
82             This software is copyright (c) 2017 by Suretec Systems Ltd.
83              
84             This is free software; you can redistribute it and/or modify it under
85             the same terms as the Perl 5 programming language system itself.
86              
87             =cut