8000 minor #38220 [Security] Log notice when no entry point is configured … · symfony/symfony@4d1a522 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4d1a522

Browse files
committed
minor #38220 [Security] Log notice when no entry point is configured (wouterj)
This PR was merged into the 5.1 branch. Discussion ---------- [Security] Log notice when no entry point is configured | Q | A | ------------- | --- | Branch? | 5.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #37068 | License | MIT | Doc PR | - In the new security system, authenticators are not necessarily authentication entry points. This can cause unexpected behavior if no entry point is configured. It's not really an error, that's why I choose the "notice" level: "Normal but significant events". Commits ------- 68f891f Log notice when no entry point is configured
2 parents f27ca4e + 68f891f commit 4d1a522

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1717
use Symfony\Component\Config\Definition\ConfigurationInterface;
1818
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
19+
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
1920
use Symfony\Component\Security\Http\Event\LogoutEvent;
2021
use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategy;
2122

@@ -194,7 +195,9 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
194195
->scalarNode('request_matcher')->end()
195196
->scalarNode('access_denied_url')->end()
196197
->scalarNode('access_denied_handler')->end()
197-
->scalarNode('entry_point')->end()
198+
->scalarNode('entry_point')
199+
->info(sprintf('An enabled authenticator name or a service id that implements "%s"', AuthenticationEntryPointInterface::class))
200+
->end()
198201
->scalarNode('provider')->end()
199202
->booleanNode('stateless')->defaultFalse()->end()
200203
->booleanNode('lazy')->defaultFalse()->end()

src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ private function handleLogoutException(ExceptionEvent $event, LogoutException $e
195195
private function startAuthentication(Request $request, AuthenticationException $authException): Response
196196
{
197197
if (null === $this->authenticationEntryPoint) {
198+
if (null !== $this->logger) {
199+
$this->logger->notice(sprintf('No Authentication entry point configured, returning a %s HTTP response. Configure "entry_point" on the firewall ("{firewall_name}") if you want to modify the response.', Response::HTTP_UNAUTHORIZED), ['firewall_name' => $this->providerKey]);
200+
}
201+
198202
throw new HttpException(Response::HTTP_UNAUTHORIZED, $authException->getMessage(), $authException, [], $authException->getCode());
199203
}
200204

0 commit comments

Comments
 (0)
0