-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] added userChecker to SimpleAuthenticationProvider #26370
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c5bd0bd
[Security] added userChecker to SimpleAuthenticationProvider
63d9dce
[Security] added userChecker to SimpleAuthenticationProvider
i3or1s 3cc426e
[Security] added userChecker to SimpleAuthenticationProvider
i3or1s 476861e
[Security] added userChecker to SimpleAuthenticationProvider
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
8000
Diff view
Diff view
[Security] added userChecker to SimpleAuthenticationProvider
retrieve user from authToken, rather then fetching it from userProvider
- Loading branch information
commit 63d9dce10bdda859f485eb6e21fccb7a30216ced
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,10 +38,9 @@ public function __construct(SimpleAuthenticatorInterface $simpleAuthenticator, U | |
|
||
public function authenticate(TokenInterface $token) | ||
{ | ||
$user = $this->userProvider->loadUserByUsername($token->getUsername()); | ||
$this->userChecker->checkPreAuth($user); | ||
$authToken = $this->simpleAuthenticator->authenticateToken($token, $this->userProvider, $this->providerKey); | ||
$this->userChecker->checkPostAuth($user); | ||
$this->userChecker->checkPreAuth($authToken->getUser()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to call |
||
$this->userChecker->checkPostAuth($authToken->getUser()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be moved after the instanceof check below |
||
|
||
if ($authToken instanceof TokenInterface) { | ||
return $authToken; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I understand the need to have the user here, it would be loaded twice now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iltar maybe then skip the pre auth check since it can be done during authentication of the token.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you do
$this->userChecker->checkPreAuth($authToken->getUser())
? I know it's not exactly correct flow wise, but it beats fetching the user twice 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iltar I was thinking about it but it sounds strange to me to pre authenticate authenticated token.
Changin interface to exclude the userProvider would cause BC breaks.
You are correct about twice loading the user and simple authenticator could do the pre-check if needed.
Maybe best is to remove the
checkPreAuth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it might seem strange, guard does it before/after the credentials check:
symfony/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php
Lines 124 to 128 in a8dc953
I don't see another option to be honest, leaving it out would be as not having it at all.