| 1 | package OpenID::Lite::Provider::Handler::CheckID; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Any::Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use OpenID::Lite::Constants::ModeType qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use OpenID::Lite::Constants::Namespace qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use OpenID::Lite::Constants::ProviderResponseType qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use OpenID::Lite::Provider::Response; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use OpenID::Lite::Message; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use OpenID::Lite::Realm; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use OpenID::Lite::Provider::AssociationBuilder; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use URI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | with 'OpenID::Lite::Role::ErrorHandler'; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | has 'setup_url' => ( | |||||||||||||||||||||||||||
| 16 | is => 'rw', | ||||||||||||||||||||||||||||
| 17 | isa => 'Str', | ||||||||||||||||||||||||||||
| 18 | required => 1, | ||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | has 'endpoint_url' => ( | |||||||||||||||||||||||||||
| 22 | is => 'rw', | ||||||||||||||||||||||||||||
| 23 | isa => 'Str', | ||||||||||||||||||||||||||||
| 24 | required => 1, | ||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 1 | 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 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub { return; } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 38 | 0 | }, | |||||||||||||||||||||||||||
| 39 | 1 | ); | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | has 'get_identity' => ( | ||||||||||||||||||||||||||||
| 42 | is => 'ro', | ||||||||||||||||||||||||||||
| 43 | isa => 'CodeRef', | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub { return; } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 46 | 0 | }, | |||||||||||||||||||||||||||
| 47 | 1 | ); | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | has 'is_identity' => ( | ||||||||||||||||||||||||||||
| 50 | is => 'ro', | ||||||||||||||||||||||||||||
| 51 | isa => 'CodeRef', | ||||||||||||||||||||||||||||
| 52 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub { return; } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 54 | 0 | }, | |||||||||||||||||||||||||||
| 55 | 1 | ); | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | has 'is_trusted' => ( | ||||||||||||||||||||||||||||
| 58 | is => 'ro', | ||||||||||||||||||||||||||||
| 59 | isa => 'CodeRef', | ||||||||||||||||||||||||||||
| 60 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub { return; } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 62 | 0 | }, | |||||||||||||||||||||||||||
| 63 | 1 | ); | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub handle_request { | ||||||||||||||||||||||||||
|
Subroutine
handle_request: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | my ( $self, $req_params ) = @_; | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | my $ns = $req_params->get('ns'); | |||||||||||||||||||||||||||
| 71 | 0 | my $return_to = $req_params->get('return_to'); | |||||||||||||||||||||||||||
| 72 | 0 | ▶ | return $self->ERROR(q{Missing parameter, "return_to"}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$return_to and $return_to =~ m[https?://]
MC/DC0%0/2
$return_to and $return_to =~ m[https?://]
$return_to
$return_to =~ m[https?://]
Truth table0%0/3
A and B
A= $return_toB= $return_to =~ m[https?://]
| |||||||||||||||||||||||||||||
| 73 | unless $return_to && $return_to =~ m!https?://!; | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | my $realm_key | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | = $req_params->is_openid2 | ||||||||||||||||||||||||||||
| 77 | ? 'realm' | ||||||||||||||||||||||||||||
| 78 | : 'trust_root'; | ||||||||||||||||||||||||||||
| 79 | 0 | my $realm = $req_params->get($realm_key); | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ($realm) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | return $self->ERROR(q{Invalid realm or return_to.}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | unless OpenID::Lite::Realm->check_url( $realm, $return_to ); | ||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | else { | ||||||||||||||||||||||||||||
| 86 | 0 | $realm = $return_to; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | 0 | $realm =~ s/\?.*//; | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | my $user = $self->get_user->(); | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | my $identity = $req_params->get('identity'); | |||||||||||||||||||||||||||
| 93 | 0 | ▶ | return $self->_build_error($req_params, q{Missing parameter, "identity"}, $ns) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | unless $identity; | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | my $res_params = OpenID::Lite::Message->new; | |||||||||||||||||||||||||||
| 97 | # XXX check | ||||||||||||||||||||||||||||
| 98 | 0 | $res_params->set( ns => $ns ); | |||||||||||||||||||||||||||
| 99 | 0 | $res_params->set( $realm_key, $realm ); | |||||||||||||||||||||||||||
| 100 | 0 | $res_params->set( claimed_id => $req_params->get('claimed_id') ); | |||||||||||||||||||||||||||
| 101 | 0 | $res_params->set( return_to => $req_params->get('return_to') ); | |||||||||||||||||||||||||||
| 102 | 0 | $res_params->set( assoc_handle => $req_params->get('assoc_handle') ); | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 0 | my $is_identity = 0; | |||||||||||||||||||||||||||
| 105 | 0 | ▶ | if ( $identity eq IDENTIFIER_SELECT ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 0 | $identity = $self->get_identity->($user, $realm); | |||||||||||||||||||||||||||
| 107 | 0 | $is_identity = 1; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | else { | ||||||||||||||||||||||||||||
| 110 | 0 | $is_identity = $self->is_identity->( $user, $identity, $realm ); | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | 0 | ▶ | my $is_trusted = $self->is_trusted->( $user, $realm ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | if $is_identity; | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | $res_params->set( identity => $identity ); | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if ($is_trusted) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | 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 | 0 | my $mode = $req_params->get('mode'); | |||||||||||||||||||||||||||
| 130 | 0 | ▶ | if ( $mode eq CHECKID_IMMEDIATE ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | # XXX : TODO use setup_map | ||||||||||||||||||||||||||||
| 133 | 0 | my $setup_params = { | |||||||||||||||||||||||||||
| 134 | return_to => $req_params->get('return_to'), | ||||||||||||||||||||||||||||
| 135 | identity => $identity, | ||||||||||||||||||||||||||||
| 136 | assoc_handle => $req_params->get('assoc_handle'), | ||||||||||||||||||||||||||||
| 137 | }; | ||||||||||||||||||||||||||||
| 138 | 0 | ▶ | $setup_params->{ ns } = $ns if $ns; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 139 | 0 | $setup_params->{ $realm_key } = $realm; | |||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | 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 | 0 | 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 | 0 | ▶ | sub _build_error { | ||||||||||||||||||||||||||
|
Subroutine
_build_error: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 162 | 0 | my ( $self, $req_params, $msg, $ns ) = @_; | |||||||||||||||||||||||||||
| 163 | 0 | ▶ | $ns ||= SIGNON_2_0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$ns ||= "http://specs.openid.net/auth/2.0/signon"
MC/DC0%0/1
$ns ||= "http://specs.openid.net/auth/2.0/signon"
$ns
Truth table0%0/2
A
A= $ns
| |||||||||||||||||||||||||||||
| 164 | 0 | my $error = OpenID::Lite::Message->new(); | |||||||||||||||||||||||||||
| 165 | 0 | $error->set( ns => $ns ); | |||||||||||||||||||||||||||
| 166 | 0 | $error->set( error => $msg ); | |||||||||||||||||||||||||||
| 167 | 0 | my $res = OpenID::Lite::Provider::Response->new( | |||||||||||||||||||||||||||
| 168 | type => CHECKID_ERROR, | ||||||||||||||||||||||||||||
| 169 | req_params => $req_params, | ||||||||||||||||||||||||||||
| 170 | res_params => $error, | ||||||||||||||||||||||||||||
| 171 | ); | ||||||||||||||||||||||||||||
| 172 | 0 | return $res; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 1 | ▶ | no Any::Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 176 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 177 | 1 | 1; | |||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||