line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenID::Lite::Provider::Handler::CheckID; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use Any::Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
4
|
1
|
|
|
1
|
|
542
|
use OpenID::Lite::Constants::ModeType qw(:all); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
136
|
|
5
|
1
|
|
|
1
|
|
5
|
use OpenID::Lite::Constants::Namespace qw(:all); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
116
|
|
6
|
1
|
|
|
1
|
|
5
|
use OpenID::Lite::Constants::ProviderResponseType qw(:all); |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
101
|
|
7
|
1
|
|
|
1
|
|
54
|
use OpenID::Lite::Provider::Response; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use OpenID::Lite::Message; |
9
|
|
|
|
|
|
|
use OpenID::Lite::Realm; |
10
|
|
|
|
|
|
|
use OpenID::Lite::Provider::AssociationBuilder; |
11
|
|
|
|
|
|
|
use URI; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'OpenID::Lite::Role::ErrorHandler'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'setup_url' => ( |
16
|
|
|
|
|
|
|
is => 'rw', |
17
|
|
|
|
|
|
|
isa => 'Str', |
18
|
|
|
|
|
|
|
required => 1, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'endpoint_url' => ( |
22
|
|
|
|
|
|
|
is => 'rw', |
23
|
|
|
|
|
|
|
isa => 'Str', |
24
|
|
|
|
|
|
|
required => 1, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'assoc_builder' => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
isa => 'OpenID::Lite::Provider::AssociationBuilder', |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# callbacks |
33
|
|
|
|
|
|
|
has 'get_user' => ( |
34
|
|
|
|
|
|
|
is => 'ro', |
35
|
|
|
|
|
|
|
isa => 'CodeRef', |
36
|
|
|
|
|
|
|
default => sub { |
37
|
|
|
|
|
|
|
sub { return; } |
38
|
|
|
|
|
|
|
}, |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has 'get_identity' => ( |
42
|
|
|
|
|
|
|
is => 'ro', |
43
|
|
|
|
|
|
|
isa => 'CodeRef', |
44
|
|
|
|
|
|
|
default => sub { |
45
|
|
|
|
|
|
|
sub { return; } |
46
|
|
|
|
|
|
|
}, |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has 'is_identity' => ( |
50
|
|
|
|
|
|
|
is => 'ro', |
51
|
|
|
|
|
|
|
isa => 'CodeRef', |
52
|
|
|
|
|
|
|
default => sub { |
53
|
|
|
|
|
|
|
sub { return; } |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has 'is_trusted' => ( |
58
|
|
|
|
|
|
|
is => 'ro', |
59
|
|
|
|
|
|
|
isa => 'CodeRef', |
60
|
|
|
|
|
|
|
default => sub { |
61
|
|
|
|
|
|
|
sub { return; } |
62
|
|
|
|
|
|
|
}, |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub handle_request { |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my ( $self, $req_params ) = @_; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $ns = $req_params->get('ns'); |
71
|
|
|
|
|
|
|
my $return_to = $req_params->get('return_to'); |
72
|
|
|
|
|
|
|
return $self->ERROR(q{Missing parameter, "return_to"}) |
73
|
|
|
|
|
|
|
unless $return_to && $return_to =~ m!https?://!; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $realm_key |
76
|
|
|
|
|
|
|
= $req_params->is_openid2 |
77
|
|
|
|
|
|
|
? 'realm' |
78
|
|
|
|
|
|
|
: 'trust_root'; |
79
|
|
|
|
|
|
|
my $realm = $req_params->get($realm_key); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
if ($realm) { |
82
|
|
|
|
|
|
|
return $self->ERROR(q{Invalid realm or return_to.}) |
83
|
|
|
|
|
|
|
unless OpenID::Lite::Realm->check_url( $realm, $return_to ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
else { |
86
|
|
|
|
|
|
|
$realm = $return_to; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
$realm =~ s/\?.*//; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $user = $self->get_user->(); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $identity = $req_params->get('identity'); |
93
|
|
|
|
|
|
|
return $self->_build_error($req_params, q{Missing parameter, "identity"}, $ns) |
94
|
|
|
|
|
|
|
unless $identity; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $res_params = OpenID::Lite::Message->new; |
97
|
|
|
|
|
|
|
# XXX check |
98
|
|
|
|
|
|
|
$res_params->set( ns => $ns ); |
99
|
|
|
|
|
|
|
$res_params->set( $realm_key, $realm ); |
100
|
|
|
|
|
|
|
$res_params->set( claimed_id => $req_params->get('claimed_id') ); |
101
|
|
|
|
|
|
|
$res_params->set( return_to => $req_params->get('return_to') ); |
102
|
|
|
|
|
|
|
$res_params->set( assoc_handle => $req_params->get('assoc_handle') ); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
my $is_identity = 0; |
105
|
|
|
|
|
|
|
if ( $identity eq IDENTIFIER_SELECT ) { |
106
|
|
|
|
|
|
|
$identity = $self->get_identity->($user, $realm); |
107
|
|
|
|
|
|
|
$is_identity = 1; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
else { |
110
|
|
|
|
|
|
|
$is_identity = $self->is_identity->( $user, $identity, $realm ); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
my $is_trusted = $self->is_trusted->( $user, $realm ) |
113
|
|
|
|
|
|
|
if $is_identity; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$res_params->set( identity => $identity ); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
if ($is_trusted) { |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
return OpenID::Lite::Provider::Response->new( |
120
|
|
|
|
|
|
|
type => POSITIVE_ASSERTION, |
121
|
|
|
|
|
|
|
req_params => $req_params, |
122
|
|
|
|
|
|
|
res_params => $res_params, |
123
|
|
|
|
|
|
|
assoc_builder => $self->assoc_builder, |
124
|
|
|
|
|
|
|
endpoint_url => $self->endpoint_url, |
125
|
|
|
|
|
|
|
setup_url => $self->setup_url, |
126
|
|
|
|
|
|
|
); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $mode = $req_params->get('mode'); |
130
|
|
|
|
|
|
|
if ( $mode eq CHECKID_IMMEDIATE ) { |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# XXX : TODO use setup_map |
133
|
|
|
|
|
|
|
my $setup_params = { |
134
|
|
|
|
|
|
|
return_to => $req_params->get('return_to'), |
135
|
|
|
|
|
|
|
identity => $identity, |
136
|
|
|
|
|
|
|
assoc_handle => $req_params->get('assoc_handle'), |
137
|
|
|
|
|
|
|
}; |
138
|
|
|
|
|
|
|
$setup_params->{ ns } = $ns if $ns; |
139
|
|
|
|
|
|
|
$setup_params->{ $realm_key } = $realm; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
return OpenID::Lite::Provider::Response->new( |
142
|
|
|
|
|
|
|
type => REQUIRES_SETUP, |
143
|
|
|
|
|
|
|
req_params => $req_params, |
144
|
|
|
|
|
|
|
setup_url => $self->setup_url, |
145
|
|
|
|
|
|
|
setup_params => $setup_params, |
146
|
|
|
|
|
|
|
res_params => $res_params, |
147
|
|
|
|
|
|
|
); |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
return OpenID::Lite::Provider::Response->new( |
152
|
|
|
|
|
|
|
type => SETUP, |
153
|
|
|
|
|
|
|
req_params => $req_params, |
154
|
|
|
|
|
|
|
res_params => $res_params, |
155
|
|
|
|
|
|
|
assoc_builder => $self->assoc_builder, |
156
|
|
|
|
|
|
|
endpoint_url => $self->endpoint_url, |
157
|
|
|
|
|
|
|
setup_url => $self->setup_url, |
158
|
|
|
|
|
|
|
); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub _build_error { |
162
|
|
|
|
|
|
|
my ( $self, $req_params, $msg, $ns ) = @_; |
163
|
|
|
|
|
|
|
$ns ||= SIGNON_2_0; |
164
|
|
|
|
|
|
|
my $error = OpenID::Lite::Message->new(); |
165
|
|
|
|
|
|
|
$error->set( ns => $ns ); |
166
|
|
|
|
|
|
|
$error->set( error => $msg ); |
167
|
|
|
|
|
|
|
my $res = OpenID::Lite::Provider::Response->new( |
168
|
|
|
|
|
|
|
type => CHECKID_ERROR, |
169
|
|
|
|
|
|
|
req_params => $req_params, |
170
|
|
|
|
|
|
|
res_params => $error, |
171
|
|
|
|
|
|
|
); |
172
|
|
|
|
|
|
|
return $res; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
no Any::Moose; |
176
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
177
|
|
|
|
|
|
|
1; |
178
|
|
|
|
|
|
|
|