Keycloak authentication for Streamlit
Project description
Streamlit Keycloak
Keycloak authentication inside your Streamlit app
Installation
pip install streamlit-keycloak
Usage
Creating a Keycloak component will perform authentication when the app is rendered. Credentials can be provided in the popup window. Outside of a SSO environment, you must allow popups to be able to log in.
The component returns a tuple containing the authentication state, OAuth2 token and user info respectively. If a refresh token is present, tokens are refreshed automatically. This will rerender the app.
Example
from streamlit_keycloak import keycloak
import streamlit as st
def main():
st.subheader(f"Welcome {user_info['preferred_username']}!")
st.write(f"Here is your OAuth2 token: {token}")
authenticated, token, user_info = keycloak(
url="http://localhost:8080",
realm="myrealm",
client_id="myclient",
)
st.title("Streamlit Keycloak example")
if authenticated:
main()
else:
st.write("Authenticating...")
Todo
- Logout functionality?
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
streamlit-keycloak-0.1.4.tar.gz
(422.8 kB
view hashes)
Built Distribution
Close
Hashes for streamlit_keycloak-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63b0f6c83be99380dd3834f6c83695f6315637600f48f943dc5ae5d838514ff1 |
|
MD5 | d925b5fa713624d105de495da3e0a277 |
|
BLAKE2b-256 | 8169d522d97a783f70bf7427f7d157ce4967d206e583a37996131076bdaa0d93 |