I have successfully built and deployed a Streamlit app on Elastic Beanstalk which utilizes Cognito for user logins (via the work here: GitHub - MausamGaurav/Streamlit_Multipage_AWSCognito_User_Authentication_Authorization).
I know this question has come up in the past…but I could not find a satisfactory answer. I’ve also been messing around with the excellent st-pages package but with no luck.
The issue with show_pages is that it passes across all users accessing the instance…no good!
The issue with hide_pages is I believe it only executes after the page loads with all “pages” in the left sidebar – thus on page load there’s a flicker of all the available pages before hiding them.
Essentially, there will be a page or two that we only want the dev team to know about the existence of them…thus why the flicker is an issue. C-suite will start asking questions about why they can’t get access
Lots of dependencies on this one. Please let me know if I can clarify anything. I am just posting one of the main code blocks located at the top of my Main.py file. This is the first thing in the .py file.
# Check authentication when user lands on the home page. authenticate.set_st_state_vars() if not st.session_state.get("authenticated", None): st.session_state["authenticated"] = False hide_pages( [ "Collect", "Sign", "Dupers", "WIP", ] ) authenticate.button_login() else: if 'non_dev' in st.session_state["user_cognito_groups"]: hide_pages( [ "WIP", ] ) elif 'dev' in st.session_state['user_cognito_groups']: hide_pages(  ) st.sidebar.success("Select a demo above.") authenticate.button_logout()
If applicable, please provide the steps we should take to reproduce the error or specified behavior.
I’d expect it to hide pages (if possible) before they get rendered.
Pages are hidden only after flickering/loading on the page.
- Streamlit version: 1.24.0
- Python version: 3.9.16
- OS version: Mac
- Browser version: Brave
mysql-connector-python streamlit~=1.24.0 streamlit_extras SQLAlchemy~=1.4.35 sqlmodel~=0.0.8 boto3~=1.26.126 pandas~=1.4.4 APScheduler~=3.10.1 plotly~=5.14.1 pytest~=7.2.1 numpy~=1.23.5 python-dateutil~=2.8.2 python-dotenv~=1.0.0 st-pages~=0.4.1