I was using streamlit to build a multipage app. I needed to add simple authentication (username/password) for logging in to app. Since i was using the previous multipage model, i was doing something like this in my main script -
if check_password():
# Add all your application here
app.add_page(“page1”, page1.app)
app.add_page(“page2”, page2.app)
# The main app
app.run()
I was discussing about this situation in another topic.
As the code of the examples of Authentication without SSO Guide save the information in App Sesion State, you only need to define once the funcion and call in each page the auth function. Just a simple example
main_page.py
import streamlit as st
from password_check import check_password
if check_password():
st.write("#Hello 👋")
pages/01_page.py
import streamlit as st
from password_check import check_password
if check_password():
st.write("#Page 1 👋")
In this way, all elements that are inside check_password() will have an password verification before showing the data.
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.