« blib/lib/Lemonldap/NG/Portal/Lib/WebAuthn.pm
↑ Summary
blib/lib/Lemonldap/NG/Portal/Lib/OIDCTokenExchange.pm »
| 1 | package Lemonldap::NG::Portal::Issuer::Get; | ||||||||||||||||||||
| 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 URI::Escape; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use Lemonldap::NG::Common::FormEncode; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use Lemonldap::NG::Portal::Main::Constants qw( | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | PE_OK | ||||||||||||||||||||
| 9 | PE_UNAUTHORIZEDURL | ||||||||||||||||||||
| 10 | PE_GET_SERVICE_NOT_ALLOWED URIRE | ||||||||||||||||||||
| 11 | 1 | ); | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 1 | our $VERSION = '2.23.0'; | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 1 | extends 'Lemonldap::NG::Portal::Main::Issuer'; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 1 | has rule => ( is => 'rw' ); | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | # INITIALIZATION | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 0 | ▶ | sub init { | ||||||||||||||||||
|
Subroutine
init: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 22 | 0 | my ($self) = @_; | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | # Parse activation rule | ||||||||||||||||||||
| 25 | 0 | my $hd = $self->p->HANDLER; | |||||||||||||||||||
| 26 | 0 | $self->logger->debug( "GET rule -> " . $self->conf->{issuerDBGetRule} ); | |||||||||||||||||||
| 27 | my $rule = | ||||||||||||||||||||
| 28 | 0 | $hd->buildSub( $hd->substitute( $self->conf->{issuerDBGetRule} ) ); | |||||||||||||||||||
| 29 | 0 | ▶ | unless ($rule) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | 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
| |||||||||||||||||||||
| 31 | 0 | $self->error("Bad GET activation rule -> $error"); | |||||||||||||||||||
| 32 | 0 | return 0; | |||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | 0 | $self->{rule} = $rule; | |||||||||||||||||||
| 35 | 0 | ▶ | return 0 unless $self->SUPER::init(); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | 0 | return 1; | |||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | # RUNNING METHODS | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | ▶ | sub run { | ||||||||||||||||||
|
Subroutine
run: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 42 | 0 | my ( $self, $req ) = @_; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | # Check activation rule | ||||||||||||||||||||
| 45 | 0 | ▶ | unless ( $self->rule->( $req, $req->sessionInfo ) ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 46 | 0 | $self->userLogger->error('GET service not authorized'); | |||||||||||||||||||
| 47 | 0 | return PE_GET_SERVICE_NOT_ALLOWED; | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | # Session ID | ||||||||||||||||||||
| 51 | 0 | ▶ | my $session_id = $req->{sessionInfo}->{_session_id} || $req->id; | ||||||||||||||||||
|
Condition0%0/3
$req->{'sessionInfo'}{'_session_id'} || $req->id
MC/DC0%0/2
$req->{'sessionInfo'}{'_session_id'} || $req->id
$req->{'sessionInfo'}{'_session_id'}
$req->id
Truth table0%0/3
A || B
A= $req->{'sessionInfo'}{'_session_id'}B= $req->id
| |||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | # Session creation timestamp | ||||||||||||||||||||
| 54 | 0 | ▶ | my $time = $req->{sessionInfo}->{_utime} || time(); | ||||||||||||||||||
|
Condition0%0/2
$req->{'sessionInfo'}{'_utime'} || time
MC/DC0%0/1
$req->{'sessionInfo'}{'_utime'} || time
$req->{'sessionInfo'}{'_utime'}
Truth table0%0/2
A
A= $req->{'sessionInfo'}{'_utime'}
| |||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 0 | ▶ | if ( $req->path =~ m#^$self->{conf}->{issuerDBGetPath}/logout# ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | 0 | $self->logger->debug("IssuerGet: request for logout"); | |||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | # TODO | ||||||||||||||||||||
| 60 | # Display a link to the provided URL | ||||||||||||||||||||
| 61 | 0 | return PE_OK; | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | else { | ||||||||||||||||||||
| 64 | 0 | $self->logger->debug("IssuerGet: request for login"); | |||||||||||||||||||
| 65 | 0 | $self->computeGetParams($req); | |||||||||||||||||||
| 66 | 0 | return PE_OK; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | # Nothing to do here for now | ||||||||||||||||||||
| 71 | 0 | ▶ | sub logout { | ||||||||||||||||||
|
Subroutine
logout: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 72 | 0 | return PE_OK; | |||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | # INTERNAL METHODS | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 0 | ▶ | sub computeGetParams { | ||||||||||||||||||
|
Subroutine
computeGetParams: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||
| 78 | 0 | my ( $self, $req ) = @_; | |||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | # Additional GET variables | ||||||||||||||||||||
| 81 | 0 | my %getPrms; | |||||||||||||||||||
| 82 | 0 | ▶ | if ( exists $self->conf->{issuerDBGetParameters} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 83 | 0 | ▶ | unless ( $req->urldc =~ URIRE ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 84 | 0 | $self->logger->error("Malformed url $req->urldc"); | |||||||||||||||||||
| 85 | 0 | return; | |||||||||||||||||||
| 86 | } | ||||||||||||||||||||
| 87 | 0 | ▶ | my $vhost = $3 . ( $4 ? ":$4" : '' ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 88 | 0 | my $prms = $self->conf->{issuerDBGetParameters}->{$vhost}; | |||||||||||||||||||
| 89 | 0 | ▶ | unless ($prms) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 90 | 0 | $self->logger->warn("IssuerGet: $vhost has no configuration"); | |||||||||||||||||||
| 91 | 0 | return ''; | |||||||||||||||||||
| 92 | } | ||||||||||||||||||||
| 93 | 0 | foreach my $param ( keys %$prms ) { | |||||||||||||||||||
| 94 | 0 | my $value = $req->{sessionInfo}->{ $prms->{$param} }; | |||||||||||||||||||
| 95 | 0 | $value =~ s/[\r\n\t]//; | |||||||||||||||||||
| 96 | 0 | $getPrms{$param} = $value; | |||||||||||||||||||
| 97 | } | ||||||||||||||||||||
| 98 | $self->userLogger->notice( 'User ' | ||||||||||||||||||||
| 99 | . $req->sessionInfo->{ $self->conf->{whatToTrace} } | ||||||||||||||||||||
| 100 | 0 | . " is authorized to access $vhost" ); | |||||||||||||||||||
| 101 | } | ||||||||||||||||||||
| 102 | else { | ||||||||||||||||||||
| 103 | 0 | $self->logger->warn("IssuerGet: no configuration"); | |||||||||||||||||||
| 104 | 0 | return; | |||||||||||||||||||
| 105 | } | ||||||||||||||||||||
| 106 | 0 | my $getVars = build_urlencoded(%getPrms); | |||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | # If there are some GET variables to send | ||||||||||||||||||||
| 109 | # Add them to URL string | ||||||||||||||||||||
| 110 | 0 | ▶ | if ( $getVars ne "" ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 111 | 0 | my $urldc = $req->urldc; | |||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | 0 | ▶ | $urldc .= ( $urldc =~ /\?\w/ ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 114 | ? | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | # there are already get variables | ||||||||||||||||||||
| 117 | "&" . $getVars | ||||||||||||||||||||
| 118 | : | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | # there are no get variables | ||||||||||||||||||||
| 121 | "?" . $getVars; | ||||||||||||||||||||
| 122 | 0 | $req->urldc($urldc); | |||||||||||||||||||
| 123 | } | ||||||||||||||||||||
| 124 | } | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | 1 | 1; | |||||||||||||||||||