protected static function JsonSubrequestDenormalizer::fixBasicAuth in Subrequests 8
Same name and namespace in other branches
- 8.2 src/Normalizer/JsonSubrequestDenormalizer.php \Drupal\subrequests\Normalizer\JsonSubrequestDenormalizer::fixBasicAuth()
- 3.x src/Normalizer/JsonSubrequestDenormalizer.php \Drupal\subrequests\Normalizer\JsonSubrequestDenormalizer::fixBasicAuth()
Adds the decoded username and password headers for Basic Auth.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request to fix.
File
- src/
Normalizer/ JsonSubrequestDenormalizer.php, line 127
Class
Namespace
Drupal\subrequests\NormalizerCode
protected static function fixBasicAuth(Request $request) {
// The server will not set the PHP_AUTH_USER and PHP_AUTH_PW for the
// subrequests if needed.
if ($request->headers
->has('Authorization')) {
$header = $request->headers
->get('Authorization');
if (strpos($header, 'Basic ') === 0) {
list($user, $pass) = explode(':', base64_decode(substr($header, 6)));
$request->headers
->set('PHP_AUTH_USER', $user);
$request->headers
->set('PHP_AUTH_PW', $pass);
}
}
}