Issue 21958 php-slim4 throws exception (#21962)

authenticatorConfig was being overwritten instead of having additional fields added.
Changed the reqex from requiring leading whitespace to having it optional.
This commit is contained in:
Kevin 2025-09-19 02:25:41 -04:00 committed by GitHub
parent 1c950018c8
commit ec0edf433a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -197,25 +197,25 @@ class RegisterRoutes
$authenticatorConfig = [ $authenticatorConfig = [
'path' => '/', 'path' => '/',
'authenticator' => new ApiKeyAuthenticator, 'authenticator' => new ApiKeyAuthenticator,
'regex' => '/\s+(.*)$/i', 'regex' => '/\s*(.*)$/i',
'argument' => null, 'argument' => null,
'attribute' => 'authorization_token', 'attribute' => 'authorization_token',
'error' => ['{{authPackage}}\ApiKeyAuthenticator', 'handleUnauthorized'], 'error' => ['{{authPackage}}\ApiKeyAuthenticator', 'handleUnauthorized'],
]; ];
if ($authMethod['isKeyInHeader']) { if ($authMethod['isKeyInHeader']) {
$authenticatorConfig = [ $authenticatorConfig += [
'header' => $authMethod['keyParamName'], 'header' => $authMethod['keyParamName'],
'parameter' => null, 'parameter' => null,
'cookie' => null, 'cookie' => null,
]; ];
} else if ($authMethod['isKeyInQuery']) { } else if ($authMethod['isKeyInQuery']) {
$authenticatorConfig = [ $authenticatorConfig += [
'header' => null, 'header' => null,
'parameter' => $authMethod['keyParamName'], 'parameter' => $authMethod['keyParamName'],
'cookie' => null, 'cookie' => null,
]; ];
} else if ($authMethod['isKeyInCookie']) { } else if ($authMethod['isKeyInCookie']) {
$authenticatorConfig = [ $authenticatorConfig += [
'header' => null, 'header' => null,
'parameter' => null, 'parameter' => null,
'cookie' => $authMethod['keyParamName'], 'cookie' => $authMethod['keyParamName'],