Idea: Streamlit Sessions

Sessioned streamlit
Require a Sessioned login to your app.

session = st.login(cache_session = True, source = ['github','gitlab']) #if user revisits don't ask for login again. 
user = session.user_data

State
A rough data schema would look like this:

user:
	user_name:		conic
	user_key:		90071992547409921
	auth_platform: 	[github, gmail, streamlit_email_service] #where this key comes from. 
	ip:				123.123.123.123

Use cases:

  • I want to maintain a white_list of authorized users that is validated in app.
  • I want different users to have personalized experiences. Maybe even keys to storing or retreiving information.

Example:

authorized_keys = [90071992547409921]
settings = dict(slider_1_location = 2)

user_settings = json.load("user_settings.json")

if user.user_key in authorized_keys:
	settings["slider_1_location"] = user_settings[user.user_key]["slider_1_location"]

Thoughts? Ideas?

2 Likes

Hi @conic,
thanks for your question! Can you open a feature request for st.login? Here is the link: https://github.com/streamlit/streamlit/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=

In general, we are thinking how to add state to Streamlit. Here is a search on Discuss of all threads related to state: https://discuss.streamlit.io/search?q=state

Matteo

1 Like