Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available: 6.14.0
Authentication Setup for HF Spaces
How to Add Password Protection
Go to your Space Settings: https://huggingface.co/spaces/igriv/cryptoindex/settings
Add a Secret named
AUTH_USERSwith a JSON value:{ "alice": "password123", "bob": "secretpass456", "charlie": "mypassword789" }Save and restart your Space
Managing Users
To add new users:
- Edit the
AUTH_USERSsecret - Add new username/password pairs to the JSON
- Save (Space will auto-restart)
To remove users:
- Edit the
AUTH_USERSsecret - Remove the user's entry from the JSON
- Save
To disable authentication:
- Delete the
AUTH_USERSsecret entirely - Or set it to an empty string
Security Notes
- Passwords are stored in HF Secrets (encrypted)
- Use strong, unique passwords
- Don't share the master HF Space access
- Users only get UI access, not source code access
Alternative: File-based Auth
If you prefer, you can create a separate users.json file:
# In app.py
try:
with open('users.json', 'r') as f:
auth_dict = json.load(f)
auth_list = [(user, pwd) for user, pwd in auth_dict.items()]
except:
auth_list = None
But using HF Secrets is more secure and easier to manage.