Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Security] Add a Not_Full_Fledged_handler in ExceptionListener from security login #57661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: 7.4
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
review changes
add r to handleR
  • Loading branch information
eltharin committed Jan 9, 2025
commit 588566a4b5d49c9bbf4b6d23dac65143b5bf7e86
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategy;
use Symfony\Component\Security\Http\Authorization\SameAsNotFullFledgedHandle;
use Symfony\Component\Security\Http\Authorization\SameAsNotFullFledgedHandler;

/**
* SecurityExtension configuration structure.
Expand Down Expand Up @@ -220,7 +220,7 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
->ifTrue(fn ($v): bool => $v == 'original')
->then(fn ($v) => null)
->ifTrue(fn ($v): bool => $v == 'same')
eltharin marked this conversation as resolved.
Show resolved Hide resolved
->then(fn ($v) => SameAsNotFullFledgedHandle::class)
->then(fn ($v) => SameAsNotFullFledgedHandler::class)
eltharin marked this conversation as resolved.
Show resolved Hide resolved
->end()
->end()
->arrayNode('logout')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
use Symfony\Component\Security\Core\User\MissingUserProvider;
use Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Component\Security\Http\Authorization\SameAsNotFullFledgedHandle;
use Symfony\Component\Security\Http\Authorization\SameAsNotFullFledgedHandler;
use Symfony\Component\Security\Http\Controller\SecurityTokenValueResolver;
use Symfony\Component\Security\Http\Controller\UserValueResolver;
use Symfony\Component\Security\Http\EventListener\IsGrantedAttributeListener;
Expand Down Expand Up @@ -325,6 +325,6 @@
->parent('cache.system')
->tag('cache.pool')

->set('security.same_as_not_full_fledged_handle', SameAsNotFullFledgedHandle::class)
->set('security.same_as_not_full_fledged_handle', SameAsNotFullFledgedHandler::class)
;
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

/**
* This is a basic NotFullFledgedHandle
* This is a basic NotFullFledgedHandler
* If IS_AUTHENTICATED_FULLY is in access denied Exception Attrribute, behavior will be as before,
eltharin marked this conversation as resolved.
Show resolved Hide resolved
* Otherwise The original AccessDeniedException is throw
*
* @author Roman JOLY <eltharin18@outlook.fr>
*/
class SameAsNotFullFledgedHandle implements NotFullFledgedHandlerInterface
class SameAsNotFullFledgedHandler implements NotFullFledgedHandlerInterface
eltharin marked this conversation as resolved.
Show resolved Hide resolved
{
public function handle(Request $request, AccessDeniedException $accessDeniedException, AuthenticationTrustResolverInterface $trustResolver, ?TokenInterface $token, callable $reauthenticateResponse): ?Response
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use Symfony\Component\Security\Core\Exception\LogoutException;
use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface;
use Symfony\Component\Security\Http\Authorization\NotFullFledgedHandlerInterface;
use Symfony\Component\Security\Http\Authorization\SameAsNotFullFledgedHandle;
use Symfony\Component\Security\Http\Authorization\SameAsNotFullFledgedHandler;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\Security\Http\Firewall\ExceptionListener;
use Symfony\Component\Security\Http\HttpUtils;
Expand Down Expand Up @@ -267,7 +267,7 @@ private function createEvent(\Exception $exception, $kernel = null)
return new ExceptionEvent($kernel, Request::create('/'), HttpKernelInterface::MAIN_REQUEST, $exception);
}

private function createExceptionListener(?TokenStorageInterface $tokenStorage = null, ?AuthenticationTrustResolverInterface $trustResolver = null, ?HttpUtils $httpUtils = null, ?AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, ?AccessDeniedHandlerInterface $accessDeniedHandler = null, ?NotFullFledgedHandlerInterface $notFullFledgedHandle = null)
private function createExceptionListener(?TokenStorageInterface $tokenStorage = null, ?AuthenticationTrustResolverInterface $trustResolver = null, ?HttpUtils $httpUtils = null, ?AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, ?AccessDeniedHandlerInterface $accessDeniedHandler = null, ?NotFullFledgedHandlerInterface $notFullFledgedHandler = null)
{
return new ExceptionListener(
$tokenStorage ?? $this->createMock(TokenStorageInterface::class),
Expand All @@ -279,15 +279,15 @@ private function createExceptionListener(?TokenStorageInterface $tokenStorage =
$accessDeniedHandler,
null,
false,
$notFullFledgedHandle,
$notFullFledgedHandler,
);
}

private function createNotFullFledgedHandler(?Response $response = null)
{
$entryPoint = $this->createMock(NotFullFledgedHandlerInterface::class);
$entryPoint->method('handle')->willReturn($response);
$handler = $this->createMock(NotFullFledgedHandlerInterface::class);
$handler->method('handle')->willReturn($response);

return $entryPoint;
return $handler;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.