claude-os/docs/guides/AUTH_SETUP.md
Claude f6a1d6b417
🗂️ ORGANIZE: Reorganize root directory structure
Moved 25 files from root to organized subdirectories while keeping
essential scripts (install.sh, setup.sh, start*.sh, stop*.sh) in root.

## Changes:

### New Directory Structure:
- Created `/scripts/` for utility scripts
- Created `/docs/guides/` for user guides
- Created `/docs/development/` for dev documentation
- Created `/docs/archive/` for historical/legacy docs

### Moved Files:

**To `/scripts/` (7 files):**
- backup_claude_os.sh
- restore_claude_os.sh
- run_tests.sh
- setup_native.sh
- start_mcp_server.sh
- start_redis_workers.sh
- entrypoint.sh

**To `/docs/guides/` (7 files):**
- AUTH_SETUP.md
- BACKUP_RESTORE_GUIDE.md
- HOOK_SETUP_QUICK_START.md
- SHARING_GUIDE.md
- START_SCRIPTS_GUIDE.md
- PORTS_GUIDE.md
- WHAT_IS_CLAUDE_OS.md

**To `/docs/development/` (4 files):**
- COMPREHENSIVE_REVIEW.md
- SECURITY_FIXES.md
- CLAUDE_OS_DEVELOPER_GUIDE.md
- PROJECT_SETUP_AND_COMMANDS.md

**To `/docs/archive/` (10 files):**
- HYBRID_INDEXING_COMPLETE.md
- INITIALIZE_PROJECT_HOOKS_FIX.md
- INSTALL_ENHANCEMENTS.md
- INSTALL_FIXES.md
- PISTN_TEST_RESULTS.md
- SESSION_SUMMARY.md
- TEST_COVERAGE.md
- TEST_RESULTS.md
- TESTING_STATUS.md
- README_TESTING.md

### Updated References:

**Fixed broken documentation links in:**
- docs/QUICK_REFERENCE.md
- docs/PRODUCTION_DEPLOYMENT.md
- docs/SCRIPTS_GUIDE.md
- docs/development/SECURITY_FIXES.md
- docs/guides/BACKUP_RESTORE_GUIDE.md
- docs/development/CLAUDE_OS_DEVELOPER_GUIDE.md
- tests/TESTING_GUIDE.md
- tests/TEST_COVERAGE.md

**Script references updated to:**
- `./scripts/backup_claude_os.sh`
- `./scripts/restore_claude_os.sh`
- `./scripts/run_tests.sh`
- `./scripts/setup_native.sh`
- `./scripts/start_mcp_server.sh`
- `./scripts/start_redis_workers.sh`

### Remaining in Root (9 essential files):
- install.sh
- setup.sh
- start.sh
- start_all_services.sh
- stop_all_services.sh
- restart_services.sh
- README.md
- CLAUDE.md
- requirements.txt (+ GEMINI_DIAGRAM_PROMPT.md)

## Benefits:
✅ Cleaner root directory (9 files vs 34 files)
✅ Organized documentation by purpose
✅ Scripts grouped in dedicated directory
✅ Essential startup commands still in root
✅ All references updated and verified
✅ No broken links

Version: 2.0.2
2025-11-04 21:34:26 +00:00

4.7 KiB

Claude OS Authentication Setup

Simple email/password authentication to keep strangers out of your Claude OS frontend.

Features

✅ Optional Authentication - Disabled by default, enable when needed ✅ Environment-based - No database required for user management ✅ JWT Tokens - 7-day token expiration ✅ Secure - Bcrypt password hashing ✅ Simple - Single user account via environment variables

Quick Start

1. Enable Authentication

Set environment variables in your .env file or server environment:

# Required: Email for login
CLAUDE_OS_EMAIL=admin@example.com

# Option 1: Plain password (development only - will be hashed automatically)
CLAUDE_OS_PASSWORD=your_secure_password_here

