Is there any way to access incoming header data in the streamlit site? I think in a flask site, you’d be handling the incoming request, could parse its header, and use that data in your site’s response. I’m wondering if all that data is unavailable to my site because streamlit/tornado(?)/requests is doing the request handling behind the scenes.
I have a streamlit site sitting behind an nginx reverse proxy. For the core of my question I’m not sure if the nginx layer matters but here’s a little info about how I’m using it. I have nginx adding authentication through its basic auth module. My goal is to find out the authenticated user’s username within my site. I believe nginx can forward the username as a field in the header (proxy_set_header REMOTE_USER $remote_user) but from what I can see, streamlit isn’t going to expose a way to read this REMOTE_USER field from the header.
Yes, your intuition is correct – Streamlit is doing a lot as middleware to obscure connections, so you can’t really crack them open and use that information the same way you would in a Flask route.
The way Streamlit is put together, the javascript (Node) end of the system handles user interface generation and responds to user input, and it communicates with Python (Tornado) over Websockets. This means that on the server side, unless the front-end has specifically collected and resent the information from a request over a websocket, your script will not have access to the original HTTP request header.
Hey there! I noodled on this for a while, and figured out what seems to be a secure implementation. Requires nginx & streamlit. The README at my repo has more details on the specifics of just the user bit if you scroll down
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.