| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error; |
|
2
|
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
13437
|
use strict; |
|
|
17
|
|
|
|
|
20
|
|
|
|
17
|
|
|
|
|
380
|
|
|
4
|
17
|
|
|
17
|
|
52
|
use warnings; |
|
|
17
|
|
|
|
|
19
|
|
|
|
17
|
|
|
|
|
835
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use overload |
|
7
|
45
|
|
|
45
|
|
4084
|
q{""} => sub { sprintf q{%s: %s}, $_[0]->type, $_[0]->description }, |
|
8
|
17
|
|
|
17
|
|
7179
|
fallback => 1; |
|
|
17
|
|
|
|
|
10212
|
|
|
|
17
|
|
|
|
|
118
|
|
|
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
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 METHODS |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
There are following errors |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 ERRORS |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=over 4 |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::InvalidRequest |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::InvalidClient |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::UnauthorizedClient |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::RedirectURIMismatch |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::AccessDenied |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::UnsupportedResponseType |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::UnsupportedResourceType |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::InvalidGrant |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::UnsupportedGrantType |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::InvalidScope |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::InvalidToken |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::ExpiredTokenLegacy |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::ExpiredToken |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::InsufficientScope |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::InvalidServerState |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::TemporarilyUnavailable |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item OAuth::Lite2::Server::Error::ServerError |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=back |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub new { |
|
132
|
73
|
|
|
73
|
0
|
6109
|
my ($class, %args) = @_; |
|
133
|
|
|
|
|
|
|
bless { |
|
134
|
|
|
|
|
|
|
description => $args{description} || '', |
|
135
|
|
|
|
|
|
|
state => $args{state} || '', |
|
136
|
73
|
|
100
|
|
|
961
|
code => $args{code} || 400, |
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
137
|
|
|
|
|
|
|
}, $class; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub throw { |
|
141
|
56
|
|
|
56
|
0
|
612
|
my ($class, %args) = @_; |
|
142
|
56
|
|
|
|
|
155
|
die $class->new(%args); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
8
|
|
|
8
|
0
|
1322
|
sub code { $_[0]->{code} } |
|
146
|
0
|
|
|
0
|
0
|
0
|
sub type { die "abstract method" } |
|
147
|
69
|
|
|
69
|
0
|
405
|
sub description { $_[0]->{description} } |
|
148
|
0
|
|
|
0
|
0
|
0
|
sub state { $_[0]->{state} } |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# OAuth Server Error |
|
151
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::InvalidRequest; |
|
152
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
153
|
13
|
|
|
13
|
|
50
|
sub type { "invalid_request" } |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::InvalidClient; |
|
156
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
157
|
1
|
|
|
1
|
|
295
|
sub code { 401 } |
|
158
|
5
|
|
|
5
|
|
25
|
sub type { "invalid_client" } |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::UnauthorizedClient; |
|
161
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
162
|
1
|
|
|
1
|
|
257
|
sub code { 401 } |
|
163
|
1
|
|
|
1
|
|
4
|
sub type { "unauthorized_client" } |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::RedirectURIMismatch; |
|
166
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
167
|
1
|
|
|
1
|
|
253
|
sub code { 401 } |
|
168
|
2
|
|
|
2
|
|
9
|
sub type { "redirect_uri_mismatch" } |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::AccessDenied; |
|
171
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
172
|
1
|
|
|
1
|
|
256
|
sub code { 401 } |
|
173
|
1
|
|
|
1
|
|
6
|
sub type { "access_denied" } |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::UnsupportedResponseType; |
|
176
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
177
|
1
|
|
|
1
|
|
4
|
sub type { "unsupported_response_type" } |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::UnsupportedResourceType; |
|
180
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
181
|
1
|
|
|
1
|
|
4
|
sub type { "unsupported_resource_type" } |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::InvalidGrant; |
|
184
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
185
|
1
|
|
|
1
|
|
256
|
sub code { 401 } |
|
186
|
12
|
|
|
12
|
|
40
|
sub type { "invalid_grant" } |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::UnsupportedGrantType; |
|
189
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
190
|
1
|
|
|
1
|
|
4
|
sub type { "unsupported_grant_type" } |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::InvalidScope; |
|
193
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
194
|
1
|
|
|
1
|
|
250
|
sub code { 401 } |
|
195
|
2
|
|
|
2
|
|
8
|
sub type { "invalid_scope" } |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::InvalidToken; |
|
198
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
199
|
19
|
|
|
19
|
|
392
|
sub code { 401 } |
|
200
|
19
|
|
|
19
|
|
51
|
sub type { "invalid_token" } |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::ExpiredTokenLegacy; |
|
203
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
204
|
4
|
|
|
4
|
|
295
|
sub code { 401 } |
|
205
|
4
|
|
|
4
|
|
13
|
sub type { "expired_token" } |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::ExpiredToken; |
|
208
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
209
|
4
|
|
|
4
|
|
356
|
sub code { 401 } |
|
210
|
4
|
|
|
4
|
|
14
|
sub type { "invalid_token" } |
|
211
|
7
|
|
|
7
|
|
27
|
sub description { "The access token expired" } |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::InsufficientScope; |
|
214
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
215
|
1
|
|
|
1
|
|
259
|
sub code { 401 } |
|
216
|
1
|
|
|
1
|
|
5
|
sub type { "insufficient_scope" } |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::InvalidServerState; |
|
219
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
220
|
1
|
|
|
1
|
|
295
|
sub code { 401 } |
|
221
|
4
|
|
|
4
|
|
12
|
sub type { "invalid_server_state" } |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
# Generally, the client knows the state of the server by HTTP Status Code. |
|
224
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::TemporarilyUnavailable; |
|
225
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
226
|
1
|
|
|
1
|
|
250
|
sub code { 503 } |
|
227
|
1
|
|
|
1
|
|
5
|
sub type { "temporarily_unavailable" } |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error::ServerError; |
|
230
|
|
|
|
|
|
|
our @ISA = qw(OAuth::Lite2::Server::Error); |
|
231
|
1
|
|
|
1
|
|
249
|
sub code { 500 } |
|
232
|
1
|
|
|
1
|
|
4
|
sub type { "server_error" } |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
package OAuth::Lite2::Server::Error; |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head1 AUTHOR |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
Ryo Ito, Eritou.06@gmail.comE |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Lyo Kato, Elyo.kato@gmail.comE |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Copyright (C) 2010 by Lyo Kato |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
247
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
|
248
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=cut |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
1; |