« blib/lib/Lemonldap/NG/Portal/Plugins/OIDC/OfflineTokens.pm
↑ Summary
blib/lib/Lemonldap/NG/Portal/Plugins/AdminLogout.pm »
| 1 | package Lemonldap::NG::Portal::Lib::SOAPProxy; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Mouse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use SOAP::Lite; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Lemonldap::NG::Portal::Main::Constants qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | URIRE | ||||||||||||||||||||||||||||
| 8 | PE_OK | ||||||||||||||||||||||||||||
| 9 | PE_ERROR | ||||||||||||||||||||||||||||
| 10 | PE_BADCREDENTIALS | ||||||||||||||||||||||||||||
| 11 | 1 | ); | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | our $VERSION = '2.0.14'; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # INITIALIZATION | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | has cookieName => ( is => 'rw' ); | |||||||||||||||||||||||||||
| 18 | 1 | has sessionService => ( is => 'rw' ); | |||||||||||||||||||||||||||
| 19 | has urn => ( | ||||||||||||||||||||||||||||
| 20 | is => 'rw', | ||||||||||||||||||||||||||||
| 21 | lazy => 1, | ||||||||||||||||||||||||||||
| 22 | 1 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 1 | $_[0]->conf->{soapProxyUrn}; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | 1 | ); | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 2 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=6 SCAR=23.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 2 | ▶ | unless ( defined $self->conf->{proxyAuthService} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->conf->{"proxyAuthService"} and $self->conf->{"proxyAuthService"} =~ 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/DC0%0/2
defined $self->conf->{"proxyAuthService"} and $self->conf->{"proxyAuthService"} =~ m[(((?^:https?))://((?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?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z0-9\-_.!~*'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)]
Truth table33%1/3
A and B
A= defined $self->conf->{"proxyAuthService"}B= $self->conf->{"proxyAuthService"} =~ 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]))*)))?))?)]
| |||||||||||||||||||||||||||||
| 31 | && $self->conf->{proxyAuthService} =~ URIRE ) | ||||||||||||||||||||||||||||
| 32 | { | ||||||||||||||||||||||||||||
| 33 | 0 | $self->error("Bad or missing proxyAuthService parameter"); | |||||||||||||||||||||||||||
| 34 | 0 | return 0; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | my $sessionService = $self->conf->{proxySessionService} | ||||||||||||||||||||||||||||
| 38 | 2 | ▶ | || $self->conf->{proxyAuthService}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->conf->{'proxySessionService'} || $self->conf->{'proxyAuthService'}
MC/DC0%0/2
$self->conf->{'proxySessionService'} || $self->conf->{'proxyAuthService'}
$self->conf->{'proxySessionService'}
$self->conf->{'proxyAuthService'}
Truth table33%1/3
A || B
A= $self->conf->{'proxySessionService'}B= $self->conf->{'proxyAuthService'}
| |||||||||||||||||||||||||||||
| 39 | 2 | ▶ | unless ( $sessionService =~ URIRE ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | $self->error("Malformed proxySessionService parameter"); | |||||||||||||||||||||||||||
| 41 | 0 | return 0; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 2 | $self->sessionService($sessionService); | |||||||||||||||||||||||||||
| 44 | $self->cookieName( $self->conf->{proxyCookieName} | ||||||||||||||||||||||||||||
| 45 | 2 | ▶ | || $self->conf->{cookieName} ); | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->conf->{'proxyCookieName'} || $self->conf->{'cookieName'}
MC/DC0%0/2
$self->conf->{'proxyCookieName'} || $self->conf->{'cookieName'}
$self->conf->{'proxyCookieName'}
$self->conf->{'cookieName'}
Truth table33%1/3
A || B
A= $self->conf->{'proxyCookieName'}B= $self->conf->{'cookieName'}
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 2 | return 1; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # RUNNING METHODS | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 1 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | 1 | *authenticate = *getUser; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 1 | ▶ | sub getUser { | ||||||||||||||||||||||||||
|
Subroutine
getUser: called CC=5 SCAR=28.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 1 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||
| 57 | 1 | ▶ | return PE_OK if ( $req->data->{_proxyQueryDone} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | $self->logger->debug( | ||||||||||||||||||||||||||||
| 59 | 1 | 'Proxy push auth to ' . $self->conf->{proxyAuthService} ); | |||||||||||||||||||||||||||
| 60 | my $soap = | ||||||||||||||||||||||||||||
| 61 | 1 | SOAP::Lite->proxy( $self->conf->{proxyAuthService} )->uri( $self->urn ); | |||||||||||||||||||||||||||
| 62 | 1 | my $r = $soap->getCookies( $req->{user}, $req->data->{password} ); | |||||||||||||||||||||||||||
| 63 | 0 | ▶ | if ( $r->fault ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | $self->logger->error( "Unable to query authentication service: " | ||||||||||||||||||||||||||||
| 65 | 0 | . $r->fault->{faultstring} ); | |||||||||||||||||||||||||||
| 66 | 0 | return PE_ERROR; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | 0 | $self->logger->debug('Proxy gets a response'); | |||||||||||||||||||||||||||
| 69 | 0 | my $res = $r->result(); | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | # If authentication failed, display error | ||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ( $res->{errorCode} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 0 | $self->userLogger->warn( | |||||||||||||||||||||||||||
| 74 | "Authentication failed for $req->{user}: error $res->{errorCode}"); | ||||||||||||||||||||||||||||
| 75 | 0 | $self->setSecurity($req); | |||||||||||||||||||||||||||
| 76 | 0 | return PE_BADCREDENTIALS; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | 0 | ▶ | unless ( $req->data->{_remoteId} = $res->{cookies}->{ $self->cookieName } ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | { | ||||||||||||||||||||||||||||
| 80 | 0 | $self->logger->error("No cookie named $self->{remoteCookieName}"); | |||||||||||||||||||||||||||
| 81 | 0 | return PE_ERROR; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | 0 | $req->data->{_proxyQueryDone}++; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | return PE_OK; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub findUser { | ||||||||||||||||||||||||||
|
Subroutine
findUser: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | # Nothing to do here | ||||||||||||||||||||||||||||
| 91 | 0 | return PE_OK; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub setSessionInfo { | ||||||||||||||||||||||||||
|
Subroutine
setSessionInfo: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | 0 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||
| 96 | 0 | ▶ | return PE_OK if ( $req->data->{_setSessionInfoDone} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 0 | $self->logger->debug( | |||||||||||||||||||||||||||
| 98 | 'Proxy requests sessionInfo to ' . $self->sessionService . '/global' ); | ||||||||||||||||||||||||||||
| 99 | 0 | my $soap = SOAP::Lite->proxy( $self->sessionService )->uri( $self->urn ); | |||||||||||||||||||||||||||
| 100 | 0 | my $r = $soap->getAttributes( $req->data->{_remoteId} ); | |||||||||||||||||||||||||||
| 101 | $self->logger->error( | ||||||||||||||||||||||||||||
| 102 | "Unable to query session service: " . $r->fault->{faultstring} ) | ||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if ( $r->fault ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | my $res = $r->result(); | |||||||||||||||||||||||||||
| 106 | 0 | ▶ | if ( $res->{error} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 0 | $self->userLogger->warn("Unable to get attributes for $self->{user}"); | |||||||||||||||||||||||||||
| 108 | 0 | return PE_ERROR; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | 0 | foreach ( keys %{ $res->{attributes} } ) { | |||||||||||||||||||||||||||
| 111 | 0 | ▶ | $req->{sessionInfo}->{$_} ||= $res->{attributes}->{$_} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$req->{"sessionInfo"}{$_} ||= $res->{"attributes"}{$_}
MC/DC0%0/2
$req->{"sessionInfo"}{$_} ||= $res->{"attributes"}{$_}
$req->{"sessionInfo"}{$_}
$res->{"attributes"}{$_}
Truth table0%0/3
A ||= B
A= $req->{"sessionInfo"}{$_}B= $res->{"attributes"}{$_}
| |||||||||||||||||||||||||||||
| 112 | unless (/^_/); | ||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | 0 | $req->data->{_setSessionInfoDone}++; | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 0 | return PE_OK; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub authLogout { | ||||||||||||||||||||||||||
|
Subroutine
authLogout: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | # Nothing to do here | ||||||||||||||||||||||||||||
| 122 | 0 | return PE_OK; | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 1 | 1; | |||||||||||||||||||||||||||