« blib/lib/Lemonldap/NG/Portal/Plugins/BasePasswordPolicy.pm
↑ Summary
blib/lib/Lemonldap/NG/Portal/Lib/Notifications/XML.pm »
| 1 | package Lemonldap::NG::Portal::Issuer::CAS; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use Mouse; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Lemonldap::NG::Common::FormEncode; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Lemonldap::NG::Portal::Main::Constants qw( | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | portalConsts | ||||||||||||||||||||||||||||||||||||||||||||||
| 9 | URIRE | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | PE_OK | ||||||||||||||||||||||||||||||||||||||||||||||
| 11 | PE_INFO | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | PE_ERROR | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | PE_LOGOUT_OK | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | PE_SENDRESPONSE | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | PE_UNKNOWNPARTNER | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | PE_UNAUTHORIZEDURL | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | PE_UNAUTHORIZEDPARTNER | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | PE_BADURL | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | PE_CAS_SERVICE_NOT_ALLOWED | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 6 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 6 | our $VERSION = '2.23.0'; | |||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 6 | extends 'Lemonldap::NG::Portal::Main::Issuer', | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | 'Lemonldap::NG::Portal::Lib::CAS'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # INITIALIZATION | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 6 | ▶ | use constant beforeAuth => 'storeEnvAndCheckGateway'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 6 | ▶ | use constant sessionKind => 'ICAS'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 6 | ▶ | use constant hook => { updateSessionId => 'updateCasSecondarySessions', }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 6 | has rule => ( is => 'rw' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 44 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=6 SCAR=19.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 44 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # Parse activation rule | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 44 | my $hd = $self->p->HANDLER; | |||||||||||||||||||||||||||||||||||||||||||||
| 40 | 44 | $self->logger->debug( "CAS rule -> " . $self->conf->{issuerDBCASRule} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | my $rule = | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 44 | $hd->buildSub( $hd->substitute( $self->conf->{issuerDBCASRule} ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 43 | 44 | ▶ | unless ($rule) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | my $error = $hd->tsv->{jail}->error || '???'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$hd->tsv->{'jail'}->error || '???'
MC/DC0%0/1
$hd->tsv->{'jail'}->error || '???'
$hd->tsv->{'jail'}->error
Truth table0%0/2
A
A= $hd->tsv->{'jail'}->error
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $self->error("Bad CAS activation rule -> $error"); | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 44 | $self->{rule} = $rule; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # Launch parents initialization subroutines, then launch IdP and SP lists | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 44 | my $res = $self->Lemonldap::NG::Portal::Main::Issuer::init(); | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | 44 | ▶ | return 0 unless ( $self->loadApp ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 44 | $self->addUnauthRoute( | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | ( $self->path ) => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | samlValidate => 'samlValidate', | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | serviceValidate => 'serviceValidate', | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | relayLogout => 'relayLogout', | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | validate => 'validate', | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | logout => 'unauthlogout', | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | proxyValidate => 'proxyValidate', | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | proxy => 'proxy', | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | p3 => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | serviceValidate => 'serviceValidate', | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | proxyValidate => 'proxyValidate' | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ['GET'] | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 44 | $self->addUnauthRoute( | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | ( $self->path ) => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | samlValidate => 'samlValidate', | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | ['POST'] | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # Add CAS Services, so we can check service= parameter on logout | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 44 | foreach my $casSrv ( keys %{ $self->casAppList } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | 85 | for my $serviceUrl ( | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | split( | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | /\s+/, | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | $self->casAppList->{$casSrv}->{casAppMetaDataOptionsService} | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 89 | push @{ $self->p->{additionalTrustedDomains} }, $serviceUrl; | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | 89 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | "CAS Service $serviceUrl added in trusted domains"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 44 | return $res; | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # RUNNING METHODS | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 35 | ▶ | sub storeEnvAndCheckGateway { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
storeEnvAndCheckGateway: called CC=13 SCAR=26.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 35 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 98 | 35 | ▶ | my $service = $self->p->getHiddenFormValue( $req, 'service' ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->p->getHiddenFormValue($req, 'service') || $req->param('service')
MC/DC50%1/2
$self->p->getHiddenFormValue($req, 'service') || $req->param('service')
$self->p->getHiddenFormValue($req, 'service')
$req->param('service')
Truth table66%2/3
A || B
A= $self->p->getHiddenFormValue($req, 'service')B= $req->param('service')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | || $req->param('service'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 35 | ▶ | $service = '' if ( $self->p->checkXSSAttackUrldc( 'service', $service ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 35 | ▶ | my $gateway = $self->p->getHiddenFormValue( $req, 'gateway' ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->p->getHiddenFormValue($req, 'gateway') || $req->param('gateway')
MC/DC50%1/2
$self->p->getHiddenFormValue($req, 'gateway') || $req->param('gateway')
$self->p->getHiddenFormValue($req, 'gateway')
$req->param('gateway')
Truth table66%2/3
A || B
A= $self->p->getHiddenFormValue($req, 'gateway')B= $req->param('gateway')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | || $req->param('gateway'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 35 | ▶ | if ( $gateway and $gateway eq "true" ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$gateway and $gateway eq "true"
MC/DC50%1/2
$gateway and $gateway eq "true"
$gateway
$gateway eq "true"
Truth table66%2/3
A and B
A= $gatewayB= $gateway eq "true"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 4 | ▶ | if ( $self->_gatewayAllowedRedirect( $req, $service ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | "Gateway mode requested, redirect without authentication"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | $req->response( | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | $self->p->sendRedirection( | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | $req, URI->new($service)->as_string | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | for my $s ( $self->ipath, $self->ipath . 'Path' ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | $self->logger->debug("Removing $s from pdata") | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 4 | ▶ | if delete $req->pdata->{$s}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | return PE_SENDRESPONSE; | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 2 | $self->logger->error( | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | "Disallowing redirection to unknown service $service"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | return PE_UNKNOWNPARTNER; | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 31 | ▶ | if ( $service and $service =~ URIRE ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$service and $service =~ m[(((?^:https?))://((?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::((?:[0-9]*)))?(/(((?:(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:/(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?]((?:(?:[;/?:\@&=+\$,a-zA-Z0-9\-_.!~*'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)]
MC/DC50%1/2
$service and $service =~ m[(((?^:https?))://((?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::((?:[0-9]*)))?(/(((?:(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:/(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?]((?:(?:[;/?:\@&=+\$,a-zA-Z0-9\-_.!~*'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)]
$service
$service =~ m[(((?^:https?))://((?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::((?:[0-9]*)))?(/(((?:(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:/(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?]((?:(?:[;/?:\@&=+\$,a-zA-Z0-9\-_.!~*'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)]
Truth table66%2/3
A and B
A= $serviceB= $service =~ m[(((?^:https?))://((?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::((?:[0-9]*)))?(/(((?:(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:/(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?]((?:(?:[;/?:\@&=+\$,a-zA-Z0-9\-_.!~*'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 6 | my $app = $self->getCasApp($service); | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 6 | ▶ | if ($app) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 4 | $req->env->{llng_cas_app} = $app; | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # Store target authentication level in pdata | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 4 | my $targetAuthnLevel = $self->spLevelRules->{$app}->( $req, {} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 4 | ▶ | $req->pdata->{targetAuthnLevel} = $targetAuthnLevel | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | if $targetAuthnLevel; | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 31 | return PE_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 4 | ▶ | sub _gatewayAllowedRedirect { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_gatewayAllowedRedirect: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 4 | my ( $self, $req, $service ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 4 | my $app = $self->getCasApp($service); | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | 4 | my $casAccessControlPolicy = $self->conf->{casAccessControlPolicy}; | |||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # Redirect is allowed if there is no access control or if | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # the service is declared in CAS apps | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 4 | ▶ | if ( $casAccessControlPolicy !~ /^(error|faketicket)$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 4 | ▶ | if ($app) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # Main method (launched only for authenticated users, see Main/Issuer) | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 29 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=49 SCAR=53.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 29 | my ( $self, $req, $target ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # Check activation rule | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 29 | ▶ | unless ( $self->rule->( $req, $req->sessionInfo ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $self->userLogger->error('CAS service not authorized'); | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | return PE_CAS_SERVICE_NOT_ALLOWED; | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # CAS URL | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 29 | my $cas_login = 'login'; | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | 29 | my $cas_logout = 'logout'; | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | 29 | my $cas_validate = 'validate'; | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | 29 | my $cas_serviceValidate = 'serviceValidate'; | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | 29 | my $cas_p3_serviceValidate = 'p3/serviceValidate'; | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | 29 | my $cas_proxyValidate = 'proxyValidate'; | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | 29 | my $cas_p3_proxyValidate = 'p3/proxyValidate'; | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | 29 | my $cas_proxy = 'proxy'; | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # Called URL | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 29 | my $url = $req->uri(); | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # Session ID | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 29 | ▶ | my $session_id = $req->{sessionInfo}->{_session_id} || $req->id; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$req->{'sessionInfo'}{'_session_id'} || $req->id
MC/DC0%0/2
$req->{'sessionInfo'}{'_session_id'} || $req->id
$req->{'sessionInfo'}{'_session_id'}
$req->id
Truth table33%1/3
A || B
A= $req->{'sessionInfo'}{'_session_id'}B= $req->id
| |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # 1. LOGIN | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 29 | ▶ | if ( $target eq $cas_login ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 11 | $self->logger->debug("URL $url detected as an CAS LOGIN URL"); | |||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 11 | my $cas_request = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 11 | foreach my $param (qw/service renew gateway/) { | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | 33 | ▶ | $cas_request->{$param} = | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->p->getHiddenFormValue($req, $param) || $req->param($param)
MC/DC50%1/2
$self->p->getHiddenFormValue($req, $param) || $req->param($param)
$self->p->getHiddenFormValue($req, $param)
$req->param($param)
Truth table66%2/3
A || B
A= $self->p->getHiddenFormValue($req, $param)B= $req->param($param)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | $self->p->getHiddenFormValue( $req, $param ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | || $req->param($param); | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 11 | my $h = $self->p->processHook( $req, 'casGotRequest', $cas_request ); | |||||||||||||||||||||||||||||||||||||||||||||
| 203 | 11 | ▶ | return $self->_failLogin( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | msg => "casGotRequest hook failed", | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | res => $h | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | ) if ( $h != PE_OK ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 11 | my $service = $cas_request->{service}; | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | 11 | ▶ | $service = '' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | if ( $self->p->checkXSSAttackUrldc( 'service', $service ) ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 11 | my $renew = $cas_request->{renew}; | |||||||||||||||||||||||||||||||||||||||||||||
| 213 | 11 | my $gateway = $cas_request->{gateway}; | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # If no service defined, exit | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 11 | ▶ | unless ( defined $service ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->logger->debug("No service defined in CAS URL"); | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | return PE_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 11 | ▶ | unless ( $service =~ m#^(https?://[^/]+)(/.*)?$# ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | return $self->_failLogin( | |||||||||||||||||||||||||||||||||||||||||||||
| 223 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | msg => "Bad service $service", | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | res => PE_BADURL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 11 | my $app = $self->getCasApp($service); | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 11 | my $spAuthnLevel = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 231 | 11 | ▶ | if ($app) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | $spAuthnLevel = | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 10 | $self->spLevelRules->{$app}->( $req, $req->sessionInfo ); | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # Renew | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 11 | ▶ | if ( $renew | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$renew and $renew eq "true" and &CORE::GLOBAL::time() - $req->sessionInfo->{"_lastAuthnUTime"} > $self->conf->{"portalForceAuthnInterval"}
$renew and $renew eq "true"
MC/DC0%0/3
$renew and $renew eq "true" and &CORE::GLOBAL::time() - $req->sessionInfo->{"_lastAuthnUTime"} > $self->conf->{"portalForceAuthnInterval"}
$renew
$renew eq "true"
&CORE::GLOBAL::time() - $req->sessionInfo->{"_lastAuthnUTime"} > $self->conf->{"portalForceAuthnInterval"}
Truth table25%1/4
A and B and C
A= $renewB= $renew eq "true"C= &CORE::GLOBAL::time() - $req->sessionInfo->{"_lastAuthnUTime"} > $self->conf->{"portalForceAuthnInterval"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | and $renew eq 'true' | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | and time - $req->sessionInfo->{_lastAuthnUTime} > | ||||||||||||||||||||||||||||||||||||||||||||||
| 240 | $self->conf->{portalForceAuthnInterval} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # Authentication must be replayed | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $self->logger->debug("Authentication renew requested"); | |||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $self->{updateSession} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $req->env->{QUERY_STRING} =~ s/renew=true/renew=false/; | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $req->pdata->{targetAuthnLevel} = $spAuthnLevel; | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | return $self->reAuth($req); | |||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # Check access on the service | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 11 | my $casAccessControlPolicy = $self->conf->{casAccessControlPolicy}; | |||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 11 | ▶ | if ( $casAccessControlPolicy =~ /^(error|faketicket)$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 11 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 257 | "CAS access control requested on service $service"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 11 | ▶ | unless ($app) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | return $self->_failLogin( | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | msg => 'CAS service not configured', | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | res => PE_UNKNOWNPARTNER, | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # Check if we have sufficient auth level | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | my $authenticationLevel = | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 10 | ▶ | $req->{sessionInfo}->{authenticationLevel} || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$req->{'sessionInfo'}{'authenticationLevel'} || 0
MC/DC0%0/1
$req->{'sessionInfo'}{'authenticationLevel'} || 0
$req->{'sessionInfo'}{'authenticationLevel'}
Truth table50%1/2
A
A= $req->{'sessionInfo'}{'authenticationLevel'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 10 | ▶ | if ( $authenticationLevel < $spAuthnLevel ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | "Insufficient authentication level for service $app" | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | . " (has: $authenticationLevel, want: $spAuthnLevel)" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # Reauth with sp auth level as target | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | $req->pdata->{targetAuthnLevel} = $spAuthnLevel; | |||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | return $self->upgradeAuth($req); | |||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # Check access rule | ||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 10 | ▶ | if ( my $rule = $self->spRules->{$app} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if ( $rule->( $req, $req->sessionInfo ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $self->logger->debug("CAS service $service access allowed"); | |||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 285 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | return $self->_failLoginRule( $req, $cas_request, $app ); | |||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | # Check last authentication time to decide if | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # the authentication is recent or not | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 10 | my $casRenewFlag = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 294 | 10 | ▶ | my $last_authn_utime = $req->{sessionInfo}->{_lastAuthnUTime} || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$req->{'sessionInfo'}{'_lastAuthnUTime'} || 0
MC/DC0%0/1
$req->{'sessionInfo'}{'_lastAuthnUTime'} || 0
$req->{'sessionInfo'}{'_lastAuthnUTime'}
Truth table50%1/2
A
A= $req->{'sessionInfo'}{'_lastAuthnUTime'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 10 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | time() - $last_authn_utime < | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | $self->conf->{portalForceAuthnInterval} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 298 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 10 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 300 | "Authentication is recent, will set CAS renew flag to true"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 10 | $casRenewFlag = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # Create a service ticket | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | $self->logger->debug( | ||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 10 | "Create a CAS service ticket for service $service"); | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||
| 308 | my $_utime = | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | $self->conf->{casTicketExpiration} | ||||||||||||||||||||||||||||||||||||||||||||||
| 310 | ? ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | time + $self->conf->{casTicketExpiration} - $self->conf->{timeout} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 10 | ▶ | : ( $req->{sessionInfo}->{_utime} || time() ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$req->{"sessionInfo"}{"_utime"} or &CORE::GLOBAL::time()
MC/DC0%0/2
$req->{"sessionInfo"}{"_utime"} or &CORE::GLOBAL::time()
$req->{"sessionInfo"}{"_utime"}
&CORE::GLOBAL::time()
Truth table33%1/3
A or B
A= $req->{"sessionInfo"}{"_utime"}B= &CORE::GLOBAL::time()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 10 | my $Sinfos; | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | 10 | $Sinfos->{type} = 'casService'; | |||||||||||||||||||||||||||||||||||||||||||||
| 316 | 10 | $Sinfos->{service} = $service; | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | 10 | $Sinfos->{renew} = $casRenewFlag; | |||||||||||||||||||||||||||||||||||||||||||||
| 318 | 10 | $Sinfos->{_cas_id} = $session_id; | |||||||||||||||||||||||||||||||||||||||||||||
| 319 | 10 | $Sinfos->{_utime} = $_utime; | |||||||||||||||||||||||||||||||||||||||||||||
| 320 | 10 | $Sinfos->{_casApp} = $app; | |||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 10 | $h = $self->p->processHook( $req, 'casGenerateServiceTicket', | |||||||||||||||||||||||||||||||||||||||||||||
| 323 | $cas_request, $app, $Sinfos ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 10 | ▶ | return $self->_failLogin( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 325 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | msg => 'casGenerateServiceTicket hook failed', | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | res => $h, | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | ( $app ? ( app => $app ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | ) if ( $h != PE_OK ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 10 | my $casServiceSession = $self->getCasSession( undef, $Sinfos ); | |||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 10 | ▶ | unless ($casServiceSession) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | return $self->_failLogin( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 335 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 336 | msg => "Unable to create CAS session", | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | ( $app ? ( app => $app ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 338 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 10 | my $casServiceSessionID = $casServiceSession->id; | |||||||||||||||||||||||||||||||||||||||||||||
| 342 | 10 | my $casServiceTicket = "ST-" . $casServiceSessionID; | |||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 10 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 345 | "CAS service session $casServiceSessionID created"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 10 | my $user = $req->sessionInfo->{ $self->conf->{whatToTrace} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 348 | 10 | ▶ | $self->auditLog( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | code => "ISSUER_CAS_LOGIN_SUCCESS", | ||||||||||||||||||||||||||||||||||||||||||||||
| 351 | ( $app ? ( app => $app ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 352 | service => $service, | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | user => $user, | ||||||||||||||||||||||||||||||||||||||||||||||
| 354 | message => ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 355 | $app | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | ? ("User $user is authorized to access $app") | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | : ("User $user is redirected to $service") | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||
| 361 | return $self->_redirectUser( $req, $cas_request->{service}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 10 | $casServiceTicket ); | |||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||
| 365 | # 2. LOGOUT | ||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 18 | ▶ | if ( $target eq $cas_logout ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 18 | $self->logger->debug("URL $url detected as an CAS LOGOUT URL"); | |||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # Disable Content-Security-Policy header since logout can be embedded | ||||||||||||||||||||||||||||||||||||||||||||||
| 371 | # in a frame | ||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 18 | $req->frame(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | # GET parameters | ||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 18 | my $logout_url = $req->param('url'); # CAS 2.0 | |||||||||||||||||||||||||||||||||||||||||||||
| 376 | 18 | my $logout_service = $req->param('service'); # CAS 3.0 | |||||||||||||||||||||||||||||||||||||||||||||
| 377 | 18 | ▶ | $logout_service = '' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 378 | if ( $self->p->checkXSSAttackUrldc( 'service', $logout_service ) ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | # If we use access control, check that the service URL is trusted | ||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 18 | ▶ | if ( $self->conf->{casAccessControlPolicy} =~ /^(error|faketicket)$/i ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 18 | ▶ | if ( $logout_service | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$logout_service and not $self->p->isTrustedUrl($logout_service)
MC/DC100%2/2
$logout_service and not $self->p->isTrustedUrl($logout_service)
$logout_service
not $self->p->isTrustedUrl($logout_service)
Truth table100%3/3
A and not(B)
A= $logout_serviceB= not $self->p->isTrustedUrl($logout_service)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 384 | and not $self->p->isTrustedUrl($logout_service) ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 385 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 4 | $self->userLogger->error( | |||||||||||||||||||||||||||||||||||||||||||||
| 387 | "Untrusted service URL $logout_service" | ||||||||||||||||||||||||||||||||||||||||||||||
| 388 | . "specified for CAS Logout" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 4 | return PE_UNAUTHORIZEDURL; | |||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # Legacy code without logout propagation for CAS 2.0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 14 | ▶ | if ($logout_url) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 4 | my $session = $self->p->getApacheSession($session_id); | |||||||||||||||||||||||||||||||||||||||||||||
| 396 | 4 | ▶ | return PE_LOGOUT_OK unless ($session); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # This will call Issuer logout methods, incluing our own | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # TODO: call authLogout and deleteSession instead of duplicating code | ||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 4 | my $res = $self->p->do( $req, [ @{ $self->p->beforeLogout } ] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 4 | ▶ | unless ( $self->p->_deleteSession( $req, $session ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $self->logger->error("Fail to delete session $session_id "); | |||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||
| 406 | # Display a link to the provided URL | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 4 | $self->logger->debug("Logout URL $logout_url will be displayed"); | |||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 4 | $req->info( | |||||||||||||||||||||||||||||||||||||||||||||
| 410 | $self->loadTemplate( | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | $req, 'casBack2Url', params => { url => $logout_url } | ||||||||||||||||||||||||||||||||||||||||||||||
| 412 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 4 | $req->data->{activeTimer} = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 4 | delete $req->pdata->{_url}; | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | 4 | return PE_INFO; | |||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 419 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 10 | ▶ | $req->{issuerNextUrl} = $logout_service if $logout_service; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 10 | $req->data->{nofail} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 422 | $req->steps( | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 10 | [ @{ $self->p->beforeLogout }, "authLogout", "deleteSession" ] | |||||||||||||||||||||||||||||||||||||||||||||
| 424 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 10 | my $res = $self->p->process($req); | |||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 10 | $req->error($res); | |||||||||||||||||||||||||||||||||||||||||||||
| 428 | 10 | ▶ | if ( $res and $res != PE_LOGOUT_OK ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$res and $res != 47
MC/DC0%0/2
$res and $res != 47
$res
$res != 47
Truth table33%1/3
A and B
A= $resB= $res != 47
| |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | if ( $res > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $self->logger->error( | |||||||||||||||||||||||||||||||||||||||||||||
| 431 | "Logout process returns error code $res"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | return $res; | |||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 10 | ▶ | if ($logout_service) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 6 | return $self->_redirectUser( $req, $logout_service ); | |||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 4 | return PE_LOGOUT_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # 3. VALIDATE [CAS 1.0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | if ( $target eq $cas_validate ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | $self->logger->debug("URL $url detected as an CAS VALIDATE URL"); | |||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||
| 450 | # This URL must not be called by authenticated users | ||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $self->userLogger->info( | |||||||||||||||||||||||||||||||||||||||||||||
| 452 | "CAS VALIDATE URL called by authenticated user, ignore it"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | return PE_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||
| 457 | # 4. SERVICE VALIDATE [CAS 2.0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | if ( $target eq $cas_serviceValidate | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$target eq $cas_serviceValidate or $target eq $cas_p3_serviceValidate
MC/DC0%0/2
$target eq $cas_serviceValidate or $target eq $cas_p3_serviceValidate
$target eq $cas_serviceValidate
$target eq $cas_p3_serviceValidate
Truth table0%0/3
A or B
A= $target eq $cas_serviceValidateB= $target eq $cas_p3_serviceValidate
| |||||||||||||||||||||||||||||||||||||||||||||||
| 459 | || $target eq $cas_p3_serviceValidate ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 460 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 463 | "URL $url detected as an CAS SERVICE VALIDATE URL"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||
| 465 | # This URL must not be called by authenticated users | ||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | $self->userLogger->info( | |||||||||||||||||||||||||||||||||||||||||||||
| 467 | "CAS SERVICE VALIDATE URL called by authenticated user, ignore it"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | return PE_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||
| 472 | # 5. PROXY VALIDATE [CAS 2.0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | if ( $target eq $cas_proxyValidate || $target eq $cas_p3_proxyValidate ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$target eq $cas_proxyValidate or $target eq $cas_p3_proxyValidate
MC/DC0%0/2
$target eq $cas_proxyValidate or $target eq $cas_p3_proxyValidate
$target eq $cas_proxyValidate
$target eq $cas_p3_proxyValidate
Truth table0%0/3
A or B
A= $target eq $cas_proxyValidateB= $target eq $cas_p3_proxyValidate
| |||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | $self->logger->debug("URL $url detected as an CAS PROXY VALIDATE URL"); | |||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||
| 477 | # This URL must not be called by authenticated users | ||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | $self->userLogger->info( | |||||||||||||||||||||||||||||||||||||||||||||
| 479 | "CAS PROXY VALIDATE URL called by authenticated user, ignore it"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | return PE_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # 6. PROXY [CAS 2.0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | if ( $target eq $cas_proxy ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | $self->logger->debug("URL $url detected as an CAS PROXY URL"); | |||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||
| 489 | # This URL must not be called by authenticated users | ||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $self->userLogger->info( | |||||||||||||||||||||||||||||||||||||||||||||
| 491 | "CAS PROXY URL called by authenticated user, ignore it"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | return PE_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | return PE_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 14 | ▶ | sub logout { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logout: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 14 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||
| 502 | # Session ID | ||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 14 | ▶ | my $session_id = $req->{sessionInfo}->{_session_id} || $req->id; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$req->{'sessionInfo'}{'_session_id'} || $req->id
MC/DC0%0/2
$req->{'sessionInfo'}{'_session_id'} || $req->id
$req->{'sessionInfo'}{'_session_id'}
$req->id
Truth table33%1/3
A || B
A= $req->{'sessionInfo'}{'_session_id'}B= $req->id
| |||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||
| 505 | # Delete linked CAS sessions | ||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 14 | ▶ | $self->deleteCasSecondarySessions($session_id) if ($session_id); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 14 | $self->_send_back_channel_LogoutRequests( $req, $req->sessionInfo ); | |||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 14 | return PE_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||
| 513 | # Direct request from SP to IdP | ||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | sub validate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 517 | 'URL ' . $req->uri . ' detected as an CAS VALIDATE URL' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | return $self->_validate_generic( | |||||||||||||||||||||||||||||||||||||||||||||
| 520 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 521 | ticket => scalar( $req->param('ticket') ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 522 | service => scalar( $req->param('service') ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 523 | renew => scalar( $req->param('renew') ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 524 | success => 'returnCasValidateSuccess', | ||||||||||||||||||||||||||||||||||||||||||||||
| 525 | failure => '_failValidate1', | ||||||||||||||||||||||||||||||||||||||||||||||
| 526 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | sub proxy { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
proxy: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 533 | 'URL ' . $req->uri . " detected as an CAS PROXY URL" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||
| 535 | # GET parameters | ||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | my $pgt = $req->param('pgt'); | |||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my $targetService = $req->param('targetService'); | |||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||
| 539 | # Required parameters: pgt and targetService | ||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | unless ( $pgt and $targetService ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pgt and $targetService
MC/DC0%0/2
$pgt and $targetService
$pgt
$targetService
Truth table0%0/3
A and B
A= $pgtB= $targetService
| |||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $self->logger->error("Pgt and TargetService parameters required"); | |||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | $self->returnCasProxyError( $req, 'INVALID_REQUEST', | |||||||||||||||||||||||||||||||||||||||||||||
| 543 | 'Missing mandatory parameters (pgt, targetService)' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||
| 546 | $self->logger->debug( | ||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | "Get proxy request with ticket $pgt for service $targetService"); | |||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||
| 549 | # Get CAS session corresponding to ticket | ||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | unless ( $pgt =~ s/^PGT-// ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | $self->logger->error( | |||||||||||||||||||||||||||||||||||||||||||||
| 552 | "Provided ticket is not a proxy granting ticket (PGT)"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | $self->returnCasProxyError( $req, 'BAD_PGT', | |||||||||||||||||||||||||||||||||||||||||||||
| 554 | 'Provided ticket is not a proxy granting ticket' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | my $casProxyGrantingSession = $self->getCasSession($pgt); | |||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | unless ($casProxyGrantingSession) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | $self->logger->warn("Proxy granting ticket session $pgt not found"); | |||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | $self->returnCasProxyError( $req, 'BAD_PGT', 'Ticket not found' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | $self->logger->debug("Proxy granting session $pgt found"); | |||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||
| 566 | # Create a proxy ticket | ||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 568 | "Create a CAS proxy ticket for service $targetService"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my $casProxySession = $self->getCasSession(); | |||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | ▶ | unless ($casProxySession) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | $self->logger->error("Unable to create CAS proxy session"); | |||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | $self->returnCasProxyError( $req, 'INTERNAL_ERROR', | |||||||||||||||||||||||||||||||||||||||||||||
| 575 | 'Error in proxy session management' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||
| 578 | my $_utime = | ||||||||||||||||||||||||||||||||||||||||||||||
| 579 | $self->conf->{casTicketExpiration} | ||||||||||||||||||||||||||||||||||||||||||||||
| 580 | ? ( time + $self->conf->{casTicketExpiration} - $self->conf->{timeout} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | : $casProxyGrantingSession->data->{_utime}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my $Pinfos; | |||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | $Pinfos->{type} = 'casProxy'; | |||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $Pinfos->{service} = $targetService; | |||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $Pinfos->{_cas_id} = $casProxyGrantingSession->data->{_cas_id}; | |||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $Pinfos->{_utime} = $_utime; | |||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | $Pinfos->{proxies} = $casProxyGrantingSession->data->{proxies}; | |||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | $casProxySession->update($Pinfos); | |||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | my $casProxySessionID = $casProxySession->id; | |||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my $casProxyTicket = "PT-" . $casProxySessionID; | |||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | $self->logger->debug("CAS proxy session $casProxySessionID created"); | |||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | return $self->returnCasProxySuccess( $req, $casProxyTicket ); | |||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 8 | ▶ | sub serviceValidate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serviceValidate: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 8 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 8 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 604 | 'URL ' . $req->uri . " detected as an CAS SERVICE VALIDATE URL" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 8 | return $self->_validate_generic( | |||||||||||||||||||||||||||||||||||||||||||||
| 607 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 608 | service => scalar( $req->param('service') ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 609 | ticket => scalar( $req->param('ticket') ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 610 | pgtUrl => scalar( $req->param('pgtUrl') ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 611 | renew => scalar( $req->param('renew') ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 612 | success => 'returnCasServiceValidateSuccess', | ||||||||||||||||||||||||||||||||||||||||||||||
| 613 | failure => '_failValidate2', | ||||||||||||||||||||||||||||||||||||||||||||||
| 614 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | sub samlValidate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
samlValidate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my $service = $req->query_parameters->{TARGET}; | |||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | my $ticket = $self->getServiceTicketFromSamlRequest( $req->content ); | |||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | return $self->_validate_generic( | |||||||||||||||||||||||||||||||||||||||||||||
| 624 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 625 | service => $service, | ||||||||||||||||||||||||||||||||||||||||||||||
| 626 | ticket => $ticket, | ||||||||||||||||||||||||||||||||||||||||||||||
| 627 | success => 'returnSamlValidateSuccess', | ||||||||||||||||||||||||||||||||||||||||||||||
| 628 | failure => '_failValidateSaml', | ||||||||||||||||||||||||||||||||||||||||||||||
| 629 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | sub proxyValidate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
proxyValidate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 636 | 'URL ' . $req->uri . " detected as an CAS PROXY VALIDATE URL" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | return $self->_validate_generic( | |||||||||||||||||||||||||||||||||||||||||||||
| 639 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 640 | ticketType => "PROXY", | ||||||||||||||||||||||||||||||||||||||||||||||
| 641 | service => scalar( $req->param('service') ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 642 | ticket => scalar( $req->param('ticket') ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 643 | pgtUrl => scalar( $req->param('pgtUrl') ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 644 | renew => scalar( $req->param('renew') ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 645 | success => 'returnCasServiceValidateSuccess', | ||||||||||||||||||||||||||||||||||||||||||||||
| 646 | failure => '_failValidate2', | ||||||||||||||||||||||||||||||||||||||||||||||
| 647 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||
| 650 | # INTERNAL METHODS | ||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 8 | ▶ | sub _validate_generic { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_generic: called CC=42 SCAR=60.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 8 | my ( $self, $req, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 8 | my $service = $params{service}; | |||||||||||||||||||||||||||||||||||||||||||||
| 656 | 8 | my $ticket = $params{ticket}; | |||||||||||||||||||||||||||||||||||||||||||||
| 657 | 8 | ▶ | my $renew = $params{renew} // "false"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$params{"renew"} // "false"
MC/DC0%0/1
$params{"renew"} // "false"
$params{"renew"}
Truth table50%1/2
A
A= $params{"renew"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 8 | my $success = $params{success}; | |||||||||||||||||||||||||||||||||||||||||||||
| 659 | 8 | my $failure = $params{failure}; | |||||||||||||||||||||||||||||||||||||||||||||
| 660 | 8 | my $pgtUrl = $params{pgtUrl}; | |||||||||||||||||||||||||||||||||||||||||||||
| 661 | 8 | ▶ | my $urlType = $params{ticketType} // "SERVICE"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$params{"ticketType"} // "SERVICE"
MC/DC0%0/1
$params{"ticketType"} // "SERVICE"
$params{"ticketType"}
Truth table50%1/2
A
A= $params{"ticketType"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||
| 663 | # PGTIOU | ||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 8 | my $casProxyGrantingTicketIOU; | |||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||
| 666 | # Required parameters: service and ticket | ||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 8 | ▶ | unless ( $service and $ticket ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$service and $ticket
MC/DC0%0/2
$service and $ticket
$service
$ticket
Truth table33%1/3
A and B
A= $serviceB= $ticket
| |||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | $self->logger->error("Service and Ticket parameters required"); | |||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | return $self->$failure( | |||||||||||||||||||||||||||||||||||||||||||||
| 670 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 671 | code => 'INVALID_REQUEST', | ||||||||||||||||||||||||||||||||||||||||||||||
| 672 | msg => 'Missing mandatory parameters (service, ticket)' | ||||||||||||||||||||||||||||||||||||||||||||||
| 673 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 8 | $self->logger->debug( "Get " | |||||||||||||||||||||||||||||||||||||||||||||
| 677 | . lc($urlType) | ||||||||||||||||||||||||||||||||||||||||||||||
| 678 | . " validate request with ticket $ticket for service $service" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||
| 680 | # Get CAS session corresponding to ticket | ||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 8 | ▶ | if ( $urlType eq 'SERVICE' and !( $ticket =~ s/^ST-// ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$urlType eq "SERVICE" and not $ticket =~ s/^ST-//
MC/DC0%0/2
$urlType eq "SERVICE" and not $ticket =~ s/^ST-//
$urlType eq "SERVICE"
not $ticket =~ s/^ST-//
Truth table33%1/3
A and not(B)
A= $urlType eq "SERVICE"B= not $ticket =~ s/^ST-//
| |||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | $self->logger->error("Provided ticket is not a service ticket (ST)"); | |||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | return $self->$failure( | |||||||||||||||||||||||||||||||||||||||||||||
| 684 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 685 | code => 'INVALID_TICKET', | ||||||||||||||||||||||||||||||||||||||||||||||
| 686 | msg => 'Provided ticket is not a service ticket' | ||||||||||||||||||||||||||||||||||||||||||||||
| 687 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 688 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 689 | ▶ | elsif ( $urlType eq 'PROXY' and !( $ticket =~ s/^(P|S)T-// ) ) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$urlType eq "PROXY" and not $ticket =~ s/^(P|S)T-//
MC/DC0%0/2
$urlType eq "PROXY" and not $ticket =~ s/^(P|S)T-//
$urlType eq "PROXY"
not $ticket =~ s/^(P|S)T-//
Truth table33%1/3
A and not(B)
A= $urlType eq "PROXY"B= not $ticket =~ s/^(P|S)T-//
| |||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | $self->userLogger->error( | |||||||||||||||||||||||||||||||||||||||||||||
| 691 | "Provided ticket is not a service or proxy ticket ($1T)"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | return $self->$failure( | |||||||||||||||||||||||||||||||||||||||||||||
| 693 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 694 | code => 'INVALID_TICKET', | ||||||||||||||||||||||||||||||||||||||||||||||
| 695 | msg => 'Provided ticket is not a service or proxy ticket' | ||||||||||||||||||||||||||||||||||||||||||||||
| 696 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 8 | my $casServiceSession = $self->getCasSession($ticket); | |||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 8 | ▶ | unless ($casServiceSession) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | $self->logger->warn("$urlType ticket session $ticket not found"); | |||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | return $self->$failure( | |||||||||||||||||||||||||||||||||||||||||||||
| 704 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 705 | code => 'INVALID_TICKET', | ||||||||||||||||||||||||||||||||||||||||||||||
| 706 | msg => 'Ticket not found' | ||||||||||||||||||||||||||||||||||||||||||||||
| 707 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 8 | $self->deleteCasSession($casServiceSession); | |||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||
| 711 | # Make sure the token is still valid, we already compensated for | ||||||||||||||||||||||||||||||||||||||||||||||
| 712 | # different TTLs when storing _utime | ||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 8 | ▶ | if ( $casServiceSession->{data}->{_utime} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 8 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 715 | time > | ||||||||||||||||||||||||||||||||||||||||||||||
| 716 | ( $casServiceSession->{data}->{_utime} + $self->conf->{timeout} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 717 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | $self->logger->info("$urlType ticket session $ticket has expired"); | |||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | return $self->$failure( | |||||||||||||||||||||||||||||||||||||||||||||
| 720 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 721 | code => 'INVALID_TICKET', | ||||||||||||||||||||||||||||||||||||||||||||||
| 722 | msg => 'Ticket expired' | ||||||||||||||||||||||||||||||||||||||||||||||
| 723 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 8 | my $app = $casServiceSession->data->{_casApp}; | |||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 8 | $self->logger->debug("$urlType ticket session $ticket found"); | |||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 8 | my $service1_uri = URI->new($service); | |||||||||||||||||||||||||||||||||||||||||||||
| 732 | 8 | my $service2_uri = URI->new( $casServiceSession->data->{service} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||
| 734 | # Check service | ||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 8 | ▶ | unless ( $service1_uri->eq($service2_uri) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||
| 737 | # Tolerate that relative URI are the same | ||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | ▶ | if ( $service1_uri->rel($service2_uri) eq "./" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$service1_uri->rel($service2_uri) eq "./" or $service2_uri->rel($service1_uri) eq "./"
MC/DC0%0/2
$service1_uri->rel($service2_uri) eq "./" or $service2_uri->rel($service1_uri) eq "./"
$service1_uri->rel($service2_uri) eq "./"
$service2_uri->rel($service1_uri) eq "./"
Truth table0%0/3
A or B
A= $service1_uri->rel($service2_uri) eq "./"B= $service2_uri->rel($service1_uri) eq "./"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 739 | or $service2_uri->rel($service1_uri) eq "./" ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 740 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | $self->logger->notice( "Submitted service $service1_uri" | |||||||||||||||||||||||||||||||||||||||||||||
| 742 | . " does not exactly match initial service " | ||||||||||||||||||||||||||||||||||||||||||||||
| 743 | . $service2_uri | ||||||||||||||||||||||||||||||||||||||||||||||
| 744 | . ' but difference is tolerated.' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 746 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 747 | $self->userLogger->error( | ||||||||||||||||||||||||||||||||||||||||||||||
| 748 | "Submitted service $service does not match initial service " | ||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | . $casServiceSession->data->{service} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | $self->deleteCasSession($casServiceSession); | |||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | return $self->_failValidate2( | |||||||||||||||||||||||||||||||||||||||||||||
| 752 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 753 | app => $app, | ||||||||||||||||||||||||||||||||||||||||||||||
| 754 | code => 'INVALID_SERVICE', | ||||||||||||||||||||||||||||||||||||||||||||||
| 755 | msg => 'Submitted service does not match initial service' | ||||||||||||||||||||||||||||||||||||||||||||||
| 756 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 759 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 8 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 761 | "Submitted service $service match initial service"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||
| 764 | # Check renew | ||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 8 | ▶ | if ( $renew and $renew eq 'true' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$renew and $renew eq "true"
MC/DC0%0/2
$renew and $renew eq "true"
$renew
$renew eq "true"
Truth table33%1/3
A and B
A= $renewB= $renew eq "true"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||
| 767 | # We should check the ST was delivered with primary credentials | ||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | $self->logger->debug("Renew flag detected "); | |||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | ▶ | unless ( $casServiceSession->data->{renew} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | $self->logger->error( "Authentication renew requested," | |||||||||||||||||||||||||||||||||||||||||||||
| 772 | . " but not done in former authentication process" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | return $self->$failure( | |||||||||||||||||||||||||||||||||||||||||||||
| 774 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 775 | app => $app, | ||||||||||||||||||||||||||||||||||||||||||||||
| 776 | code => 'INVALID_TICKET', | ||||||||||||||||||||||||||||||||||||||||||||||
| 777 | msg => 'Authentication renew requested,' | ||||||||||||||||||||||||||||||||||||||||||||||
| 778 | . ' but not done in former authentication process' | ||||||||||||||||||||||||||||||||||||||||||||||
| 779 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||
| 784 | # Proxies (for PROXY VALIDATE only) | ||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 8 | my $proxies = $casServiceSession->data->{proxies}; | |||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||
| 787 | # Proxy granting ticket | ||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 8 | ▶ | if ($pgtUrl) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | my $allow_proxy = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | ▶ | if ($app) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 792 | $allow_proxy = | ||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | ▶ | $self->casAppList->{$app}->{casAppMetaDataOptionsAllowProxy} // 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->casAppList->{$app}{"casAppMetaDataOptionsAllowProxy"} // 1
MC/DC0%0/1
$self->casAppList->{$app}{"casAppMetaDataOptionsAllowProxy"} // 1
$self->casAppList->{$app}{"casAppMetaDataOptionsAllowProxy"}
Truth table0%0/2
A
A= $self->casAppList->{$app}{"casAppMetaDataOptionsAllowProxy"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | ▶ | if ( !$allow_proxy ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | return $self->$failure( | |||||||||||||||||||||||||||||||||||||||||||||
| 797 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 798 | app => $app, | ||||||||||||||||||||||||||||||||||||||||||||||
| 799 | code => 'UNAUTHORIZED_SERVICE_PROXY', | ||||||||||||||||||||||||||||||||||||||||||||||
| 800 | msg => 'CAS proxy is not allowed' | ||||||||||||||||||||||||||||||||||||||||||||||
| 801 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||
| 804 | # Create a proxy granting ticket | ||||||||||||||||||||||||||||||||||||||||||||||
| 805 | $self->logger->debug( | ||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | "Create a CAS proxy granting ticket for service $service"); | |||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | my $PGinfos; | |||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||
| 810 | # PGT session | ||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | $PGinfos->{type} = 'casProxyGranting'; | |||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | $PGinfos->{service} = $service; | |||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | $PGinfos->{_cas_id} = $casServiceSession->data->{_cas_id}; | |||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | $PGinfos->{_utime} = time; | |||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | $PGinfos->{_casApp} = $app; | |||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||
| 817 | # Trace proxies | ||||||||||||||||||||||||||||||||||||||||||||||
| 818 | $PGinfos->{proxies} = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 819 | $proxies | ||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | ▶ | ? $proxies . $self->conf->{multiValuesSeparator} . $pgtUrl | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 821 | : $pgtUrl | ||||||||||||||||||||||||||||||||||||||||||||||
| 822 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | my $casProxyGrantingSession = $self->getCasSession( undef, $PGinfos ); | |||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | ▶ | if ($casProxyGrantingSession) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | my $casProxyGrantingSessionID = $casProxyGrantingSession->id; | |||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | my $casProxyGrantingTicket = "PGT-" . $casProxyGrantingSessionID; | |||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 832 | "CAS proxy granting session $casProxyGrantingSessionID created" | ||||||||||||||||||||||||||||||||||||||||||||||
| 833 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||
| 835 | # Generate the proxy granting ticket IOU | ||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | my $tmpCasSession = $self->getCasSession(); | |||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | ▶ | if ($tmpCasSession) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | $casProxyGrantingTicketIOU = "PGTIOU-" . $tmpCasSession->id; | |||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | $self->deleteCasSession($tmpCasSession); | |||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | $self->logger->debug( "Generate proxy granting ticket IOU" | |||||||||||||||||||||||||||||||||||||||||||||
| 843 | . $casProxyGrantingTicketIOU ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||
| 845 | # Request pgtUrl | ||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 847 | $self->callPgtUrl( | ||||||||||||||||||||||||||||||||||||||||||||||
| 848 | $pgtUrl, $casProxyGrantingTicketIOU, | ||||||||||||||||||||||||||||||||||||||||||||||
| 849 | $casProxyGrantingTicket | ||||||||||||||||||||||||||||||||||||||||||||||
| 850 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 851 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 852 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 854 | "Proxy granting URL $pgtUrl called with success"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 856 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | $self->logger->error( | |||||||||||||||||||||||||||||||||||||||||||||
| 858 | "Error calling proxy granting URL $pgtUrl"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | $casProxyGrantingTicketIOU = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 864 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | $self->logger->warn( | |||||||||||||||||||||||||||||||||||||||||||||
| 866 | "Error in proxy granting ticket management, bypass it"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||
| 870 | # Open local session | ||||||||||||||||||||||||||||||||||||||||||||||
| 871 | my $localSession = | ||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 8 | $self->p->getApacheSession( $casServiceSession->data->{_cas_id} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 8 | ▶ | unless ($localSession) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 875 | $self->userLogger->warn( "Local session " | ||||||||||||||||||||||||||||||||||||||||||||||
| 876 | . $casServiceSession->data->{_cas_id} | ||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | . " notfound" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | return $self->$failure( | |||||||||||||||||||||||||||||||||||||||||||||
| 879 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 880 | app => $app, | ||||||||||||||||||||||||||||||||||||||||||||||
| 881 | code => 'INTERNAL_ERROR', | ||||||||||||||||||||||||||||||||||||||||||||||
| 882 | msg => 'No session associated to ticket' | ||||||||||||||||||||||||||||||||||||||||||||||
| 883 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||
| 886 | # Get username | ||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 8 | my $username = $self->getUsernameForApp( $req, $app, $localSession->data ); | |||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||
| 889 | # Useful for logging | ||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 8 | $req->sessionInfo( $localSession->data ); | |||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 8 | $self->logger->debug("Get username $username"); | |||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||
| 894 | # Get attributes [CAS 3.0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 8 | my $attributes = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 896 | my $ev = | ||||||||||||||||||||||||||||||||||||||||||||||
| 897 | ( $app and $self->conf->{casAppMetaDataExportedVars}->{$app} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 8 | ▶ | ? $self->conf->{casAppMetaDataExportedVars}->{$app} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$app and $self->conf->{"casAppMetaDataExportedVars"}{$app}
MC/DC0%0/2
$app and $self->conf->{"casAppMetaDataExportedVars"}{$app}
$app
$self->conf->{"casAppMetaDataExportedVars"}{$app}
Truth table33%1/3
A and B
A= $appB= $self->conf->{"casAppMetaDataExportedVars"}{$app}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 899 | : {}; | ||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 8 | ▶ | unless (%$ev) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 8 | ▶ | $ev = $self->conf->{casAttributes} || {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->conf->{'casAttributes'} || {}
MC/DC0%0/1
$self->conf->{'casAttributes'} || {}
$self->conf->{'casAttributes'}
Truth table50%1/2
A
A= $self->conf->{'casAttributes'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 8 | foreach my $casAttribute ( keys %$ev ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | my $sessionAttr = $ev->{$casAttribute}; | |||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | my $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||
| 908 | # Lookup per-service macros first, and then local sessions | ||||||||||||||||||||||||||||||||||||||||||||||
| 909 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | ▶ | if ( $app and $self->spMacros->{$app}->{$sessionAttr} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$app and $self->spMacros->{$app}{$sessionAttr}
MC/DC0%0/2
$app and $self->spMacros->{$app}{$sessionAttr}
$app
$self->spMacros->{$app}{$sessionAttr}
Truth table0%0/3
A and B
A= $appB= $self->spMacros->{$app}{$sessionAttr}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | $value = $self->spMacros->{$app}->{$sessionAttr} | |||||||||||||||||||||||||||||||||||||||||||||
| 912 | ->( $req, $localSession->data ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 913 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 914 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | $value = $localSession->data->{$sessionAttr}; | |||||||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | ▶ | $attributes->{$casAttribute} = $value | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 919 | if defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||||||
| 922 | # Return success message | ||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 8 | ▶ | if ( $self->isLogoutEnabled($app) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 4 | $self->_save_ticket_for_single_logout( $localSession, $service, | |||||||||||||||||||||||||||||||||||||||||||||
| 925 | $req->param('ticket') ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 8 | ▶ | $self->p->registerProtectedAppAccess( $req, $username, "cas:$app" ) if $app; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 8 | my $h = | |||||||||||||||||||||||||||||||||||||||||||||
| 931 | $self->p->processHook( $req, 'casGenerateValidateResponse', $username, | ||||||||||||||||||||||||||||||||||||||||||||||
| 932 | $attributes ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 8 | ▶ | return $self->$failure( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 934 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 935 | app => $app, | ||||||||||||||||||||||||||||||||||||||||||||||
| 936 | code => "INTERNAL_ERROR", | ||||||||||||||||||||||||||||||||||||||||||||||
| 937 | msg => "Internal error during request validation", | ||||||||||||||||||||||||||||||||||||||||||||||
| 938 | res => $h, | ||||||||||||||||||||||||||||||||||||||||||||||
| 939 | ) if ( $h != PE_OK ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 8 | my $user = $req->sessionInfo->{ $self->conf->{whatToTrace} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 942 | 8 | ▶ | my $by_app = $app ? " by $app" : ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 8 | ▶ | my $attr_str = | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $attributes and keys %$attributes
MC/DC0%0/2
defined $attributes and keys %$attributes
defined $attributes
keys %$attributes
Truth table33%1/3
A and B
A= defined $attributesB= keys %$attributes
| |||||||||||||||||||||||||||||||||||||||||||||||
| 944 | ( defined($attributes) && keys %$attributes ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 945 | ? ( " with attributes " . join( ',', sort( keys(%$attributes) ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 946 | : ""; | ||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 8 | ▶ | $self->auditLog( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 948 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 949 | code => "ISSUER_CAS_VALIDATE_SUCCESS", | ||||||||||||||||||||||||||||||||||||||||||||||
| 950 | message => ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 951 | "CAS validation succeeded for ${user}${by_app}" | ||||||||||||||||||||||||||||||||||||||||||||||
| 952 | . " as ${username}${attr_str}" | ||||||||||||||||||||||||||||||||||||||||||||||
| 953 | ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 954 | ( $app ? ( app => $app ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 955 | user => $user, | ||||||||||||||||||||||||||||||||||||||||||||||
| 956 | cas_user => $username, | ||||||||||||||||||||||||||||||||||||||||||||||
| 957 | cas_proxies => $proxies, | ||||||||||||||||||||||||||||||||||||||||||||||
| 958 | attributes => $attributes, | ||||||||||||||||||||||||||||||||||||||||||||||
| 959 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 8 | return $self->$success( $req, $username, | |||||||||||||||||||||||||||||||||||||||||||||
| 961 | $casProxyGrantingTicketIOU, $proxies, $attributes ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||
| 964 | # Returns the main attribute (sub) to use for this App | ||||||||||||||||||||||||||||||||||||||||||||||
| 965 | # It can be a session attribute, or per-App macro | ||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 8 | ▶ | sub getUsernameForApp { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getUsernameForApp: called CC=6 SCAR=22.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 8 | my ( $self, $req, $app, $data ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||
| 969 | my $username_attribute = | ||||||||||||||||||||||||||||||||||||||||||||||
| 970 | ( $app | ||||||||||||||||||||||||||||||||||||||||||||||
| 971 | and $self->casAppList->{$app}->{casAppMetaDataOptionsUserAttribute} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 972 | ? $self->casAppList->{$app}->{casAppMetaDataOptionsUserAttribute} | ||||||||||||||||||||||||||||||||||||||||||||||
| 973 | : ( $self->conf->{casAttr} | ||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 8 | ▶ | || $self->conf->{whatToTrace} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$app and $self->casAppList->{$app}{"casAppMetaDataOptionsUserAttribute"}
$self->conf->{"casAttr"} or $self->conf->{"whatToTrace"}
MC/DC0%0/2
$app and $self->casAppList->{$app}{"casAppMetaDataOptionsUserAttribute"}
$app
$self->casAppList->{$app}{"casAppMetaDataOptionsUserAttribute"}
MC/DC0%0/2
$self->conf->{"casAttr"} or $self->conf->{"whatToTrace"}
$self->conf->{"casAttr"}
$self->conf->{"whatToTrace"}
Truth table33%1/3
A and B
A= $appB= $self->casAppList->{$app}{"casAppMetaDataOptionsUserAttribute"}
Truth table33%1/3
A or B
A= $self->conf->{"casAttr"}B= $self->conf->{"whatToTrace"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 8 | my $username; | |||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||
| 978 | # If the main attribute is a SP macro, resolve it | ||||||||||||||||||||||||||||||||||||||||||||||
| 979 | # else, get it directly from session data | ||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 8 | ▶ | if ( $app and $self->spMacros->{$app}->{$username_attribute} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$app and $self->spMacros->{$app}{$username_attribute}
MC/DC0%0/2
$app and $self->spMacros->{$app}{$username_attribute}
$app
$self->spMacros->{$app}{$username_attribute}
Truth table33%1/3
A and B
A= $appB= $self->spMacros->{$app}{$username_attribute}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 981 | $username = | ||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | $self->spMacros->{$app}->{$username_attribute}->( $req, $data ); | |||||||||||||||||||||||||||||||||||||||||||||
| 983 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 984 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 8 | $username = $data->{$username_attribute}; | |||||||||||||||||||||||||||||||||||||||||||||
| 986 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 8 | return $username; | |||||||||||||||||||||||||||||||||||||||||||||
| 988 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 4 | ▶ | sub _save_ticket_for_single_logout { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_save_ticket_for_single_logout: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 4 | my ( $self, $localSession, $service, $ticket ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 4 | $self->logger->debug("Saving service $service ticket $ticket for SLO"); | |||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 4 | ▶ | my $service2ticket = $localSession->data->{cas_tickets_for_SLO} || {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$localSession->data->{'cas_tickets_for_SLO'} || {}
MC/DC0%0/1
$localSession->data->{'cas_tickets_for_SLO'} || {}
$localSession->data->{'cas_tickets_for_SLO'}
Truth table50%1/2
A
A= $localSession->data->{'cas_tickets_for_SLO'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 4 | $service2ticket->{$service} = $ticket; | |||||||||||||||||||||||||||||||||||||||||||||
| 997 | 4 | $localSession->update( { cas_tickets_for_SLO => $service2ticket } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 998 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 14 | ▶ | sub _send_back_channel_LogoutRequests { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_send_back_channel_LogoutRequests: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 14 | my ( $self, $req, $sessionData ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 14 | ▶ | my $service2ticket = $sessionData->{cas_tickets_for_SLO} or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 4 | my $content; | |||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 4 | foreach my $service ( keys %$service2ticket ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | # Create a new relay session | ||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | my $relayInfos = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | service => $service, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 4 | ticket => $service2ticket->{$service}, | |||||||||||||||||||||||||||||||||||||||||||||
| 1012 | _type => "relay" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 4 | my $relaySession = $self->getCasSession( undef, $relayInfos ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 4 | my $relayid = $relaySession->id; | |||||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | # Build the URL that could be used to play this logout request | ||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 4 | my $slo_url = | |||||||||||||||||||||||||||||||||||||||||||||
| 1019 | $self->p->buildUrl( $req->portal, "cas", "relayLogout", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | { relay => $relayid } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 4 | my $name = $self->getNameFromService($service); | |||||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | # Display information to the user | ||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 4 | $content .= $self->loadTemplate( | |||||||||||||||||||||||||||||||||||||||||||||
| 1026 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 'samlSpSoapLogout', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | params => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | imgUrl => $slo_url, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | # Build Relay URL and display it | ||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | $req->info( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 4 | ▶ | $self->loadTemplate( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | $req, 'samlSpsLogout', params => { content => $content } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | ) if $content; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 4 | ▶ | sub getNameFromService { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getNameFromService: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 4 | my ( $self, $service ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 4 | my $app = $self->getCasApp($service); | |||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 4 | ▶ | if ( $self->casAppList->{$app}->{casAppMetaDataOptionsDisplayName} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 4 | return $self->casAppList->{$app}->{casAppMetaDataOptionsDisplayName}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1049 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | return $app; | |||||||||||||||||||||||||||||||||||||||||||||
| 1051 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 4 | ▶ | sub relayLogout { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
relayLogout: called CC=5 SCAR=19.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 4 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 4 | my $relay = $req->param("relay"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 4 | ▶ | unless ($relay) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | $self->logger->error("Missing relay parameter"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | return $self->p->imgnok($req); | |||||||||||||||||||||||||||||||||||||||||||||
| 1060 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 4 | my $session = $self->getCasSession($relay); | |||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 4 | ▶ | unless ($session) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | $self->logger->warn("CAS session $relay not found"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | return $self->p->imgnok($req); | |||||||||||||||||||||||||||||||||||||||||||||
| 1066 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 4 | ▶ | unless ( $session->data->{_type} eq "relay" ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | $self->logger->error( "CAS session $relay has incorrect type " | ||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | . $session->data->{_type} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | return $self->p->imgnok($req); | |||||||||||||||||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 4 | my $service = $session->data->{service}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 4 | my $ticket = $session->data->{ticket}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 4 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 1077 | "Sending back-channel LogoutRequest to $service (ticket $ticket)"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 4 | my $logoutRequest = $self->buildLogoutRequest($ticket); | |||||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 4 | $self->logger->debug("Sending back-channel LogoutRequest to $service"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 4 | my $response = $self->ua->post( | |||||||||||||||||||||||||||||||||||||||||||||
| 1083 | $service, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | { logoutRequest => $logoutRequest }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | "Content-Type" => 'application/x-www-form-urlencoded' | ||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 4 | ▶ | if ( $response->is_success ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 4 | $self->logger->debug("CAS back-channel logout to $service OK"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 4 | return $self->p->imgok($req); | |||||||||||||||||||||||||||||||||||||||||||||
| 1091 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | $self->logger->error( "CAS back-channel logout to $service error: " | |||||||||||||||||||||||||||||||||||||||||||||
| 1094 | . $response->message ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | $self->logger->debug( $response->dump ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | return $self->p->imgnok($req); | |||||||||||||||||||||||||||||||||||||||||||||
| 1097 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 8 | ▶ | sub isLogoutEnabled { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isLogoutEnabled: called CC=5 SCAR=16.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 8 | my ( $self, $app ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 8 | my $option = -1; | |||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 8 | ▶ | if ($app) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | $option = $self->casAppList->{$app}->{casAppMetaDataOptionsLogout} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 8 | ▶ | // -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->casAppList->{$app}{"casAppMetaDataOptionsLogout"} // -1
MC/DC0%0/1
$self->casAppList->{$app}{"casAppMetaDataOptionsLogout"} // -1
$self->casAppList->{$app}{"casAppMetaDataOptionsLogout"}
Truth table50%1/2
A
A= $self->casAppList->{$app}{"casAppMetaDataOptionsLogout"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 8 | ▶ | if ( $option == -1 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 4 | ▶ | return $self->conf->{casBackChannelSingleLogout} || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->conf->{'casBackChannelSingleLogout'} || 0
MC/DC0%0/1
$self->conf->{'casBackChannelSingleLogout'} || 0
$self->conf->{'casBackChannelSingleLogout'}
Truth table50%1/2
A
A= $self->conf->{'casBackChannelSingleLogout'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 4 | return $option; | |||||||||||||||||||||||||||||||||||||||||||||
| 1114 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | ▶ | sub _failValidate1 { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_failValidate1: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 0 | my ( $self, $req, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 0 | ▶ | my $reason = $params{'msg'} ? ": $params{'msg'}" : ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | ▶ | my $res = $params{res} || PE_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$params{'res'} || 24
MC/DC0%0/1
$params{'res'} || 24
$params{'res'}
Truth table0%0/2
A
A= $params{'res'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | my $app = $params{app}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | $self->auditLog( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | code => "ISSUER_CAS_VALIDATE_FAILED", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | message => ( "CAS validation failed" . $reason ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | ( $reason ? ( reason => $reason ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | ( $app ? ( app => $app ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | portal_error => portalConsts->{$res}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | user => $req->sessionInfo->{ $self->conf->{whatToTrace} }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | return $self->returnCasValidateError($req); | |||||||||||||||||||||||||||||||||||||||||||||
| 1134 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 0 | ▶ | sub _failValidate2 { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_failValidate2: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 0 | my ( $self, $req, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 0 | ▶ | my $message = $params{'msg'} ? ": $params{'msg'}" : ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | my $reason = $params{'msg'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | ▶ | my $code = $params{'code'} || 'INTERNAL_ERROR'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$params{'code'} || 'INTERNAL_ERROR'
MC/DC0%0/1
$params{'code'} || 'INTERNAL_ERROR'
$params{'code'}
Truth table0%0/2
A
A= $params{'code'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 0 | ▶ | my $res = $params{res} || PE_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$params{'res'} || 24
MC/DC0%0/1
$params{'res'} || 24
$params{'res'}
Truth table0%0/2
A
A= $params{'res'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 0 | my $app = $params{app}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | $self->auditLog( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | code => "ISSUER_CAS_VALIDATE_FAILED", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | message => ( "CAS validation failed" . $message ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | ( $reason ? ( reason => $reason ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | ( $app ? ( app => $app ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | cas_code => $code, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | portal_error => portalConsts->{$res}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | user => $req->sessionInfo->{ $self->conf->{whatToTrace} }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 0 | return $self->returnCasServiceValidateError( $req, $code, $reason ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1156 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | ▶ | sub _failValidateSaml { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_failValidateSaml: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 0 | my ( $self, $req, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 0 | ▶ | my $message = $params{'msg'} ? ": $params{'msg'}" : ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | my $reason = $params{'msg'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | my $code = $params{'code'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | ▶ | my $res = $params{res} || PE_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$params{'res'} || 24
MC/DC0%0/1
$params{'res'} || 24
$params{'res'}
Truth table0%0/2
A
A= $params{'res'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | my $app = $params{app}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | $self->auditLog( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | code => "ISSUER_CAS_VALIDATE_FAILED", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | message => ( "CAS validation failed" . $message ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | ( $reason ? ( reason => $reason ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | ( $app ? ( app => $app ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | cas_code => $code, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | portal_error => portalConsts->{$res}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | user => $req->sessionInfo->{ $self->conf->{whatToTrace} }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | return $self->returnSamlValidateError( $req, $code, $reason ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1178 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 1 | ▶ | sub _failLogin { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_failLogin: called CC=5 SCAR=17.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 1 | my ( $self, $req, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 1 | ▶ | my $reason = $params{'msg'} ? ": $params{'msg'}" : ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 1 | ▶ | my $res = $params{res} || PE_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$params{'res'} || 24
MC/DC0%0/1
$params{'res'} || 24
$params{'res'}
Truth table50%1/2
A
A= $params{'res'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 1 | my $app = $params{app}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | $self->auditLog( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | code => "ISSUER_CAS_LOGIN_FAILED", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | message => ( "CAS login failed" . $reason ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | ( $reason ? ( reason => $reason ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | ( $app ? ( app => $app ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | portal_error => portalConsts->{$res}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | user => $req->sessionInfo->{ $self->conf->{whatToTrace} }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 1 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 1 | return $res; | |||||||||||||||||||||||||||||||||||||||||||||
| 1197 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | 0 | ▶ | sub _failLoginRule { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_failLoginRule: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | my ( $self, $req, $cas_request, $app ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 0 | my $casAccessControlPolicy = $self->conf->{casAccessControlPolicy}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | my $user = $req->sessionInfo->{ $self->conf->{whatToTrace} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 0 | ▶ | $self->auditLog( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | $req, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | code => "ISSUER_CAS_LOGIN_FAILED", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | ( $app ? ( app => $app ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | message => ("User $user is not authorized to access $app"), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | reason => "User is not authorized by access rule", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | user => $user, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | ▶ | if ( $casAccessControlPolicy =~ /^(error)$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | return PE_UNAUTHORIZEDPARTNER; | |||||||||||||||||||||||||||||||||||||||||||||
| 1215 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | return $self->_redirectUser( $req, $cas_request->{service}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | "ST-F4K3T1CK3T" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1219 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 17 | ▶ | sub _redirectUser { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_redirectUser: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 17 | my ( $self, $req, $destination, $ticket ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | # Redirect to service | ||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | # cas_request may have been modified by hook | ||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 17 | ▶ | if ($ticket) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 10 | ▶ | $destination .= ( $destination =~ /\?/ ? '&' : '?' ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | . build_urlencoded( ticket => $ticket ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 17 | $self->logger->debug("Redirect user to $destination"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 17 | $req->{urldc} = $destination; | |||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 17 | $req->steps( [] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 17 | return PE_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 1237 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 3 | ▶ | sub unauthlogout { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unauthlogout: called CC=7 SCAR=20.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 3 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 3 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||
| 1242 | "URL " . $req->path_info . " detected as an CAS LOGOUT URL" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | # GET parameters | ||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 3 | my $logout_url = $req->param('url'); # CAS 2.0 | |||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 3 | my $logout_service = $req->param('service'); # CAS 3.0 | |||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 3 | ▶ | $logout_service = '' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | if ( $self->p->checkXSSAttackUrldc( 'service', $logout_service ) ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | # If we use access control, check that the service URL is trusted | ||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 3 | ▶ | if ( $self->conf->{casAccessControlPolicy} =~ /^(error|faketicket)$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 3 | ▶ | if ( $logout_service | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$logout_service and not $self->p->isTrustedUrl($logout_service)
MC/DC100%2/2
$logout_service and not $self->p->isTrustedUrl($logout_service)
$logout_service
not $self->p->isTrustedUrl($logout_service)
Truth table100%3/3
A and not(B)
A= $logout_serviceB= not $self->p->isTrustedUrl($logout_service)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | and not $self->p->isTrustedUrl($logout_service) ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 1 | $self->userLogger->error( | |||||||||||||||||||||||||||||||||||||||||||||
| 1256 | "Untrusted service URL $logout_service" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | . "specified for CAS Logout" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 1 | return $self->p->do( $req, [ [ returnPE => PE_UNAUTHORIZEDURL ] ] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1259 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | # Legacy code without logout propagation for CAS 2.0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 2 | ▶ | if ($logout_url) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | # Display a link to the provided URL | ||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 0 | $self->logger->debug("Logout URL $logout_url will be displayed"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1267 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 0 | $req->info( | |||||||||||||||||||||||||||||||||||||||||||||
| 1269 | $self->loadTemplate( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | $req, 'casBack2Url', params => { url => $logout_url } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 0 | $req->data->{activeTimer} = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | delete $req->pdata->{_url}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 0 | return $self->p->do( $req, [ [ returnPE => PE_INFO ] ] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1277 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | elsif ($logout_service) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 1 | $self->_redirectUser( $req, $logout_service ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1280 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 2 | return $self->p->unauthLogout($req); | |||||||||||||||||||||||||||||||||||||||||||||
| 1283 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||