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

[Messenger] Sanitize message when the receiver is another app #49081

Open
nikophil opened this issue Jan 23, 2023 · 6 comments · May be fixed by #49256
Open

[Messenger] Sanitize message when the receiver is another app #49081

nikophil opened this issue Jan 23, 2023 · 6 comments · May be fixed by #49256

Comments

@nikophil
Copy link
Contributor

nikophil commented Jan 23, 2023

Description

Hello,

Messenger is a great component, but has some drawbacks when it comes to send messages across different apps which use messenger.
Let's pretend an app A sends message through rabbitMQ, that will be consumed by an app B

Messages needs to be "sanitized" before leaving the app:

  • stamps should be removed: if a stamp exists in app A and not in app B, when A sends messages to B, an error could occur. As well as if app A uses a bus which not exist in app B, B will try to get a bus which does not exist and an error will be thrown.
  • header type could also be problematic: if PHP message objects in both apps do not have the same FQCN, when app B receives the message it will try to deserialize it in a class which does not exist.

A solution would be to add a new interface ExternalMessageInterface and take some actions when the interface is encountered in \Symfony\Component\Messenger\Transport\Serialization\Serializer.

I don't think we could fix this with a middleware, because the header type is added at serialization time.

I'd like to have some feedback on this before fixing it.

Thanks :)

@mdeboer
Copy link
Contributor

mdeboer commented Jan 29, 2023

For external applications you can use a custom serializer afaik. If so we could provide a simple JSON serializer that adds none of that stuff.

@lyrixx
Copy link
Member

lyrixx commented Jan 29, 2023

I also use plain JSON when dealing with interoperability. It's easier IMHO

@nikophil
Copy link
Contributor Author

If so we could provide a simple JSON serializer that adds none of that stuff.

I agree with this: IMO this is such a common task, it should not require boilerplate code in user land, and maybe it should be documented

@nikophil nikophil linked a pull request Feb 6, 2023 that will close this issue
@carsonbot
Copy link

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

@carsonbot
Copy link

Could I get an answer? If I do not hear anything I will assume this issue is resolved or abandoned. Please get back to me <3

@nesl247
Copy link

nesl247 commented Sep 4, 2023

This has not been resolved.

@carsonbot carsonbot removed the Stalled label Sep 4, 2023
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.

5 participants