Setting up password for new multipageapp

Hi all,

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()

with the introduction of new support for multipage - Introducing multipage apps! ๐Ÿ“„

i am not able to use login to the whole app, if i do this -

if name == โ€œmainโ€:
if check_password():
run()

it only restricts the check to main/default page. Any ideas on how i can set up authentication with this new feature for the app as a whole ?

2 Likes

We have the same problemโ€ฆ

Hi Guys, read this topics:

Tell me if worked.

Hi @Yashwant_Akash_Lal,

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 all, it works !! I created a utility file with check password function and used it in the pages i need.

1 Like