cryptoindex / AUTH_SETUP.md
igriv's picture
Add configurable password authentication via HF Secrets
1fc34e1

A newer version of the Gradio SDK is available: 6.14.0

Upgrade

Authentication Setup for HF Spaces

How to Add Password Protection

  1. Go to your Space Settings: https://huggingface.co/spaces/igriv/cryptoindex/settings

  2. Add a Secret named AUTH_USERS with a JSON value:

    {
      "alice": "password123",
      "bob": "secretpass456",
      "charlie": "mypassword789"
    }
    
  3. Save and restart your Space

Managing Users

To add new users:

  1. Edit the AUTH_USERS secret
  2. Add new username/password pairs to the JSON
  3. Save (Space will auto-restart)

To remove users:

  1. Edit the AUTH_USERS secret
  2. Remove the user's entry from the JSON
  3. Save

To disable authentication:

  1. Delete the AUTH_USERS secret entirely
  2. 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.