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
Built Distribution
File details
Details for the file streamlit-keycloak-0.1.4.tar.gz
.
File metadata
- Download URL: streamlit-keycloak-0.1.4.tar.gz
- Upload date:
- Size: 422.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
e2739194d83af58a7196d7881aff5e432938771afcb689eb9b8184294a6a5b05
|
|
MD5 |
08a553d66804784b56ef9e9710bdfe92
|
|
BLAKE2b-256 |
c91e702b04576aeb3ade360f7b4cd651f01a29caee92d228fd397176149d9f10
|
File details
Details for the file streamlit_keycloak-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: streamlit_keycloak-0.1.4-py3-none-any.whl
- Upload date:
- Size: 429.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
63b0f6c83be99380dd3834f6c83695f6315637600f48f943dc5ae5d838514ff1
|
|
MD5 |
d925b5fa713624d105de495da3e0a277
|
|
BLAKE2b-256 |
8169d522d97a783f70bf7427f7d157ce4967d206e583a37996131076bdaa0d93
|