line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::OAuth::Handler; |
2
|
2
|
|
|
2
|
|
945
|
use parent qw(Plack::Middleware::OAuth::GenericHandler); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
13
|
|
3
|
2
|
|
|
2
|
|
106
|
use warnings; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
74
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
77
|
|
5
|
2
|
|
|
2
|
|
12
|
use Digest::MD5 qw(md5_hex); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
104
|
|
6
|
2
|
|
|
2
|
|
12
|
use DateTime; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
53
|
|
7
|
2
|
|
|
2
|
|
10
|
use Plack::Util::Accessor qw(config provider on_success on_error); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
22
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Plack::Middleware::OAuth::Handler - OAuth Handler |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 ACCESSORS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head2 provider |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Provider id. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 config |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Provider configuration hash reference. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 on_success |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
On success handler. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 on_error |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
On error handler. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 METHODS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 default_callback |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return default callback URL. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub default_callback { |
40
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
41
|
0
|
|
|
|
|
|
my $provider = $self->provider; |
42
|
0
|
|
|
|
|
|
my $env = $self->env; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# 'REQUEST_URI' => '/oauth/twitter', |
45
|
|
|
|
|
|
|
# 'SCRIPT_NAME' => '/oauth', |
46
|
|
|
|
|
|
|
# 'PATH_INFO' => '/twitter', |
47
|
0
|
|
|
|
|
|
return URI->new( $env->{'psgi.url_scheme'} . '://' . |
48
|
|
|
|
|
|
|
$env->{HTTP_HOST} . $env->{SCRIPT_NAME} . '/' . lc($provider) . '/callback' ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub build_v1_common_args { |
52
|
0
|
|
|
0
|
0
|
|
my $self = $_[0]; |
53
|
0
|
|
|
|
|
|
my $config = $self->config; |
54
|
|
|
|
|
|
|
return ( |
55
|
0
|
|
|
|
|
|
consumer_key => $config->{consumer_key}, |
56
|
|
|
|
|
|
|
consumer_secret => $config->{consumer_secret}, |
57
|
|
|
|
|
|
|
signature_method => $config->{signature_method}, |
58
|
|
|
|
|
|
|
timestamp => DateTime->now->epoch, |
59
|
|
|
|
|
|
|
nonce => md5_hex(time), |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|