Skip to content

[RFC] Security and stateless and monolog processor #59329

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
94noni opened this issue Dec 30, 2024 · 0 comments
Closed

[RFC] Security and stateless and monolog processor #59329

94noni opened this issue Dec 30, 2024 · 0 comments
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed)

Comments

@94noni
Copy link
Contributor

94noni commented Dec 30, 2024

Description

I am opening an issue because it hits us hard recently

We are decoupling some frontend code via multiple render esi to allow unitary http caching of partial responses
Some of our actions will be stateless by design, so we added the route config stateless on it to be sure we can add cache control on it freely
Some other actions will be stateful and we rely on normal security logic (get the user, etc)
Our front main firewall is lazy

One main template can make 10+ render_esi, and for some routes declared stateless, we had one of our internal monolog processor that crashes because it started the session to get the user via the security logic (when we wanted not to as it can be optional for us to have the user log here)

After digging, we have found this class/service security.untracked_token_storage here #33663
(as well as some reference to monolog logic in its desc)

And when we swapped our internal processor declaration, the problem disappeared

RFCs:

  • symfony/symfony-docs: document such service in this particular context? were one want an "optional" user in a stateless route?
  • symfony/symfony: create an OptionalTokenProcessor ? (in the monolog bridge) (we have an internal one because we dont want all the data of the bridge one)
  • symfony/symfony: configure the TokenProcessor class (of the bridge) with this service?

Many thanks

Example

    CoreBundle\Component\Monolog\Processor\UserProcessor:
        arguments:
-            - '@Symfony\Bundle\SecurityBundle\Security'
+            - '@security.untracked_token_storage'
- $user = $this->security->getUser();
+ $token = $this->tokenStorage->getToken();
+ $user = $token->getUser();

 if (null !== $user) {
    $logRecord->extra ///
}

edit: For the record, we just found this very old processor does not implements the interface of monolog processor interface, thus the biding failure from security token and session logic
after reading the PR related to the original PR found and interface added + namespace swap

lets close for now

@carsonbot carsonbot added the RFC RFC = Request For Comments (proposals about features that you want to be discussed) label Dec 30, 2024
@94noni 94noni closed this as completed Dec 30, 2024
@94noni 94noni reopened this Dec 30, 2024
@94noni 94noni closed this as completed Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed)
Projects
None yet
Development

No branches or pull requests

2 participants