| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error; |
|
2
|
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
49
|
use strict; |
|
|
10
|
|
|
|
|
16
|
|
|
|
10
|
|
|
|
|
291
|
|
|
4
|
10
|
|
|
10
|
|
43
|
use warnings; |
|
|
10
|
|
|
|
|
13
|
|
|
|
10
|
|
|
|
|
656
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use overload |
|
7
|
13
|
|
|
13
|
|
1240
|
q{""} => sub { sprintf q{%s: %s}, $_[0]->type, $_[0]->description }, |
|
8
|
10
|
|
|
10
|
|
4802
|
fallback => 1; |
|
|
10
|
|
|
|
|
3833
|
|
|
|
10
|
|
|
|
|
99
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
OAuth::Lite2::Server::Error - OAuth 2.0 server errors |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# At End-User Endpoint |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
try { |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
if ($something_wrong) { |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
OAuth::Lite2::Server::Error::InvalidRequest->throw( |
|
23
|
|
|
|
|
|
|
description => q{Something wrong}, |
|
24
|
|
|
|
|
|
|
# state => q{foo}, |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} catch { |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
if ($_->isa("OAuth::Lite2::Server::Error")) { |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $uri = URI->new( $client_callback_uri ); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my %error_params = ( error => $_->type ); |
|
35
|
|
|
|
|
|
|
$error_params{error_description} = $_->description if $_->description; |
|
36
|
|
|
|
|
|
|
$error_params{state} = $_->state if $_->state; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$uri->query_form(%error_params); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$your_app->redirect( $uri->as_string ); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} else { |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Internal Server Error |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
}; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# At token-endpoint |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
try { |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} catch { |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
if ($_->isa("OAuth::Lite2::Server::Error")) { |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my %error_params = ( error => $_->type ); |
|
60
|
|
|
|
|
|
|
$error_params{error_description} = $_->description if $_->description; |
|
61
|
|
|
|
|
|
|
$error_params{scope} = $_->scope if $_->scope; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$req->new_response($_->code, |
|
64
|
|
|
|
|
|
|
[ "Content-Type" => $formatter->type, "Cache-Control" => "no-store" ], |
|
65
|
|
|
|
|
|
|
[ $formatter->format(\%error_params) ], |
|
66
|
|
|
|
|
|
|
); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} else { |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# rethrow |
|
71
|
|
|
|
|
|
|
die $_; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
}; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
OAuth 2.0 error classes. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
See |
|
82
|
|
|
|
|
|
|
L, |
|
83
|
|
|
|
|
|
|
L, |
|
84
|
|
|
|
|
|
|
L |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 METHODS |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 ERRORS |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=over 4 |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::AccessDenied |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::ExpiredToken |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::ExpiredTokenLegacy |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::InvalidRequest |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::InvalidToken |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::InvalidClient |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::InvalidGrant |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::InvalidScope |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::RedirectURIMismatch |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::UnauthorizedClient |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::UnsupportedGrantType |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::UnsupportedResourceType |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=back |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub new { |
|
121
|
37
|
|
|
37
|
0
|
55
|
my ($class, %args) = @_; |
|
122
|
|
|
|
|
|
|
bless { |
|
123
|
|
|
|
|
|
|
description => $args{description} || '', |
|
124
|
|
|
|
|
|
|
state => $args{state} || '', |
|
125
|
37
|
|
100
|
|
|
706
|
code => $args{code} || 400, |
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
126
|
|
|
|
|
|
|
}, $class; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub throw { |
|
130
|
37
|
|
|
37
|
0
|
458
|
my ($class, %args) = @_; |
|
131
|
37
|
|
|
|
|
125
|
die $class->new(%args); |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
|
|
0
|
0
|
0
|
sub code { $_[0]->{code} } |
|
135
|
0
|
|
|
0
|
0
|
0
|
sub type { die "abstract method" } |
|
136
|
34
|
|
|
34
|
0
|
199
|
sub description { $_[0]->{description} } |
|
137
|
0
|
|
|
0
|
0
|
0
|
sub state { $_[0]->{state} } |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# OAuth Server Error |
|
140
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::InvalidRequest; |
|
141
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
142
|
5
|
|
|
5
|
|
20
|
sub type { "invalid_request" } |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::InvalidClient; |
|
145
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
146
|
0
|
|
|
0
|
|
0
|
sub code { 401 } |
|
147
|
3
|
|
|
3
|
|
16
|
sub type { "invalid_client" } |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::UnauthorizedClient; |
|
150
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
151
|
0
|
|
|
0
|
|
0
|
sub code { 401 } |
|
152
|
0
|
|
|
0
|
|
0
|
sub type { "unauthorized_client" } |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::RedirectURIMismatch; |
|
155
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
156
|
0
|
|
|
0
|
|
0
|
sub code { 401 } |
|
157
|
1
|
|
|
1
|
|
5
|
sub type { "redirect_uri_mismatch" } |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::AccessDenied; |
|
160
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
161
|
0
|
|
|
0
|
|
0
|
sub code { 401 } |
|
162
|
0
|
|
|
0
|
|
0
|
sub type { "access_denied" } |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::UnsupportedResourceType; |
|
165
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
166
|
0
|
|
|
0
|
|
0
|
sub type { "unsupported_resource_type" } |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::InvalidGrant; |
|
169
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
170
|
0
|
|
|
0
|
|
0
|
sub code { 401 } |
|
171
|
4
|
|
|
4
|
|
16
|
sub type { "invalid_grant" } |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::UnsupportedGrantType; |
|
174
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
175
|
0
|
|
|
0
|
|
0
|
sub type { "unsupported_grant_type" } |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::InvalidScope; |
|
178
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
179
|
0
|
|
|
0
|
|
0
|
sub code { 401 } |
|
180
|
0
|
|
|
0
|
|
0
|
sub type { "invalid_scope" } |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::InvalidToken; |
|
183
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
184
|
18
|
|
|
18
|
|
174
|
sub code { 401 } |
|
185
|
18
|
|
|
18
|
|
60
|
sub type { "invalid_token" } |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::ExpiredTokenLegacy; |
|
188
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
189
|
3
|
|
|
3
|
|
27
|
sub code { 401 } |
|
190
|
3
|
|
|
3
|
|
11
|
sub type { "expired_token" } |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::ExpiredToken; |
|
193
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
194
|
3
|
|
|
3
|
|
32
|
sub code { 401 } |
|
195
|
3
|
|
|
3
|
|
8
|
sub type { "invalid_token" } |
|
196
|
6
|
|
|
6
|
|
31
|
sub description { "The access token expired" } |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::InsufficientScope; |
|
199
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
200
|
0
|
|
|
0
|
|
|
sub code { 401 } |
|
201
|
0
|
|
|
0
|
|
|
sub type { "insufficient_scope" } |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error; |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 AUTHOR |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Lyo Kato, Elyo.kato@gmail.comE |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Copyright (C) 2010 by Lyo Kato |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
214
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
|
215
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
1; |