Skip to content

Navigation Menu

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 1a4835d

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

File tree

6 files changed

+20
-17
lines changed
Filter options

6 files changed

+20
-17
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

‎composer.json

Copy file name to clipboardExpand all lines: composer.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
"symfony/polyfill-php73": "^1.11",
5454
"symfony/polyfill-php80": "^1.15",
5555
"symfony/polyfill-uuid": "^1.15",
56-
"symfony/runtime": "self.version"
56+
"symfony/runtime": "self.version",
57+
"vimeo/psalm": "4.x-dev"
5758
},
5859
"replace": {
5960
"symfony/asset": "self.version",

‎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 array<class-string<BadgeInterface>, BadgeInterface> An array of badge instances indexed by class name
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
+5-10Lines changed: 5 additions & 10 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
/**
@@ -21,9 +20,6 @@
2120
*/
2221
trait PassportTrait
2322
{
24-
/**
25-
* @var BadgeInterface[]
26-
*/
2723
private $badges = [];
2824

2925
public function addBadge(BadgeInterface $badge): PassportInterface
@@ -43,12 +39,11 @@ public function getBadge(string $badgeFqcn): ?BadgeInterface
4339
return $this->badges[$badgeFqcn] ?? null;
4440
}
4541

46-
public function checkIfCompletelyResolved(): void
42+
/**
43+
* @return array<class-string<BadgeInterface>, BadgeInterface>
44+
*/
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.