cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Databricks Apps (Streamlit) - How to Implement Proper Logout Functionality?

maninegi05
New Contributor II

We have built a Databricks App using Streamlit and are looking for a way to implement a proper logout functionality.

Currently, we built Logout functionality where we can clear the Streamlit session state and client-side cookies. However, the Databricks authentication session remains active, and reopening the app automatically signs the user back in without prompting for authentication.

At the moment, the only way the user is logged out is when the Databricks access token/session expires.

  • Is there a supported way to completely terminate the Databricks authentication session from within a Databricks App?
  • Can we force users to re-authenticate after clicking Logout?
  • Has anyone implemented a reliable logout mechanism for Streamlit-based Databricks Apps?

I would appreciate any guidance or best practices from the community.

1 REPLY 1

emma_s
Databricks Employee
Databricks Employee

Hi,

At the moment this is not a supported feature, you may want to raise it as a feautre request via your account team.

Having said that there are a few things you could try to get a near but not perfect experience. Here are some options for you to explore:

  1. Combine a soft logout (clear session state, block UI) with shortened token TTLs. This would involve creating a is logged_in_user state in your streamlit app and then setting it from the logout button. You could then have some kind of logged out page in your app. You could then try reducing the TTL of the token, however the docs for this are mostly around third party applications so I can't guarantee this will definitely work for the app. Docs for this are here. You would also need to be an account admin to the second part.
  2. If your organisation uses Azure AD / Entra ID (or another IdP), you can configure Conditional Access policies with session lifetime limits or sign-in frequency requirements, in conjunction with the sign out workaround. This maybe the best way. 

I hope this helps with some ideas.


Thanks,

Emma