line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::ActionRole::OAuth2::AuthToken::ViaAuthGrant; |
2
|
8
|
|
|
8
|
|
26012
|
use Moose::Role; |
|
8
|
|
|
|
|
29
|
|
|
8
|
|
|
|
|
97
|
|
3
|
8
|
|
|
8
|
|
54606
|
use Try::Tiny; |
|
8
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
658
|
|
4
|
8
|
|
|
8
|
|
4165
|
use CatalystX::OAuth2::Request::AuthToken; |
|
8
|
|
|
|
|
38
|
|
|
8
|
|
|
|
|
1830
|
|
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
|
25
|
my ( $self, $controller, $c ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
|
|
235
|
my $store = $controller->store; |
15
|
5
|
|
|
|
|
20
|
my $req; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
try { |
18
|
|
|
|
|
|
|
$req = CatalystX::OAuth2::Request::AuthToken->new( |
19
|
5
|
|
|
5
|
|
399
|
%{ $c->req->query_parameters } ); |
|
5
|
|
|
|
|
37
|
|
20
|
5
|
|
|
|
|
246
|
$req->store($store); |
21
|
5
|
|
|
|
|
184
|
$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
|
|
|
|
|
87
|
}; |
31
|
|
|
|
|
|
|
|
32
|
5
|
|
|
|
|
144
|
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.001007 |
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 |