« blib/lib/Lemonldap/NG/Manager/Api/History.pm
↑ Summary
blib/lib/Lemonldap/NG/Manager/Api/Menu/App.pm »
| 1 | package Lemonldap::NG::Manager::Api::Providers::OidcRp; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 28 | our $VERSION = '2.23.0'; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Lemonldap::NG::Manager::Api; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 28 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 28 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 28 | ▶ | use Mouse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 28 | ▶ | use Lemonldap::NG::Manager::Conf::Parser; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 28 | extends 'Lemonldap::NG::Manager::Api::Common'; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 20 | ▶ | sub getOidcRpByConfKey { | ||||||||||||||||||||||||||
|
Subroutine
getOidcRpByConfKey: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | 20 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 20 | ▶ | my $confKey = $req->params('confKey') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | or return $self->sendError( $req, 'confKey is missing', 400 ); | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 20 | $self->logger->debug("[API] OIDC RP $confKey configuration requested"); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # Get latest configuration | ||||||||||||||||||||||||||||
| 23 | 20 | my $conf = $self->_confAcc->getConf( { noCache => 1 } ); | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 20 | my $oidcRp = $self->_getOidcRpByConfKey( $conf, $confKey ); | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # Return 404 if not found | ||||||||||||||||||||||||||||
| 28 | 20 | ▶ | return $self->sendError( $req, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | "OIDC relying party '$confKey' not found", 404 ) | ||||||||||||||||||||||||||||
| 30 | unless ( defined $oidcRp ); | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 20 | return $self->sendJSONresponse( $req, $oidcRp ); | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 6 | ▶ | sub findOidcRpByConfKey { | ||||||||||||||||||||||||||
|
Subroutine
findOidcRpByConfKey: called CC=6 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | 6 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 6 | ▶ | my $pattern = ( | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 39 | defined $req->params('uPattern') | ||||||||||||||||||||||||||||
| 40 | ? $req->params('uPattern') | ||||||||||||||||||||||||||||
| 41 | : ( defined $req->params('pattern') ? $req->params('pattern') : undef ) | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 6 | ▶ | return $self->sendError( $req, 'Invalid input: pattern is missing', 400 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | unless ( defined $pattern ); | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 6 | ▶ | unless ( $pattern = $self->_getRegexpFromPattern($pattern) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 2 | return $self->sendError( $req, 'Invalid input: pattern is invalid', | |||||||||||||||||||||||||||
| 49 | 400 ); | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | $self->logger->debug( | ||||||||||||||||||||||||||||
| 53 | 4 | "[API] Find OIDC RPs by confKey regexp $pattern requested"); | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # Get latest configuration | ||||||||||||||||||||||||||||
| 56 | 4 | my $conf = $self->_confAcc->getConf( { noCache => 1 } ); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | my @oidcRps = | ||||||||||||||||||||||||||||
| 59 | 8 | ▶ | map { $_ =~ $pattern ? $self->_getOidcRpByConfKey( $conf, $_ ) : () } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 4 | keys %{ $conf->{oidcRPMetaDataOptions} }; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 4 | return $self->sendJSONresponse( $req, [@oidcRps] ); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 2 | ▶ | sub findOidcRpByClientId { | ||||||||||||||||||||||||||
|
Subroutine
findOidcRpByClientId: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 66 | 2 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 2 | ▶ | my $clientId = ( | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 69 | defined $req->params('uClientId') ? $req->params('uClientId') | ||||||||||||||||||||||||||||
| 70 | : ( | ||||||||||||||||||||||||||||
| 71 | defined $req->params('clientId') ? $req->params('clientId') | ||||||||||||||||||||||||||||
| 72 | : undef | ||||||||||||||||||||||||||||
| 73 | ) | ||||||||||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 2 | ▶ | return $self->sendError( $req, 'Invalid input: clientId is missing', 400 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | unless ( defined $clientId ); | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 2 | $self->logger->debug("[API] Find OIDC RPs by clientId $clientId requested"); | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | # Get latest configuration | ||||||||||||||||||||||||||||
| 82 | 2 | my $conf = $self->_confAcc->getConf( { noCache => 1 } ); | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 2 | my $oidcRp = $self->_getOidcRpByClientId( $conf, $clientId ); | |||||||||||||||||||||||||||
| 85 | 2 | ▶ | return $self->sendError( $req, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | "OIDC relying party with clientId '$clientId' not found", 404 ) | ||||||||||||||||||||||||||||
| 87 | unless ( defined $oidcRp ); | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 1 | return $self->sendJSONresponse( $req, $oidcRp ); | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 5 | ▶ | sub addOidcRp { | ||||||||||||||||||||||||||
|
Subroutine
addOidcRp: called CC=13 SCAR=26.7
Pod
undocumented
| |||||||||||||||||||||||||||||
| 93 | 5 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||
| 94 | 5 | my $add = $req->jsonBodyToObj; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 5 | ▶ | return $self->sendError( $req, "Invalid input: " . $req->error, 400 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | unless ($add); | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | return $self->sendError( $req, 'Invalid input: confKey is missing', 400 ) | ||||||||||||||||||||||||||||
| 100 | 5 | ▶ | unless ( defined $add->{confKey} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | return $self->sendError( $req, 'Invalid input: confKey is not a string', | ||||||||||||||||||||||||||||
| 103 | 400 ) | ||||||||||||||||||||||||||||
| 104 | 5 | ▶ | if ( ref $add->{confKey} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | return $self->sendError( $req, 'Invalid input: confKey is empty', 400 ) | ||||||||||||||||||||||||||||
| 107 | 5 | ▶ | unless ( $add->{confKey} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | return $self->sendError( $req, 'Invalid input: clientId is missing', 400 ) | ||||||||||||||||||||||||||||
| 110 | 5 | ▶ | unless ( defined $add->{clientId} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | return $self->sendError( $req, 'Invalid input: clientId is not a string', | ||||||||||||||||||||||||||||
| 113 | 400 ) | ||||||||||||||||||||||||||||
| 114 | 5 | ▶ | if ( ref $add->{clientId} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | return $self->sendError( $req, 'Invalid input: redirectUris is missing', | ||||||||||||||||||||||||||||
| 117 | 400 ) | ||||||||||||||||||||||||||||
| 118 | 5 | ▶ | unless ( defined $add->{redirectUris} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | return $self->sendError( $req, | ||||||||||||||||||||||||||||
| 121 | 'Invalid input: redirectUris must be an array', 400 ) | ||||||||||||||||||||||||||||
| 122 | 5 | ▶ | unless ( ref( $add->{redirectUris} ) eq "ARRAY" ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 5 | $self->logger->debug( | |||||||||||||||||||||||||||
| 125 | "[API] Add OIDC RP with confKey $add->{confKey} and clientId $add->{clientId} requested" | ||||||||||||||||||||||||||||
| 126 | ); | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | # Get latest configuration | ||||||||||||||||||||||||||||
| 129 | 5 | my $conf = $self->_confAcc->getConf( { noCache => 1 } ); | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | return $self->sendError( | ||||||||||||||||||||||||||||
| 132 | $req, | ||||||||||||||||||||||||||||
| 133 | "Invalid input: An OIDC RP with confKey $add->{confKey} already exists", | ||||||||||||||||||||||||||||
| 134 | 409 | ||||||||||||||||||||||||||||
| 135 | 5 | ▶ | ) if ( defined $self->_getOidcRpByConfKey( $conf, $add->{confKey} ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | return $self->sendError( | ||||||||||||||||||||||||||||
| 138 | $req, | ||||||||||||||||||||||||||||
| 139 | "Invalid input: An OIDC RP with clientId $add->{clientId} already exists", | ||||||||||||||||||||||||||||
| 140 | 409 | ||||||||||||||||||||||||||||
| 141 | 4 | ▶ | ) if ( defined $self->_getOidcRpByClientId( $conf, $add->{clientId} ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 3 | ▶ | $add->{options} = {} unless ( defined $add->{options} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 3 | $add->{options}->{clientId} = $add->{clientId}; | |||||||||||||||||||||||||||
| 145 | 3 | $add->{options}->{redirectUris} = $add->{redirectUris}; | |||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 3 | my $res = $self->_pushOidcRp( $conf, $add->{confKey}, $add, 1 ); | |||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | return $self->sendError( $req, $res->{msg}, 400 ) | ||||||||||||||||||||||||||||
| 150 | 3 | ▶ | unless ( $res->{res} eq 'ok' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 2 | return $self->sendJSONresponse( | |||||||||||||||||||||||||||
| 153 | $req, | ||||||||||||||||||||||||||||
| 154 | { message => "Successful operation" }, | ||||||||||||||||||||||||||||
| 155 | code => 201 | ||||||||||||||||||||||||||||
| 156 | ); | ||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 4 | ▶ | sub updateOidcRp { | ||||||||||||||||||||||||||
|
Subroutine
updateOidcRp: called CC=8 SCAR=21.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 160 | 4 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||
| 161 | 4 | ▶ | my $confKey = $req->params('confKey') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | or return $self->sendError( $req, 'confKey is missing', 400 ); | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 4 | my $update = $req->jsonBodyToObj; | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 4 | ▶ | return $self->sendError( $req, "Invalid input: " . $req->error, 400 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | unless ($update); | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 4 | ▶ | if ( $update->{redirectUris} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | 4 | ▶ | if ( ref( $update->{redirectUris} ) eq "ARRAY" ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | 4 | $update->{options}->{redirectUris} = $update->{redirectUris}; | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | else { | ||||||||||||||||||||||||||||
| 174 | 0 | return $self->sendError( $req, | |||||||||||||||||||||||||||
| 175 | 'Invalid input: redirectUris must be an array', 400 ); | ||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | $self->logger->debug( | ||||||||||||||||||||||||||||
| 180 | 4 | "[API] OIDC RP $confKey configuration update requested"); | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | # Get latest configuration | ||||||||||||||||||||||||||||
| 183 | 4 | my $conf = $self->_confAcc->getConf( { noCache => 1 } ); | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 4 | my $current = $self->_getOidcRpByConfKey( $conf, $confKey ); | |||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | # Return 404 if not found | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 4 | ▶ | return $self->sendError( $req, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | "OIDC relying party '$confKey' not found", 404 ) | ||||||||||||||||||||||||||||
| 191 | unless ( defined $current ); | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | # check if new clientID exists already | ||||||||||||||||||||||||||||
| 194 | 3 | my $res = $self->_isNewOidcRpClientIdUnique( $conf, $confKey, $update ); | |||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | return $self->sendError( $req, $res->{msg}, 409 ) | ||||||||||||||||||||||||||||
| 197 | 3 | ▶ | unless ( $res->{res} eq 'ok' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 2 | $res = $self->_pushOidcRp( $conf, $confKey, $update, 0 ); | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | return $self->sendError( $req, $res->{msg}, 400 ) | ||||||||||||||||||||||||||||
| 202 | 2 | ▶ | unless ( $res->{res} eq 'ok' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 1 | return $self->sendJSONresponse( $req, undef, code => 204 ); | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 4 | ▶ | sub replaceOidcRp { | ||||||||||||||||||||||||||
|
Subroutine
replaceOidcRp: called CC=11 SCAR=24.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 208 | 4 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||
| 209 | 4 | ▶ | my $confKey = $req->params('confKey') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | or return $self->sendError( $req, 'confKey is missing', 400 ); | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 4 | my $replace = $req->jsonBodyToObj; | |||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 4 | ▶ | return $self->sendError( $req, "Invalid input: " . $req->error, 400 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | unless ($replace); | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | return $self->sendError( $req, 'Invalid input: clientId is missing', 400 ) | ||||||||||||||||||||||||||||
| 218 | 4 | ▶ | unless ( defined $replace->{clientId} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | return $self->sendError( $req, 'Invalid input: clientId is not a string', | ||||||||||||||||||||||||||||
| 221 | 400 ) | ||||||||||||||||||||||||||||
| 222 | 4 | ▶ | if ( ref $replace->{clientId} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | return $self->sendError( $req, 'Invalid input: redirectUris is missing', | ||||||||||||||||||||||||||||
| 225 | 400 ) | ||||||||||||||||||||||||||||
| 226 | 4 | ▶ | unless ( defined $replace->{redirectUris} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | return $self->sendError( $req, | ||||||||||||||||||||||||||||
| 229 | 'Invalid input: redirectUris must be an array', 400 ) | ||||||||||||||||||||||||||||
| 230 | 4 | ▶ | unless ( ref( $replace->{redirectUris} ) eq "ARRAY" ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 4 | $self->logger->debug( | |||||||||||||||||||||||||||
| 233 | "[API] OIDC RP $confKey configuration replace requested"); | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | # Get latest configuration | ||||||||||||||||||||||||||||
| 236 | 4 | my $conf = $self->_confAcc->getConf( { noCache => 1 } ); | |||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | # Return 404 if not found | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 4 | ▶ | return $self->sendError( $req, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | "OIDC relying party '$confKey' not found", 404 ) | ||||||||||||||||||||||||||||
| 242 | unless ( defined $self->_getOidcRpByConfKey( $conf, $confKey ) ); | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | # check if new clientID exists already | ||||||||||||||||||||||||||||
| 245 | 3 | my $res = $self->_isNewOidcRpClientIdUnique( $conf, $confKey, $replace ); | |||||||||||||||||||||||||||
| 246 | return $self->sendError( $req, $res->{msg}, 409 ) | ||||||||||||||||||||||||||||
| 247 | 3 | ▶ | unless ( $res->{res} eq 'ok' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 3 | ▶ | $replace->{options} = {} unless ( defined $replace->{options} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | 3 | $replace->{options}->{clientId} = $replace->{clientId}; | |||||||||||||||||||||||||||
| 251 | 3 | $replace->{options}->{redirectUris} = $replace->{redirectUris}; | |||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 3 | $res = $self->_pushOidcRp( $conf, $confKey, $replace, 1 ); | |||||||||||||||||||||||||||
| 254 | return $self->sendError( $req, $res->{msg}, 400 ) | ||||||||||||||||||||||||||||
| 255 | 3 | ▶ | unless ( $res->{res} eq 'ok' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 1 | return $self->sendJSONresponse( $req, undef, code => 204 ); | |||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 3 | ▶ | sub deleteOidcRp { | ||||||||||||||||||||||||||
|
Subroutine
deleteOidcRp: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 261 | 3 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||
| 262 | 3 | ▶ | my $confKey = $req->params('confKey') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 263 | or return $self->sendError( $req, 'confKey is missing', 400 ); | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | # Get latest configuration | ||||||||||||||||||||||||||||
| 266 | 3 | my $conf = $self->_confAcc->getConf( { noCache => 1 } ); | |||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 3 | my $delete = $self->_getOidcRpByConfKey( $conf, $confKey ); | |||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | # Return 404 if not found | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 3 | ▶ | return $self->sendError( $req, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 273 | "OIDC relying party '$confKey' not found", 404 ) | ||||||||||||||||||||||||||||
| 274 | unless ( defined $delete ); | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 2 | delete $conf->{oidcRPMetaDataOptions}->{$confKey}; | |||||||||||||||||||||||||||
| 277 | 2 | delete $conf->{oidcRPMetaDataExportedVars}->{$confKey}; | |||||||||||||||||||||||||||
| 278 | 2 | delete $conf->{oidcRPMetaDataOptionsExtraClaims}->{$confKey}; | |||||||||||||||||||||||||||
| 279 | 2 | delete $conf->{oidcRPMetaDataMacros}->{$confKey}; | |||||||||||||||||||||||||||
| 280 | 2 | delete $conf->{oidcRPMetaDataScopeRules}->{$confKey}; | |||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | # Save configuration | ||||||||||||||||||||||||||||
| 283 | 2 | $self->_saveApplyConf($conf); | |||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 2 | return $self->sendJSONresponse( $req, undef, code => 204 ); | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 50 | ▶ | sub _getOidcRpByConfKey { | ||||||||||||||||||||||||||
|
Subroutine
_getOidcRpByConfKey: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 289 | 50 | my ( $self, $conf, $confKey ) = @_; | |||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | # Check if confKey is defined | ||||||||||||||||||||||||||||
| 292 | 50 | ▶ | return undef unless ( defined $conf->{oidcRPMetaDataOptions}->{$confKey} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | # Get Client ID | ||||||||||||||||||||||||||||
| 295 | my $clientId = $conf->{oidcRPMetaDataOptions}->{$confKey} | ||||||||||||||||||||||||||||
| 296 | 43 | ->{oidcRPMetaDataOptionsClientID}; | |||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | # Get exported vars | ||||||||||||||||||||||||||||
| 299 | 43 | my $exportedVars = $conf->{oidcRPMetaDataExportedVars}->{$confKey}; | |||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | # Get extra claim | ||||||||||||||||||||||||||||
| 302 | 43 | my $extraClaims = $conf->{oidcRPMetaDataOptionsExtraClaims}->{$confKey}; | |||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | # Get macros | ||||||||||||||||||||||||||||
| 305 | 43 | ▶ | my $macros = $conf->{oidcRPMetaDataMacros}->{$confKey} || {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$conf->{'oidcRPMetaDataMacros'}{$confKey} || {}
MC/DC0%0/1
$conf->{'oidcRPMetaDataMacros'}{$confKey} || {}
$conf->{'oidcRPMetaDataMacros'}{$confKey}
Truth table50%1/2
A
A= $conf->{'oidcRPMetaDataMacros'}{$confKey}
| |||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | # Get scope rules | ||||||||||||||||||||||||||||
| 308 | 43 | ▶ | my $scopeRules = $conf->{oidcRPMetaDataScopeRules}->{$confKey} || {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$conf->{'oidcRPMetaDataScopeRules'}{$confKey} || {}
MC/DC0%0/1
$conf->{'oidcRPMetaDataScopeRules'}{$confKey} || {}
$conf->{'oidcRPMetaDataScopeRules'}{$confKey}
Truth table50%1/2
A
A= $conf->{'oidcRPMetaDataScopeRules'}{$confKey}
| |||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | # Redirect URIs, filled later | ||||||||||||||||||||||||||||
| 311 | my $redirectUris = $self->_translateValueConfToApi( | ||||||||||||||||||||||||||||
| 312 | 'oidcRPMetaDataOptionsRedirectUris', | ||||||||||||||||||||||||||||
| 313 | $conf->{oidcRPMetaDataOptions}->{$confKey} | ||||||||||||||||||||||||||||
| 314 | ->{oidcRPMetaDataOptionsRedirectUris} | ||||||||||||||||||||||||||||
| 315 | 43 | ); | |||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | # Get options | ||||||||||||||||||||||||||||
| 318 | 43 | my $options = {}; | |||||||||||||||||||||||||||
| 319 | 43 | for | |||||||||||||||||||||||||||
| 320 | 43 | my $configOption ( keys %{ $conf->{oidcRPMetaDataOptions}->{$confKey} } ) | |||||||||||||||||||||||||||
| 321 | { | ||||||||||||||||||||||||||||
| 322 | 1663 | my $apiName = $self->_translateOptionConfToApi($configOption); | |||||||||||||||||||||||||||
| 323 | my $apiValue = $self->_translateValueConfToApi( $configOption, | ||||||||||||||||||||||||||||
| 324 | 1663 | $conf->{oidcRPMetaDataOptions}->{$confKey}->{$configOption} ); | |||||||||||||||||||||||||||
| 325 | 1663 | $options->{$apiName} = $apiValue; | |||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | return { | ||||||||||||||||||||||||||||
| 329 | 43 | confKey => $confKey, | |||||||||||||||||||||||||||
| 330 | clientId => $clientId, | ||||||||||||||||||||||||||||
| 331 | redirectUris => $redirectUris, | ||||||||||||||||||||||||||||
| 332 | exportedVars => $exportedVars, | ||||||||||||||||||||||||||||
| 333 | extraClaims => $extraClaims, | ||||||||||||||||||||||||||||
| 334 | macros => $macros, | ||||||||||||||||||||||||||||
| 335 | scopeRules => $scopeRules, | ||||||||||||||||||||||||||||
| 336 | options => $options | ||||||||||||||||||||||||||||
| 337 | }; | ||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | 8 | ▶ | sub _getOidcRpByClientId { | ||||||||||||||||||||||||||
|
Subroutine
_getOidcRpByClientId: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 341 | 8 | my ( $self, $conf, $clientId ) = @_; | |||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | 8 | foreach ( keys %{ $conf->{oidcRPMetaDataOptions} } ) { | |||||||||||||||||||||||||||
| 344 | return $self->_getOidcRpByConfKey( $conf, $_ ) | ||||||||||||||||||||||||||||
| 345 | if ( $conf->{oidcRPMetaDataOptions}->{$_} | ||||||||||||||||||||||||||||
| 346 | 9 | ▶ | ->{oidcRPMetaDataOptionsClientID} eq $clientId ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | 5 | return undef; | |||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | 6 | ▶ | sub _isNewOidcRpClientIdUnique { | ||||||||||||||||||||||||||
|
Subroutine
_isNewOidcRpClientIdUnique: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||
| 353 | 6 | my ( $self, $conf, $confKey, $oidcRp ) = @_; | |||||||||||||||||||||||||||
| 354 | 6 | my $curClientId = $self->_getOidcRpByConfKey( $conf, $confKey )->{clientId}; | |||||||||||||||||||||||||||
| 355 | my $newClientId = | ||||||||||||||||||||||||||||
| 356 | $oidcRp->{clientId} | ||||||||||||||||||||||||||||
| 357 | || $oidcRp->{options}->{clientId} | ||||||||||||||||||||||||||||
| 358 | 6 | ▶ | || ""; | ||||||||||||||||||||||||||
|
Condition60%3/5
$oidcRp->{'clientId'} || $oidcRp->{'options'}{'clientId'} || ''
$oidcRp->{"clientId"} or $oidcRp->{"options"}{"clientId"}
MC/DC0%0/2
$oidcRp->{'clientId'} || $oidcRp->{'options'}{'clientId'} || ''
$oidcRp->{"clientId"}
$oidcRp->{"options"}{"clientId"}
Truth table66%2/3
A or B
A= $oidcRp->{"clientId"}B= $oidcRp->{"options"}{"clientId"}
| |||||||||||||||||||||||||||||
| 359 | 6 | ▶ | if ( $newClientId ne '' && $newClientId ne $curClientId ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$newClientId ne "" and $newClientId ne $curClientId
MC/DC50%1/2
$newClientId ne "" and $newClientId ne $curClientId
$newClientId ne ""
$newClientId ne $curClientId
Truth table66%2/3
A and B
A= $newClientId ne ""B= $newClientId ne $curClientId
| |||||||||||||||||||||||||||||
| 360 | return { | ||||||||||||||||||||||||||||
| 361 | 2 | ▶ | res => 'ko', | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 362 | msg => | ||||||||||||||||||||||||||||
| 363 | "An OIDC relying party with clientId '$newClientId' already exists" | ||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | if ( defined $self->_getOidcRpByClientId( $conf, $newClientId ) ); | ||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 5 | return { res => 'ok' }; | |||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | 8 | ▶ | sub _pushOidcRp { | ||||||||||||||||||||||||||
|
Subroutine
_pushOidcRp: called CC=16 SCAR=28.8
| |||||||||||||||||||||||||||||
| 372 | 8 | my ( $self, $conf, $confKey, $push, $replace ) = @_; | |||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | 8 | my $translatedOptions = {}; | |||||||||||||||||||||||||||
| 375 | 8 | ▶ | if ($replace) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 376 | 6 | $conf->{oidcRPMetaDataOptions}->{$confKey} = {}; | |||||||||||||||||||||||||||
| 377 | 6 | $conf->{oidcRPMetaDataExportedVars}->{$confKey} = {}; | |||||||||||||||||||||||||||
| 378 | 6 | $conf->{oidcRPMetaDataOptionsExtraClaims}->{$confKey} = {}; | |||||||||||||||||||||||||||
| 379 | 6 | $conf->{oidcRPMetaDataScopeRules}->{$confKey} = {}; | |||||||||||||||||||||||||||
| 380 | 6 | $conf->{oidcRPMetaDataMacros}->{$confKey} = {}; | |||||||||||||||||||||||||||
| 381 | 6 | $translatedOptions = $self->_getDefaultValues('oidcRPMetaDataNode'); | |||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | 8 | ▶ | if ( defined $push->{options} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 8 | foreach ( keys %{ $push->{options} } ) { | |||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | 41 | my $optionName = $self->_translateOptionApiToConf( $_, 'oidcRP' ); | |||||||||||||||||||||||||||
| 389 | 41 | eval { | |||||||||||||||||||||||||||
| 390 | my $optionValue = | ||||||||||||||||||||||||||||
| 391 | $self->_translateValueApiToConf( $optionName, | ||||||||||||||||||||||||||||
| 392 | 41 | $push->{options}->{$_} ); | |||||||||||||||||||||||||||
| 393 | 41 | $translatedOptions->{$optionName} = $optionValue; | |||||||||||||||||||||||||||
| 394 | }; | ||||||||||||||||||||||||||||
| 395 | 41 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 396 | return { | ||||||||||||||||||||||||||||
| 397 | 0 | res => 'ko', | |||||||||||||||||||||||||||
| 398 | msg => "Invalid input: $@", | ||||||||||||||||||||||||||||
| 399 | }; | ||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | 8 | my $res = $self->_hasAllowedAttributes( $translatedOptions, | |||||||||||||||||||||||||||
| 404 | 'oidcRPMetaDataNode' ); | ||||||||||||||||||||||||||||
| 405 | 8 | ▶ | return $res unless ( $res->{res} eq 'ok' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | 5 | $self->_merge_hash( $conf, 'oidcRPMetaDataOptions', $confKey, | |||||||||||||||||||||||||||
| 408 | $translatedOptions ); | ||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | $conf->{oidcRPMetaDataOptions}->{$confKey}->{oidcRPMetaDataOptionsClientID} | ||||||||||||||||||||||||||||
| 412 | = $push->{clientId} | ||||||||||||||||||||||||||||
| 413 | 5 | ▶ | if ( defined $push->{clientId} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | 5 | ▶ | if ( defined $push->{exportedVars} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 416 | 5 | ▶ | if ( $self->_isSimpleKeyValueHash( $push->{exportedVars} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 417 | $self->_merge_hash( | ||||||||||||||||||||||||||||
| 418 | $conf, 'oidcRPMetaDataExportedVars', | ||||||||||||||||||||||||||||
| 419 | $confKey, $push->{exportedVars} | ||||||||||||||||||||||||||||
| 420 | 5 | ); | |||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||
| 422 | else { | ||||||||||||||||||||||||||||
| 423 | return { | ||||||||||||||||||||||||||||
| 424 | 0 | res => 'ko', | |||||||||||||||||||||||||||
| 425 | msg => | ||||||||||||||||||||||||||||
| 426 | "Invalid input: exportedVars is not a hash object with \"key\":\"value\" attributes" | ||||||||||||||||||||||||||||
| 427 | }; | ||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | 5 | ▶ | if ( defined $push->{macros} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 432 | 5 | ▶ | if ( $self->_isSimpleKeyValueHash( $push->{macros} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 433 | $self->_merge_hash( $conf, 'oidcRPMetaDataMacros', $confKey, | ||||||||||||||||||||||||||||
| 434 | 5 | $push->{macros} ); | |||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||
| 436 | else { | ||||||||||||||||||||||||||||
| 437 | return { | ||||||||||||||||||||||||||||
| 438 | 0 | res => 'ko', | |||||||||||||||||||||||||||
| 439 | msg => "Invalid input: macros is not a hash object" | ||||||||||||||||||||||||||||
| 440 | . " with \"key\":\"value\" attributes" | ||||||||||||||||||||||||||||
| 441 | }; | ||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | 5 | ▶ | if ( defined $push->{scopeRules} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 446 | 5 | ▶ | if ( $self->_isSimpleKeyValueHash( $push->{scopeRules} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 447 | $self->_merge_hash( | ||||||||||||||||||||||||||||
| 448 | $conf, 'oidcRPMetaDataScopeRules', | ||||||||||||||||||||||||||||
| 449 | $confKey, $push->{scopeRules} | ||||||||||||||||||||||||||||
| 450 | 5 | ); | |||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||
| 452 | else { | ||||||||||||||||||||||||||||
| 453 | return { | ||||||||||||||||||||||||||||
| 454 | 0 | res => 'ko', | |||||||||||||||||||||||||||
| 455 | msg => "Invalid input: scopeRules is not a hash object" | ||||||||||||||||||||||||||||
| 456 | . " with \"key\":\"value\" attributes" | ||||||||||||||||||||||||||||
| 457 | }; | ||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | 5 | ▶ | if ( defined $push->{extraClaims} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 462 | 1 | ▶ | if ( $self->_isSimpleKeyValueHash( $push->{extraClaims} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 463 | $self->_merge_hash( $conf, 'oidcRPMetaDataOptionsExtraClaims', | ||||||||||||||||||||||||||||
| 464 | 1 | $confKey, $push->{extraClaims} ); | |||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||
| 466 | else { | ||||||||||||||||||||||||||||
| 467 | return { | ||||||||||||||||||||||||||||
| 468 | 0 | res => 'ko', | |||||||||||||||||||||||||||
| 469 | msg => "Invalid input: extraClaims is not a hash object" | ||||||||||||||||||||||||||||
| 470 | . " with \"key\":\"value\" attributes" | ||||||||||||||||||||||||||||
| 471 | }; | ||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | # Test new configuration | ||||||||||||||||||||||||||||
| 476 | 5 | my $parser = Lemonldap::NG::Manager::Conf::Parser->new( { | |||||||||||||||||||||||||||
| 477 | refConf => $self->_confAcc->getConf( { noCache => 1 } ), | ||||||||||||||||||||||||||||
| 478 | newConf => $conf, | ||||||||||||||||||||||||||||
| 479 | req => {}, | ||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||
| 481 | ); | ||||||||||||||||||||||||||||
| 482 | 5 | ▶ | unless ( $parser->testNewConf( $self->p ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 483 | return { | ||||||||||||||||||||||||||||
| 484 | res => 'ko', | ||||||||||||||||||||||||||||
| 485 | code => 400, | ||||||||||||||||||||||||||||
| 486 | msg => "Configuration error: " | ||||||||||||||||||||||||||||
| 487 | 1 | . join( ". ", map { $_->{message} } @{ $parser->errors } ), | |||||||||||||||||||||||||||
| 488 | }; | ||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | # Save configuration | ||||||||||||||||||||||||||||
| 492 | 4 | $self->_saveApplyConf($conf); | |||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | 4 | return { res => 'ok' }; | |||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | 28 | 1; | |||||||||||||||||||||||||||