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

Commit 09cc884

Browse filesBrowse files
committed
[Security] Move the badges resolution check to AuthenticatorManager
1 parent 314ef9f commit 09cc884
Copy full SHA for 09cc884

File tree

5 files changed

+15
-13
lines changed
Filter options

5 files changed

+15
-13
lines changed

‎UPGRADE-5.3.md

Copy file name to clipboardExpand all lines: UPGRADE-5.3.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ Routing
9191
Security
9292
--------
9393

94+
* [BC BREAK] Remove method `checkIfCompletelyResolved()` from `PassportInterface`, checking that passport badges are
95+
resolved is up to `AuthenticatorManager`
9496
* Deprecate class `User`, use `InMemoryUser` or your own implementation instead.
9597
If you are using the `isAccountNonLocked()`, `isAccountNonExpired()` or `isCredentialsNonExpired()` method, consider re-implementing
9698
them in your own user class, as they are not part of the `InMemoryUser` API

‎src/Symfony/Component/Security/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ CHANGELOG
44
5.3
55
---
66

7+
* Add `PassportInterface:getBadges()`, implemented by `PassportTrait`
8+
* [BC BREAK] Remove method `checkIfCompletelyResolved()` from `PassportInterface`, checking that passport badges are
9+
resolved is up to `AuthenticatorManager`
710
* Deprecate class `User`, use `InMemoryUser` instead
811
* Deprecate class `UserChecker`, use `InMemoryUserChecker` or your own implementation instead
912
* [BC break] Remove support for passing a `UserInterface` implementation to `Passport`, use the `UserBadge` instead.

‎src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Security\Core\AuthenticationEvents;
2020
use Symfony\Component\Security\Core\Event\AuthenticationSuccessEvent;
2121
use Symfony\Component\Security\Core\Exception\AuthenticationException;
22+
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
2223
use Symfony\Component\Security\Core\User\UserInterface;
2324
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
2425
use Symfony\Component\Security\Http\Authenticator\InteractiveAuthenticatorInterface;
@@ -168,7 +169,11 @@ private function executeAuthenticator(AuthenticatorInterface $authenticator, Req
168169
$this->eventDispatcher->dispatch($event);
169170

170171
// check if all badges are resolved
171-
$passport->checkIfCompletelyResolved();
172+
foreach ($passport->getBadges() as $badge) {
173+
if (!$badge->isResolved()) {
174+
throw new BadCredentialsException(sprintf('Authentication failed: Security badge "%s" is not resolved, did you forget to register the correct listeners?', get_debug_type($badge)));
175+
}
176+
}
172177

173178
// create the authenticated token
174179
$authenticatedToken = $authenticator->createAuthenticatedToken($passport, $this->firewallName);

‎src/Symfony/Component/Security/Http/Authenticator/Passport/PassportInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Authenticator/Passport/PassportInterface.php
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Security\Http\Authenticator\Passport;
1313

14-
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
1514
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\BadgeInterface;
1615

1716
/**
@@ -43,9 +42,7 @@ public function hasBadge(string $badgeFqcn): bool;
4342
public function getBadge(string $badgeFqcn): ?BadgeInterface;
4443

4544
/**
46-
* Checks if all badges are marked as resolved.
47-
*
48-
* @throws BadCredentialsException when a badge is not marked as resolved
45+
* @return BadgeInterface[]
4946
*/
50-
public function checkIfCompletelyResolved(): void;
47+
public function getBadges(): array;
5148
}

‎src/Symfony/Component/Security/Http/Authenticator/Passport/PassportTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Authenticator/Passport/PassportTrait.php
+2-7Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Security\Http\Authenticator\Passport;
1313

14-
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
1514
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\BadgeInterface;
1615

1716
/**
@@ -43,12 +42,8 @@ public function getBadge(string $badgeFqcn): ?BadgeInterface
4342
return $this->badges[$badgeFqcn] ?? null;
4443
}
4544

46-
public function checkIfCompletelyResolved(): void
45+
public function getBadges(): array
4746
{
48-
foreach ($this->badges as $badge) {
49-
if (!$badge->isResolved()) {
50-
throw new BadCredentialsException(sprintf('Authentication failed security badge "%s" is not resolved, did you forget to register the correct listeners?', \get_class($badge)));
51-
}
52-
}
47+
return $this->badges;
5348
}
5449
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.