mkhorasani / Streamlit-Authenticator

A secure authentication module to validate user credentials in a Streamlit application.
Apache License 2.0
1.38k stars 229 forks source link

No authentication based on cookie #77

Closed DominikZabron closed 11 months ago

DominikZabron commented 11 months ago

I implemented all the instructions from the readme and they just work fine, however, when I reload the app (the cookie is still present, I can see it on the st.session_state.init together with _xsrf), but it don't trigger automatic login.

Which piece of code do I miss to trigger automatic login based on a cookie?

DominikZabron commented 11 months ago

I think putting authenticator._check_cookie() might be enough, is there any better way?

mkhorasani commented 11 months ago

Please ensure your cookie_expiry_days is greater than 0, if that's not already the case.

DominikZabron commented 11 months ago

Cookie expiry_days: 30.

I have multipage app, I need to switch page once for the _check_cookie() to work. I try to understand what is different on first load.

DominikZabron commented 11 months ago

Ok, my solution was to explicitly call _check_cookie() as the top auth operation. I suppose something weird is happening on the session_state, so the order of operations matter, I think it's possible that if "authentication_status" not in st.session_state; st.session_state["authentication_status"] = None or similar create some race condition.