Skip to content
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

[Security] Mark the request as _stateless if the firewall used is stateless #40372

Closed
Seldaek opened this issue Mar 5, 2021 · 5 comments · Fixed by #48044
Closed

[Security] Mark the request as _stateless if the firewall used is stateless #40372

Seldaek opened this issue Mar 5, 2021 · 5 comments · Fixed by #48044

Comments

@Seldaek
Copy link
Member

Seldaek commented Mar 5, 2021

Description
As of 5.1, routes can be marked stateless which is a great addition. It occurred to me that if a firewall is configured to be stateless, the Request could also automatically receive the stateless attribute if it matches the firewall config.

Example

Security config example:

security:
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt|error)|css|images|js)/
            security: false

        api:
            host: ^api\.
            custom_authenticators:
                - App\Security\ApiTokenAuthenticator
            stateless: true

        main:
            form_login:
                provider: app_user_provider
                login_path: /login
                check_path: /user/login_check

In this case, requests to the api.example.org should get the _stateless attribute automatically, so we get warned if any API usage has a session started.

Using stateless routes in this case is not strictly possible as we have routes usable on both api and regular domain, and they do make use of sessions for user authentication on the regular domain, but not on the API one.

I for now fixed this with a request listener setting the attribute myself, but it would be nice if the framework took care of it.

@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@Seldaek
Copy link
Member Author

Seldaek commented Sep 13, 2021

Still relevant, will see if I can work on a patch.

@carsonbot carsonbot removed the Stalled label Sep 13, 2021
@nicolas-grekas
Copy link
Member

Patch welcome indeeded :)

@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@xabbuh
Copy link
Member

xabbuh commented Dec 4, 2022

@fabpot #48044 would still be needed for this to be complete if I am not mistaken.

@xabbuh xabbuh reopened this Dec 4, 2022
@fabpot fabpot closed this as completed Dec 18, 2022
fabpot added a commit that referenced this issue Dec 18, 2022
…s stateless (alamirault)

This PR was squashed before being merged into the 6.3 branch.

Discussion
----------

[SecurityBundle] Set request stateless when firewall is stateless

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #40372 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Automatically add `_stateless` attribute to the request when firewall is stateless

Commits
-------

ce458c6 [SecurityBundle] Set request stateless when firewall is stateless
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants