-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New Guard Authentication System (e.g. putting the joy back into security) #14673
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
330aa7f
Improving phpdoc on AuthenticationEntryPointInterface so people that …
weaverryan 05af97c
Initial commit (but after some polished work) of the new Guard authen…
weaverryan a0bceb4
adding Guard tests
weaverryan 873ed28
Renaming the tokens to be clear they are "post" and "pre" auth - also…
weaverryan 180e2c7
Properly handles "post auth" tokens that have become not authenticated
weaverryan 6c180c7
Adding an edge case - this should not happen anyways
weaverryan c73c32e
Thanks fabbot!
weaverryan eb158cb
Updating interface method per suggestion - makes sense to me, Request…
weaverryan d693721
Adding periods at the end of exceptions, and changing one class name …
weaverryan 6edb9e1
Tweaking docblock on interface thanks to @iltar
weaverryan ffdbc66
Splitting the getting of the user and checking credentials into two s…
weaverryan 7de05be
A few more changes thanks to @iltar
weaverryan 7a94994
Thanks again fabbot!
weaverryan 81432f9
Adding missing factory registration
weaverryan 293c8a1
meaningless author and license changes
weaverryan 0501761
Allowing for other authenticators to be checked
weaverryan 31f9cae
Adding a base class to assist with form login authentication
weaverryan c9d9430
Adding logging on this step and switching the order - not for any hu…
weaverryan 396a162
Tweaks thanks to Wouter
weaverryan 302235e
Fixing a bug where having an authentication failure would log you out.
weaverryan dd485f4
Adding a new exception and throwing it when the User changes
weaverryan e353833
fabbot
weaverryan d763134
Removing unnecessary override
weaverryan a01ed35
Adding the necessary files so that Guard can be its own installable c…
weaverryan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Tweaks thanks to Wouter
- Loading branch information
commit 396a1622dc69b53c552659a4839e4f22834976a8
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
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
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.
Shouldn't the
checkPostAuth()
be done aftercreateAuthenticatedToken()
?I have a small concern regarding the user checker though. Say that before querying anything to find a user, I want to check if the IP has a time out, how would I do it here?
In the old situation I would have created my own simple-authenticator which did this. After this PR, I'd have to put it in a
GuardAuthenticatorInterface
. Neither of those solutions seems feasible for me as I would have to create either a weird inheritance tree or duplicate code in my authenticators. It would be great for you (and others ofc!) to think with me on the following points:Regarding those points, after an x amount of failed attempts, I have to show a captcha which has to be displayed until either valid or another x attempts have failed. This bundle would add the 'captcha' type to a form which you can then re-use for both the validation and display. I want to do this before the authentication takes place (why query the database for a blocked IP). https://github.com/Gregwar/CaptchaBundle
Just a random brainfart
I can also imagine the possibility to automate certain validation points by using a FormType with constraints; With a data transformer to put the user in there automatically via a user provider based on the username.
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.
A lot here :)
Actually,
checkPostAuth()
is right, butcheckPreAuth()
was wrong - it should happen right after fetching the User, but before checking credentials (seeUserAuthenticationProvider
). I've just split a method on the interface to make this possible and moved thecheckPreAuth()
in the provider. Thanks for asking about this - I hadn't really realized I had things in the wrong spot.About the IP timeout idea, was this simpler with the simple-authenticator? Or are you saying that in both cases, you'd need to use inheritance or duplication to put the code into the "simple authenticator" or the "guard authenticator", so it's the same, but no better? I just commented on symfony/security - tagging UserCheckerInterface #11090 - I think it can be solved there.
We should avoid using forms or validation anywhere. But more importantly, the "guard authenticators" are so simple that you can do whatever you want, including using forms and validation.
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.
Regarding point 2, It will be similar. In my case I've actually implement a custom UserChecker, which I manually had to inject (can't configure that at all). I've made a custom method called
checkPreUserLoad()
in a customUserCheckerInterface
implementation and created an abstract authenticator that all our different authentication classes (simple-form, simple-pre-auth) extend. In your implementation, I would probably put half of this inside the part where you get the values from the request and pass the captcha valid/invalid/not required from there.I was wondering if it would be possible to tackle that problem while we are at it.
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.
Would the user checker stuff in #11090 solve this? If not, what do you propose? This looks like a lot of business logic to me, and putting that either into the user checker or somewhere in the authenticator (or the authenticator calls out to another service which holds the logic) seems right and simple to me.
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.
I think the solution I proposed in #11090 will in fact solve this issue. That is Backwards compatible, just need to modify the configuration for this factory.
Eventually I can use a service decorator to replace the
security.user_checker
and voila, everything magically works without needing to change this code.