« blib/lib/Lemonldap/NG/Portal/Auth/Choice.pm
↑ Summary
blib/lib/Lemonldap/NG/Portal/Lib/Wrapper.pm »
| 1 | package Lemonldap::NG::Portal::Captcha::CaptchEtat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 JSON; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Lemonldap::NG::Common::UserAgent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use HTTP::Request::Common; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Add constants used by this module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | our $VERSION = '2.23.0'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | extends 'Lemonldap::NG::Portal::Main::Plugin'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | has ua => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | builder => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | my $ua = Lemonldap::NG::Common::UserAgent->new( $_[0]->{conf} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | $ua->env_proxy(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | return $ua; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | has client_id => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | ▶ | builder => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | $_[0]->conf->{captchaOptions}->{clientId}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | has client_secret => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | ▶ | builder => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 3 | $_[0]->conf->{captchaOptions}->{clientSecret}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | has captcha_style_name => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | builder => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | $_[0]->conf->{captchaOptions}->{captchaStyleName} || 'captchaFR'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | has oauth_token_endpoint => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | builder => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | $_[0]->conf->{captchaOptions}->{oauthTokenEndpoint} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | ▶ | || 'https://oauth.piste.gouv.fr/api/oauth/token'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | has oauth_scope => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | builder => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | ▶ | $_[0]->conf->{captchaOptions}->{oauthScope} || 'piste.captchetat'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | has captcha_api_base => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | ▶ | builder => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | $_[0]->conf->{captchaOptions}->{captchaApiBase} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | ▶ | || 'https://api.piste.gouv.fr/piste/captchetat/v2'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | has access_token_cache => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | ▶ | builder => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 3 | expires_at => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | value => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 3 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=13.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 3 | ▶ | unless ( $self->client_id && $self->client_secret ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->client_id and $self->client_secret
MC/DC0%0/2
$self->client_id and $self->client_secret
$self->client_id
$self->client_secret
Truth table33%1/3
A and B
A= $self->client_idB= $self->client_secret
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $self->logger->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 'Missing required options for CaptchEtat: clientId, clientSecret'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | $self->addAuthRoute( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 3 | 'simple-captcha-endpoint' => 'captchaProxy', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | [qw(GET)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | $self->addUnauthRoute( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 'simple-captcha-endpoint' => 'captchaProxy', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | [qw(GET)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 10 | ▶ | sub getToken { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getToken: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 10 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 10 | my $cache = $self->access_token_cache; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 10 | ▶ | if ( $cache->{expires_at} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$cache->{"expires_at"} and $cache->{"expires_at"} > &CORE::GLOBAL::time() and $cache->{"value"}
$cache->{"expires_at"} and $cache->{"expires_at"} > &CORE::GLOBAL::time()
MC/DC66%2/3
$cache->{"expires_at"} and $cache->{"expires_at"} > &CORE::GLOBAL::time() and $cache->{"value"}
$cache->{"expires_at"}
$cache->{"expires_at"} > &CORE::GLOBAL::time()
$cache->{"value"}
Truth table75%3/4
A and B and C
A= $cache->{"expires_at"}B= $cache->{"expires_at"} > &CORE::GLOBAL::time()C= $cache->{"value"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | and $cache->{expires_at} > time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | and $cache->{value} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 5 | return $cache->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 5 | return $self->_getNewToken; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 5 | ▶ | sub _getNewToken { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_getNewToken: called CC=5 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 5 | my $token_url = URI->new( $self->oauth_token_endpoint ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 5 | $self->logger->debug("Calling CaptchEtat token endpoint $token_url"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 5 | my $response = $self->ua->post( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | $token_url, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | Content => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | grant_type => 'client_credentials', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | client_id => $self->client_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | client_secret => $self->client_secret, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | scope => $self->oauth_scope, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 5 | ▶ | if ( $response->is_success ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 5 | my $res = eval { JSON::from_json( $response->decoded_content ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 5 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $self->logger->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | "Could not decode JSON response from CaptchEtat token endpoint: $@" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $self->logger->debug( $response->dump ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # Cache token if we can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 5 | ▶ | if ( $res->{expires_in} and $res->{access_token} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$res->{"expires_in"} and $res->{"access_token"}
MC/DC0%0/2
$res->{"expires_in"} and $res->{"access_token"}
$res->{"expires_in"}
$res->{"access_token"}
Truth table33%1/3
A and B
A= $res->{"expires_in"}B= $res->{"access_token"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | $self->access_token_cache( { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | expires_at => ( time + $res->{expires_in} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | value => $res->{access_token}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $self->access_token_cache( {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 5 | return ( $res->{access_token} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | $self->logger->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | 'CaptchEtat token endpoint error: ' . $response->status_line ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $self->logger->debug( $response->dump ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 7 | ▶ | sub captchaProxy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
captchaProxy: called CC=9 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 7 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 7 | my $param_get = $self->_validateProxyParam( $req, 'get' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 7 | ▶ | if ( !$param_get ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | $self->logger->error("CaptchEtat proxy: missing 'get' parameter"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | return $self->p->sendError( $req, 'invalid parameters', 400 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 6 | my $param_c = $self->_validateProxyParam( $req, 'c' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 6 | ▶ | if ( !$param_c ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $self->logger->error("CaptchEtat proxy: missing 'c' parameter"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | return $self->p->sendError( $req, 'invalid parameters', 400 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 6 | my $param_t = $self->_validateProxyParam( $req, 't' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 6 | ▶ | if ( $param_get eq "sound" and !$param_t ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$param_get eq "sound" and not $param_t
MC/DC0%0/2
$param_get eq "sound" and not $param_t
$param_get eq "sound"
not $param_t
Truth table33%1/3
A and not(B)
A= $param_get eq "sound"B= not $param_t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $self->logger->error("CaptchEtat proxy: missing 't' parameter"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | return $self->p->sendError( $req, 'invalid parameters', 400 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 6 | my $backend_uri = URI->new( $self->captcha_api_base ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 6 | $backend_uri->path_segments( $backend_uri->path_segments, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | "simple-captcha-endpoint" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 6 | ▶ | $backend_uri->query_form( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | get => $param_get, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | c => $param_c, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | ( $param_t ? ( t => $param_t ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 6 | $self->logger->debug("Sending CaptchEtat request to $backend_uri"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 6 | my $http_request = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | GET( $backend_uri, "Content-Type" => "application/json", ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 6 | my $response = $self->request_authenticated_service($http_request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 6 | ▶ | if ($response) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 6 | ▶ | if ( $response->is_success ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 5 | my $res = eval { JSON::from_json( $response->decoded_content ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 5 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $self->logger->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | "Could not decode JSON response from CaptchEtat: $@"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $self->logger->debug( $response->dump ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | return $self->p->sendError( $req, 'CaptchEtat backend failed', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 500 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 5 | return $self->p->sendJSONresponse( $req, $res ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | $self->logger->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 'CaptchEtat error: ' . $response->status_line ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | $self->logger->debug( $response->dump ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | return $self->p->sendError( $req, 'CaptchEtat backend failed', 500 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 19 | ▶ | sub _validateProxyParam { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validateProxyParam: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 19 | my ( $self, $req, $param_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 19 | ▶ | my $value = $req->param($param_name) || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$req->param($param_name) || ''
MC/DC100%1/1
$req->param($param_name) || ''
$req->param($param_name)
Truth table100%2/2
A
A= $req->param($param_name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 19 | ▶ | if ( $value =~ /^[\w-]+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 12 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 6 | ▶ | sub init_captcha { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_captcha: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 6 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 6 | my $cacheTag = $self->p->cacheTag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 6 | $req->data->{customScript} .= <<"EOF"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | <script type="text/javascript" src="$self->{p}->{staticPrefix}/common/js/captchetat-js.min.js?v=$cacheTag"></script> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 6 | my $nomCaptcha = $self->captcha_style_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 6 | ▶ | my $sc = $req->script_name // ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$req->script_name // ""
MC/DC0%0/1
$req->script_name // ""
$req->script_name
Truth table50%1/2
A
A= $req->script_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 6 | $sc =~ s#/*$#/#; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 6 | my $endpoint = "${sc}simple-captcha-endpoint"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # Read option from the manager configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 6 | my $html = <<EOF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | <div id="captchetat" captchaStyleName="$nomCaptcha" altImage="alternativeImage" urlBackend="$endpoint"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | <input type="text" id="captchaCode" name="captchaCode"/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 6 | $req->captchaHtml($html); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 8 | ▶ | sub request_authenticated_service { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_authenticated_service: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 8 | my ( $self, $http_request ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 8 | my $response = $self->_request_with_token($http_request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # If we got an invalid token response, get new token and retry once | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 8 | ▶ | if ( $self->_isInvalidTokenResponse($response) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 2 | $self->logger->debug( 'Current access token rejected,' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | . ' retrying request with a new Access Token' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # Invalidate token cache to make sure it will be refreshed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2 | $self->access_token_cache( {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 2 | $response = $self->_request_with_token($http_request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 8 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 10 | ▶ | sub _request_with_token { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_request_with_token: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 10 | my ( $self, $http_request ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 10 | my $bearer_token = $self->getToken; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 10 | ▶ | unless ($bearer_token) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $self->logger->info('Could not get bearer token for CaptchEtat'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 10 | $http_request->header( Authorization => "Bearer $bearer_token" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 10 | return $self->ua->request($http_request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 8 | ▶ | sub _isInvalidTokenResponse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isInvalidTokenResponse: called CC=8 SCAR=23.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 8 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 8 | ▶ | return unless $r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 8 | ▶ | if ( $r->code and $r->code == 401 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$r->code and $r->code == 401
MC/DC50%1/2
$r->code and $r->code == 401
$r->code
$r->code == 401
Truth table66%2/3
A and B
A= $r->codeB= $r->code == 401
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | # This dependency improves parsing of WWW-Authenticate headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 2 | require HTTP::Headers::Auth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | my ( $auth_scheme, $params ) = $r->www_authenticate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 2 | ▶ | if ( lc($auth_scheme) eq "bearer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
lc $auth_scheme eq "bearer" and ref $params eq "HASH" and $params->{"error"} and $params->{"error"} eq "invalid_token"
lc $auth_scheme eq "bearer" and ref $params eq "HASH" and $params->{"error"}
lc $auth_scheme eq "bearer" and ref $params eq "HASH"
MC/DC0%0/4
lc $auth_scheme eq "bearer" and ref $params eq "HASH" and $params->{"error"} and $params->{"error"} eq "invalid_token"
lc $auth_scheme eq "bearer"
ref $params eq "HASH"
$params->{"error"}
$params->{"error"} eq "invalid_token"
Truth table20%1/5
A and B and C and D
A= lc $auth_scheme eq "bearer"B= ref $params eq "HASH"C= $params->{"error"}D= $params->{"error"} eq "invalid_token"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | and ref($params) eq "HASH" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | and $params->{error} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | and $params->{error} eq "invalid_token" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 6 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 3 | ▶ | sub check_captcha { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_captcha: called CC=5 SCAR=17.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 3 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 3 | my $captcha_uuid = $req->param('captchetat-uuid'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 3 | my $captcha_input = $req->param('captchaCode'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 3 | ▶ | unless ($captcha_input) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 1 | $self->logger->info('No captcha value submitted'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | ▶ | unless ($captcha_uuid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $self->logger->info('No captcha UUID received'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 2 | my $validation_url = URI->new( $self->captcha_api_base ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 2 | $validation_url->path_segments( $validation_url->path_segments, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | "valider-captcha" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 2 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | "Sending CaptchEtat validation request to $validation_url"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 2 | my $http_request = POST( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | $validation_url, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | "Content-Type" => "application/json", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | Content => to_json( { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | uuid => $captcha_uuid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | code => $captcha_input, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 2 | my $response = $self->request_authenticated_service($http_request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 2 | ▶ | if ($response) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 2 | ▶ | if ( $response->is_success ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 2 | my $res = $response->decoded_content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 2 | return ( $res eq "true" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $self->logger->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 'CaptchEtat error: ' . $response->status_line ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $self->logger->debug( $response->dump ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||