Get help from the marimo community

Updated last month

Examples of mo.app_meta().request not getting `user` from AuthMiddleware

At a glance
I am currently deploying Marimo programatically via FastAPI and need to get access to the user object that is set on the request when inside of a Marimo cell.

I am following the examples that have been set in the docs here https://docs.marimo.io/guides/deploying/programmatically/#authentication-middleware-example

However the code that is shown in the examples, and anything else I have tried, all result in the user being a starlette.authentication.SimpleUser object. No matter how I implement the middleware or what I set the user object in the request to I get the same result inside the marimo cell.

This happens even with the example code mentioned in the docs. I have attached the following files:
  • Screenshot of the marimo app's output
  • main.py - Fast API app
  • test.py - Marimo notebook app being run programatically
No matter what I do I cannot get the values set in request.scope["user"] to show up in the app when it is rendered. I have tried changing it from a dictionary (used in the examples) to a subclass of starlette's SimpleUser. None of it is passed through to the Marimo app.

Any insight into what I could be doing wrong would be appreciated.
Attachment
image.png
C
M
10 comments
Hi @Myles Scolnick , this issue is related to the work that was done in 0.10.18. The thread where you mentioned this is this one https://discord.com/channels/1059888774789730424/1328383090476843041
Hey @Chris O it’s possible our middleware is overriding it still
I can take a look today. Just for kicks, can you shove the user info into headers via your middleware? I’m wondering if everything is being overridden
Hi @Myles Scolnick I was debugging further and what I saw is that if I set cookies on the response via my middleware then those changes do show up in the marimo app.

My conclusion was that there must be something overwriting my middleware changes to the scope section of the request.
I will try adding something to the headers and let you know asap if that shows up
@Myles Scolnick I can confirm that setting the headers via the request.scope does persist. So it seems it is only the user that is not persisting
thanks for checking. i will look into 1) not overriding user, or 2) adding a ["meta"] scope such that you can add whatever you want
That would be great, thank you very much @Myles Scolnick
PR is up, will make it in the next release
Amazing thank you @Myles Scolnick
Add a reply
Sign up and join the conversation on Discord