😍 UPGRADED: Simple Authentication for Streamlit Apps

Does this remember that the user is authenticated even after manual refresh? I cloned the repo and its authentication user but on a manual refresh of the web page it log me out. I did a simple code using Firebase and was able to authenticate the user but have a similar issue on browser refresh.

@ankmishra04 - Yes, with the latest cookies feature, it should survive a refresh.

Hello rahul-psych.
Would you share your implementation with streamlit.secret with me?
I plan to share my app with streamlit share, so I’d like to implement the built-in structures of streamlit for my secrets.

@asehmi : Many thanks for your work. You saved me a lot of work.

Regards Sven

1 Like

Hi,

I’ve updated this solution to use the latest version of Streamlit and improved the Airtable integration. Note, it supports SQLite as well. Extensive documentation is included in the readme.

GitHub

Enjoy!
Arvindra

1 Like

First off, thank you. This solution is very useful. However…

I downloaded the zip file from Github and extracted all the files into my directory.
Changed the env.sample to .env without any edits.
Installed requirements from the requirements text but it failed to find pycryptodome==3.18.1 so I just installed pycryptodome. Version is 3.21.0

streamlit run admin.py works in that the page opens but I am not able to create a user. I get the error message:
Trapped exception
‘NoneType’ object has no attribute ‘encode’
I can view users but the passwords display as hashed.

streamlit run app.py works and I can log in using the admin account provided. If I select super user then I can edit the database and all functions work. I can create and edit users. Viewing users still displays passwords as hashed.

What can I do to have the admin.py file work?
Is it possible to have the passwords display in plain text as shown in the .gif demo?

When entering information into any form, username or password, after pressing enter the cursor does not move to the next field. Is this typical for Streamlit pages?

I do have a login page though so thanks for that! Any assistance is greatly appreciated.

1 Like

Will have a quick look soon. I haven’t touched this app for a while. It’s best practice not to allow anyone (admins included) to see passwords, so I don’t think I’ll be doing that. You can yourself though remove all encryption by modifying the code.

:heart_eyes: UPGRADED: Simple Authentication for Streamlit Apps

A simple username/password database authentication solution for Streamlit

I’m building an intranet (in-house) app for a client. They want secure, database-backed login with username/password and very low user admin overhead.

I wrote a login service back in 2021 that might fit the bill. So I used Claude Code to review the old codebase and ended up rewriting the persistent cookies support with server-side session tokens as the client-side version never worked reliably. I upgraded and removed unnecessary packages, and added some new features and hardened the auth flows.

From another project where I was using SendGrid, I had the idea to add self-service user signup with email PIN verification (just because it would be easy to do with Claude).

The SQLite backend support had always been seamless. And if you want Airtable instead, just flip a switch, add a couple of small tables in your workspace, provide Airtable keys in .env, and you’re set!

I also made it package-installable (just because it would be easy to do with Claude). This means that once downloaded there is no friction using it as a library (st_auth_simple) in your own Streamlit apps.

If you want an extremely simple username/password auth solution for your Streamlit apps, ideally suited for:

  • Single deployments — Not designed for distributed/multi-server deployments (session tokens are server-local)
  • Trusted networks — Assumes users are on a trusted network (no additional encryption between browser and server)
  • Without MFA — Single-factor authentication only (username/password + session token)
  • Admin password resets — Use admin.py to change user passwords

… then head over to my GitHub repo and grab it.

Arvindra