-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[SecurityBundle] Allow accessing remember_me services via FirewallMap #19819
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
Conversation
1afd15f
to
c31c420
Compare
public function getListeners(Request $request) | ||
{ | ||
$context = $this->getContext($request); |
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 about caching contexts by requests using a SplObjectStorage
?
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.
It could be a good candidate I think!
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.
Done in #20196
So does this encourage developers to avoid the security configuration to do it programmatically outside of the firewall? If so, sounds like a bad idea. All authentication related stuff should go through the firewall. If this is a DX issue, maybe that should be solved instead? |
@iltar That's not the goal of this PR, |
I don't know any alternative so I guess this is the way to go for the case at hand |
@iltar Just re-read you.
This allows to access the BTW, Guard already provides a way to authenticate users programatically (which, contrarily to this, doesn't seem to require any configuration) via This PR could give a structured way to solve the related issues, and it is IMHO a nice have. |
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.
Hi,
Thanks for the contribution. If you could take a look at my comment regarding the tests...
If you could also provide a docs PR, I think we would be good to go to Reviewed status.
$context = new FirewallContext($listeners, $exceptionListener, $rememberMeServices); | ||
|
||
$this->assertEquals(array($listeners, $exceptionListener), $context->getContext()); | ||
$this->assertEquals($rememberMeServices, $context->getRememberMeServices()); |
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.
Wouldn't assertSame
be better in these cases?
c31c420
to
7c1dbea
Compare
@lemoinem I updated the test according to your suggestion. About the doc PR, I would like to have at least a thought from the core team before submitting it. Doc PRs being most often created after merging the code PR, it should not be a problem for marking this as reviewed. Thank you for your review. Status: needs review |
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.
Looks good to me! 👍
…ap (chalasr) This PR was merged into the 3.2-dev branch. Discussion ---------- [SecurityBundle] Cache contexts per request in FirewallMap | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #19819 (comment) | License | MIT | Doc PR | n/a From @HeahDude in #19819 (comment), I propose to store and retrieve `Context` objects per `Request` using `SplObjectStorage`. At the moment, contexts are consumed by the `Symfony\Components\Security\Http\Firewall` class only, but they could be indirectly by end users if #19490 and/or #19819 come to be merged. Commits ------- ffacec1 [SecurityBundle] Cache contexts per request in FirewallMap
528ddae
to
5853fdd
Compare
f8cc3a0
to
501f04d
Compare
Not ready as is. |
501f04d
to
8b0cb06
Compare
Closing this as it doesn't look the best way to fix the related tickets. |
This allows to retrieve the
RememberMeServices
service of the current firewall using:An alternative could be to create a public alias of the service.
It seems there are use cases, see the ticket and the ones mentioning it (some from FOSUserBundle).