-
Notifications
You must be signed in to change notification settings - Fork 76
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
Allow preparation of providers to be optional #273
Conversation
673dfc1
to
b296ba0
Compare
I have been thinking about this myself when I started the 8.x todo list :) As you mentioned, this will be a BC break, so I'd consider this for the version 8 major release. Though my approach would be a bit different. I'd set all the authentication providers that do not need preparation to "prepared" when the security token is created (in |
I considered the same approach :) But choose to do it this way, because it feels a bit "cleaner" and represents the actual behavior instead of "faking" the preparation state. But I agree as well: it would probably require less changes and therefore probably introduce less bugs 😅 |
Yea, I feel the same issue with the naming/semantics. Would be better if it's called "is ready" or something like that, instead of calling it "prepared", when there was actually no preparation work done. Though, you could argue something that doesn't need preparation could be considered "automatically prepared" 🤷 We could rename things (and introduce more BC breaks), but that's probably not worth bothering too much with it. I'd definitely prefer a less complex implementation over the cleaner naming. |
b296ba0
to
6ef8427
Compare
Looks much cleaner, definitely that approach 👍 Things that I'd change before merging:
What would you suggest how to move forward? I can't merge this into |
Agreed, I'll add some tests and I've updated the loop to be a little more efficient. I noticed this MR now also include the prio change of the listener. To be honest this was not necessarily the intention, but maybe we can use this MR to "Add support for stateless second factor authentication". In this case we should probably also add some documentation about how to setup such authentication. :) |
6ef8427
to
6b53f6c
Compare
About that branching, I'll leave that up to you :) I've integrated my MR branch into an actual project to test it "in production". If this branch/MR lands somewhere in this repo, I'll switch my project to this branch as well. |
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've updated the MR to go into the 8.x
branch. The 8.x
is already containing the change for authenticator priority. So please do a rebase on your side.
src/bundle/DependencyInjection/Factory/Security/TwoFactorFactory.php
Outdated
Show resolved
Hide resolved
src/bundle/Security/TwoFactor/Provider/TwoFactorProviderInterface.php
Outdated
Show resolved
Hide resolved
src/bundle/Security/TwoFactor/Provider/TwoFactorProviderInitiator.php
Outdated
Show resolved
Hide resolved
This paves the way for stateless 2nd factor authentication
6a5b35c
to
a753fda
Compare
Perfect 👍. Integration tests have also gone green. Unit tests need to be added, then we're ready to merge. |
Perfect, thank you! 🙇 |
Description
To pave the way for stateless 2nd factor authentication the bundle can be made aware of providers that do no need to be prepared.
These providers can be used for stateless auth because there is no need to store the state of the preparation.
This MR skips calling the preparation, storing the state of the preparation and checking this state if the provider does not need to be prepared. It does this by adding a bool method
needsPreparation
to theProviderInterface
and checking this method where appropriate.Unfortunately this is a backwards incompatible change and would require other Provider implementations to add the method.
Also see #265