line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::OAuth::AccessToken; |
2
|
3
|
|
|
3
|
|
36978
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
95
|
|
3
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
84
|
|
4
|
3
|
|
|
3
|
|
961
|
use Plack::Session; |
|
3
|
|
|
|
|
2072
|
|
|
3
|
|
|
|
|
97
|
|
5
|
3
|
|
|
3
|
|
19
|
use Plack::Util::Accessor qw(params provider version); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
25
|
|
6
|
|
|
|
|
|
|
use overload |
7
|
|
|
|
|
|
|
'""' => sub { |
8
|
2
|
|
|
2
|
|
1096
|
my $self = shift; |
9
|
2
|
|
|
|
|
6
|
return $self->access_token; |
10
|
3
|
|
|
3
|
|
2402
|
}; |
|
3
|
|
|
|
|
1395
|
|
|
3
|
|
|
|
|
34
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
1
|
|
|
1
|
0
|
22
|
my ($class,%args) = @_; |
14
|
1
|
|
50
|
|
|
5
|
$args{params} ||= { }; |
15
|
1
|
|
|
|
|
5
|
return bless \%args , $class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub is_provider { |
19
|
0
|
|
|
0
|
0
|
0
|
return $_[0]->provider eq $_[1]; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub has_error { |
23
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
24
|
0
|
|
|
|
|
0
|
return $self->{params}->{error}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub access_token { |
28
|
2
|
|
|
2
|
0
|
12
|
return $_[0]->{params}->{access_token}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub access_token_secret { |
32
|
0
|
|
|
0
|
0
|
|
return $_[0]->{params}->{access_token_secret}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub code { |
36
|
0
|
|
|
0
|
0
|
|
return $_[0]->{params}->{code}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub hashref { |
40
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
41
|
0
|
|
|
|
|
|
return \%$self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub extra { |
45
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
46
|
0
|
|
0
|
|
|
|
return $self->params->{extra} || { }; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub register_session { |
50
|
0
|
|
|
0
|
0
|
|
my ($self,$env) = @_; |
51
|
0
|
|
|
|
|
|
my $session = Plack::Session->new( $env ); |
52
|
0
|
|
|
|
|
|
my $provider_id = lc($self->provider); |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$session->set( 'oauth.' . $provider_id , 1 ); |
55
|
0
|
|
|
|
|
|
$session->set( 'oauth.' . $provider_id . '.version' , $self->version ); |
56
|
0
|
|
|
|
|
|
$session->set( 'oauth.' . $provider_id . '.access_token' , $self->access_token ); |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
if( $self->version == 2 ) { |
|
|
0
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$session->set( 'oauth.' . $provider_id . '.code' , $self->{params}->{code} ); |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
$session->set( 'oauth.' . $provider_id . '.token_type' , $self->{params}->{token_type} ) |
62
|
|
|
|
|
|
|
if $self->params->{token_type}; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
$session->set( 'oauth.' . $provider_id . '.refresh_token' , $self->{params}->{refresh_token} ) |
65
|
|
|
|
|
|
|
if $self->params->{refresh_token}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
elsif( $self->version == 1 ) { |
68
|
0
|
|
|
|
|
|
$session->set( 'oauth.' . $provider_id . '.access_token_secret' , $self->{params}->{access_token_secret} ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |