Authnyc! is a OpenID Connect client demonstration application.
Authnyc! has been tested with and currently only has pre-programmed support for integrating with Auth0 as a provider.
Python 3.12.x
-
Login to the Auth0 Dashboard
-
Select Applications > Applications
-
Select
+ Create Application
a. Name: SampleApp b. Choose an application type: Regular Web Applications c. Select Create -
Select Python for
What technology are you using for your project?
-
Select Settings
-
Update Allowed Callback URLs a. http://localhost:8501
-
Update Allowed Logout URLs a. http://localhost:8501
-
Select Save Changes
- Login to Auth0 Dashboard
- Select Applications -> Applications
- Select Create Application
- Set Application Name
- Select Machine to Machine Applications
- Select Create
- Select API
- Select the following scopes: a. read:users b. update:users c. create:users d. read:users_app_metadata e. update:users_app_metadata f. create:users_app_metadata
- Select Authorize
- Set up Python Virtual Environment (one time step)
Windows:
py -m venv .\venv
macOS:
python3 -m venv ./venv
- Activate Virtual Environment
Windows:
.\venv\Scripts\Activate.ps1
macOS:
. ./venv/bin/activate
- Install Dependencies (One time step)
Windows:
python.exe -m pip install --upgrade pip
macOS:
pip install --upgrade pip
Both: pip install -r requirements.txt
-
Run Authnyc!:
streamlit run ./src/authnyc/authnyc.py
When starting Authnyc! for the first time, a couple of forms will collect the required provider information which will be used to automatically configure the OIDC client.
To clear the configuration and start over, edit the authnyc.toml file and
set oidc_provider_configured = false
, remove the config_db.json, oidc_db.json,
and user_db.json files if they exists.
Setting up the python virtual environment is a one time step.
Windows:
py -m venv .\venv
macOS:
python3 -m venv ./venv
Windows:
.\venv\Scripts\Activate.ps1
(venv) C:\path\to\project>
macOS:
. ./venv/bin/activate
python.exe -m pip install --upgrade pip
Edit
.streamlit/config.toml
[theme] base="light" primaryColor=#0079c2 secondaryBackgroundColor=#92d3f5
Based on: https://github.com/dnplus/streamlit-oauth
Based on: https://github.com/mkhorasani/Streamlit-Authenticator/blob/main/README.md
Following the example, create a yaml backed user store with some test user accounts.
Ensure the python virtual environment is activate prior to beginning this step.
python
import streamlit_authenticator as stauth
hashed_passwords = stauth.utilities.hasher.Hasher(['password1', 'password2']).generate()
print(hashed_passwords)
Copy the hashed passwords to the creds_authenticator.yaml file to their respective accounts.
openssl rand -hex 32
Copy the result into the creds_authenticator.yaml file under cookie > key.
Edit
src/app/creds_authenticator.yaml
` cookie: expiry_days: 30 key: name: streamlit_app_authn credentials: usernames: testuser1: email: [email protected] name: Test User 1 failed_login_attempts: 0 logged_in: false password: testuser2: email: [email protected] name: Test User 2 failed_login_attempts: 0 logged_in: false password: preauthorized: emails: