New Library: streamlit-login-auth-ui, connect your streamlit application to a pre-built and secure Login/ Sign-Up page

Hey @Liscivia , Thank You so much for the appreciation. I agree with you. Could you please share screenshots as well? So, that it is easier for everyone to understand and contribute? Thank You so much.

1 Like

Sure!


As you can see I’ve got two diffeent pages with two different layouts set in the configurations of the page.
The only difference between the ‘Net Liquidity’ and ‘Home’ page is that the first one is set to wide, the other one to centered, the login prompt shows up differently in the two pages!

Thank you :slight_smile:

Another doubt that I have is in regards of the _secret_auth_.json file where the credentials are stored, I guess that one should be hidded when the app gets deployed, isn’t it?
I’ve placed it into my .gitignore file but now the app doesn’t read the credentials, is there a way to reference it with st.secrets to be able to deploy safely?

I fixed this by implementing this:

if LOGGED_IN != True:
    with open('style1 or style 2.css') as f:
        st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)

style1.css:

.css-1bzkvni {
    display: none;
}

style2.css :

.css-18e3th9 {
    max-width: 46em !important;
    padding-left: 1em !important;
    padding-right: 1em !important 
}
.css-1bzkvni {
    display: none;
}

On centered layout I used style 1, on wide I used style 2.
:slight_smile:

1 Like

how to disable registered user after some days of condition??

@Gauri_Prabhakar I’m sorry, is it possible to update the version of the repo on Pypi?
Just to include the Get_username function that I’d find very convenient?
Thank you

I have a PR that includes this feature. See also the app.py, sample lines are commented out.

I am not entirely sure about only to several person.

If you mean to bypass the login username and password, I have this change to just disable the widgets.

The user can just press the Login button to enter.

Example app.py

import streamlit as st
from streamlit_login_auth_ui.widgets import __login__

# When deployed in streamlit cloud or using secrets.toml locally.
# users_auth_file = st.secrets['secrets_users_auth_file']
# auth_token = st.secrets['secrets_courier_auth_token']

users_auth_file = '_secret_auth_.json'
auth_token = 'courier_auth_token'  # password reset is not supported

__login__obj = __login__(
    auth_token=auth_token,
    company_name="Shims",
    width=200,
    height=250,
    logout_button_name='Logout',
    hide_menu_bool=False,
    hide_footer_bool=False,
    lottie_url='https://assets2.lottiefiles.com/packages/lf20_jcikwtux.json',
    users_auth_file=users_auth_file,
    is_disable_login=True)

is_logged_in = __login__obj.build_login_ui()

if is_logged_in:
    st.markdown("Your Streamlit Application Begins here!")
    username = __login__obj.get_username()
    st.markdown(st.session_state)
    st.write(username)

See is_disable_login=True.

hello, I want to ask you,
in my app, I want to know the username using the get_username() but it return

AttributeError: ‘login’ object has no attribute ‘get_username’

How to overcome it>?
Thanks

The package at pypi is not updated yet. So the get_username() is not supported in pip install streamlit-login-auth-ui.

Here is one way to show the username. This is based on the updated repo.

Install normally.

pip install streamlit-login-auth-ui

and then see the following code on # Get the user name. comment.

import streamlit as st
from streamlit_login_auth_ui.widgets import __login__


if 'login' not in st.session_state:
    st.session_state.login = False


__login__obj = __login__(auth_token="courier_auth_token",
                    company_name="Shims",
                    width=200, height=250,
                    logout_button_name='Logout', hide_menu_bool=False,
                    hide_footer_bool=False,
                    lottie_url='https://assets2.lottiefiles.com/packages/lf20_jcikwtux.json')

st.session_state.login = __login__obj.build_login_ui()

if st.session_state.login:
    st.markdown("Welcome to Main page!")

    # Get the user name.
    fetched_cookies = __login__obj.cookies
    if '__streamlit_login_signup_ui_username__' in fetched_cookies.keys():
        username = fetched_cookies['__streamlit_login_signup_ui_username__']
        st.write(username)

thank you I recently try by implementing the code inside the method

could this library be integrated with firebase auth? I mean, getting an authorization token.

I’m using this plugin within a Heroku streamlit app. Where should I stored the _secret_auth_.json file? Should it really just be stored on the memory of the Heroku app? Is this secure? Is it better to maintain these secrets in a separate server, such as on AWS or GCS? If so, do you have any suggestions or links for how to do this?

Thank you for the easy and great plugin!

I have a pull request of this repository. The secret_auth.json file can be saved in deta.

I have not tried it yet with GCS but I think this is possible.

The repo owner has not replied yet. I might create this June, a new package based on this repo with some improvements and features if the owner will not comment on my pull request.

Great. Thanks for the effort and link! I’ll check it out. This actually matches our use case better too – allowing user login but not open registration. While merging clearly seems desirable, if the original author will not merge the PR, please let us know if you make a separate repo.