starflow / PASSWORD_AUTH_SETUP.md
leoeric's picture
Add password authentication for users without HF accounts
7f796c3

A newer version of the Gradio SDK is available: 6.2.0

Upgrade

Password Protection Setup (No HF Account Required)

βœ… Solution: Gradio Built-in Authentication

Good news: You don't need to build your own frontend! Gradio has built-in password protection that works without Hugging Face accounts.

How It Works

  • Users visit your Space URL
  • They see a login screen (username/password)
  • No Hugging Face account needed!
  • Simple and secure

Setup Steps

Step 1: Update app.py

The code is already updated! Just change the password:

demo.launch(
    auth=("starflow", "your-password-here"),  # Change this!
    share=False
)

Step 2: Set Your Password

  1. Edit app.py in your Space (or locally and push)
  2. Change: "your-password-here" to your actual password
  3. Save and push

Step 3: Share Access

Option A: Single Username/Password

auth=("starflow", "my-secure-password")
  • Everyone uses same login
  • Simple to share

Option B: Multiple Users

auth=[
    ("user1", "password1"),
    ("user2", "password2"),
    ("user3", "password3")
]
  • Different login for each person
  • More control

Usage

  1. Make Space Public (so anyone can access the URL)

    • Settings β†’ Visibility β†’ Public
    • Or keep Private (only collaborators see it)
  2. Share the Space URL:

  3. Users visit URL:

    • See login screen
    • Enter username/password
    • No HF account needed!
    • Access granted βœ…

Security Tips

  • βœ… Use strong passwords
  • βœ… Change password regularly
  • βœ… Don't share password publicly
  • βœ… Use different passwords for different users (if using multiple)

Alternative: Environment Variables (More Secure)

For better security, use environment variables:

import os

username = os.getenv("STARFLOW_USERNAME", "starflow")
password = os.getenv("STARFLOW_PASSWORD", "default-password")

demo.launch(auth=(username, password))

Then set in Space Settings β†’ Variables:

  • STARFLOW_USERNAME = your-username
  • STARFLOW_PASSWORD = your-password

Benefits

βœ… No HF account needed - Users just need password βœ… Simple - Built into Gradio βœ… Secure - Password protected βœ… Easy to manage - Change password anytime βœ… No custom frontend - Uses existing Gradio UI

Summary

You DON'T need to build your own frontend!

Just:

  1. Add password to app.py
  2. Make Space Public (or keep Private + share URL)
  3. Share URL + password with users
  4. Done! βœ