# Option 2: Pre-hashed password (recommended for production)
CLAUDE_OS_PASSWORD_HASH=$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5hhA82jdg8jpu

# Optional: Custom secret key for JWT (auto-generated if not set)
CLAUDE_OS_SECRET_KEY=your-super-secret-key-min-32-chars

2. Generate Password Hash (Production)

For production, use a pre-hashed password instead of plain text:

# Install dependencies first
cd ~/Projects/claude-os
source venv/bin/activate
pip install -r requirements.txt

# Generate hash
python3 -c "from passlib.context import CryptContext; print(CryptContext(schemes=['bcrypt']).hash('your_password_here'))"

Copy the output and use it as CLAUDE_OS_PASSWORD_HASH in your .env file.

3. Restart Claude OS

# Local (Mac)
./stop.sh
./start.sh

# Production Server
sudo systemctl restart claude-os

4. Login

Visit your Claude OS frontend:

Use the email and password you configured.

Production Deployment

Server Environment Variables

Add to /opt/claude-os/.env:

CLAUDE_OS_EMAIL=admin@pistn.com
CLAUDE_OS_PASSWORD_HASH=$2b$12$xyz...  # Generated hash
CLAUDE_OS_SECRET_KEY=your-32-char-secret

Restart the service:

sudo systemctl restart claude-os

Disable Authentication

To disable authentication (open access):

# Remove or comment out these variables in .env:
# CLAUDE_OS_EMAIL=...
# CLAUDE_OS_PASSWORD=...
# CLAUDE_OS_PASSWORD_HASH=...

Restart Claude OS. The frontend will allow access without login.

How It Works

Backend (FastAPI)

  • /api/auth/login - Login endpoint, returns JWT token
  • /api/auth/me - Get current user info
  • /api/auth/status - Check if authentication is enabled

Frontend (React)

  • Login Page - Beautiful gradient login form
  • Auth Context - Manages authentication state
  • Protected Routes - Automatically redirects to login if not authenticated
  • Token Storage - JWT stored in localStorage (7-day expiration)

Security Features

✅ Bcrypt hashing - Industry-standard password encryption ✅ JWT tokens - Stateless authentication ✅ Automatic expiration - Tokens expire after 7 days ✅ HTTPS recommended - Use SSL in production ✅ No database needed - Single user, environment-based

Troubleshooting

"Authentication is not configured"

You haven't set the CLAUDE_OS_EMAIL environment variable. Set it and restart.

"Incorrect email or password"

Check your .env file:

  • Email matches exactly (case-sensitive)
  • If using CLAUDE_OS_PASSWORD, make sure it's correct
  • If using CLAUDE_OS_PASSWORD_HASH, regenerate the hash

Login page doesn't appear

Make sure your Claude OS frontend is running:

# Local development
cd frontend
npm run dev

# Production (should be served by Nginx)
curl http://localhost:5173

Token expired

Tokens last 7 days. Just login again to get a new token.

Multiple Users

This system is designed for single-user access. For multiple users:

  1. Simple approach: Share one account with your team
  2. Advanced approach: Extend the auth system to use a database (requires custom implementation)

For most teams deploying Claude OS internally, a single shared account is sufficient since it's:

  • Behind your firewall
  • For trusted team members only
  • Just to keep strangers out (not enterprise-grade auth)

Security Best Practices

Development (Local)

CLAUDE_OS_EMAIL=dev@localhost
CLAUDE_OS_PASSWORD=dev123

Fine for local development. Password is hashed automatically.

Production (Server)

CLAUDE_OS_EMAIL=admin@yourcompany.com
CLAUDE_OS_PASSWORD_HASH=$2b$12$xyz...  # Pre-hashed
CLAUDE_OS_SECRET_KEY=randomly-generated-32-char-secret

✅ Use hashed passwords ✅ Use strong secret keys ✅ Use HTTPS/SSL ✅ Rotate passwords periodically


Questions? Check the main Claude OS README or open an issue on GitHub.