I have created a Streamlit app using the multipage functionality. So far, great experience.
Now I wondered if there is any possibility to include user roles? Is it possible to only show those pages in the navigation to which the respective user may have access? And can I restrict these pages from beeing rendered?
I have no clue how could I adress this point but maybe it is not possible at all?
About user roles: you may want to have a look at st.experimental_user, it’s a Streamlit native way (although experimental) for you to get information on the user. This is working when your app is deployed on Streamlit Cloud, and would give you user data whenever they’re signed in on Cloud, too. See the docs
About pages being hidden depending on x/y/z: currently this is not natively supported with our multipage apps. Any page in pages/*.py will be displayed in the sidebar. Now, playing with st.experimental_user, you could still show an empty page for those that don’t have access (although it’s clickable from the sidebar):
# pages/sensitive_page.py
AUTHORIZED_EMAILS = st.secrets.emails
import streamlit as st
if "email" in st.experimental_user:
if st.experimental_user.email in AUTHORIZED_EMAILS:
display_app()
else:
st.error("You are not authorized to view this page, sorry!")