This directory contains utility scripts for managing and testing the OAuth 2.1 learning system.
Launches all three OAuth servers with proper process management and health checks.
Features:
- Staggered startup with health checks
- Graceful shutdown handling (Ctrl+C)
- Process monitoring and automatic restart
- Clear status messages and instructions
- Port availability checking
Usage:
# Start all servers
python scripts/start_all.py
# Or make it executable and run directly
./scripts/start_all.pyWhat it does:
- Starts Authorization Server on port 8081
- Starts Resource Server on port 8082
- Starts Client Application on port 8080
- Monitors all processes and restarts if needed
- Provides clear instructions for using the system
Generates bcrypt password hashes for demo accounts and provides testing utilities.
Features:
- Generate hashes for all demo accounts
- Verify hash correctness
- Output in multiple formats (Python code, JSON)
- Interactive mode for custom passwords
- Password strength validation
Usage:
# Generate demo account hashes
python scripts/hash_passwords.py
# Interactive mode for custom passwords
python scripts/hash_passwords.py --interactive
# Just verify existing hashes
python scripts/hash_passwords.py --verify-only
# Don't save output files
python scripts/hash_passwords.py --no-saveDemo Accounts:
alice/password123bob/secret456carol/mypass789
Automates the complete OAuth 2.1 flow for testing and demonstration.
Features:
- Complete OAuth 2.1 flow automation with PKCE
- Tests all demo accounts
- Step-by-step flow verification
- Detailed logging and error reporting
- Health checks for all servers
- JSON output for results
Usage:
# Test with alice account
python scripts/demo_flow.py
# Test with specific account
python scripts/demo_flow.py --username bob
# Test all demo accounts
python scripts/demo_flow.py --test-all
# Save results to file
python scripts/demo_flow.py --test-all --output results.json
# Custom server URLs
python scripts/demo_flow.py --auth-url http://localhost:9001 --resource-url http://localhost:9002Flow Steps:
- Generate PKCE challenge and authorization URL
- Request authorization page from auth server
- Authenticate user with demo credentials
- Exchange authorization code + PKCE verifier for access token
- Access protected resource with Bearer token
- Access user info endpoint
Make sure you have the required dependencies installed:
# Core dependencies (should already be installed)
pip install fastapi uvicorn httpx passlib[bcrypt] colorama
# Additional dependencies for demo automation
pip install beautifulsoup4-
Start all servers:
python scripts/start_all.py
-
In another terminal, test the flow:
python scripts/demo_flow.py --test-all
-
Generate fresh password hashes (if needed):
python scripts/hash_passwords.py
If you get "port already in use" errors:
# Check what's using the ports
lsof -i :8080 -i :8081 -i :8082
# Kill processes if needed
pkill -f uvicorn# Install missing packages
pip install httpx beautifulsoup4 'passlib[bcrypt]'# Check if servers are responding
curl http://localhost:8080/health
curl http://localhost:8081/health
curl http://localhost:8082/health- Make sure all servers are running and healthy
- Check that demo accounts are properly configured
- Verify network connectivity between components
- Check server logs for detailed error information
Scripts may create output files in scripts/output/:
demo_users.py- Python code for user storagedemo_users.json- JSON format user datauser_storage_template.py- Complete UserStore templatehash_*.py- Individual password hashesresults.json- Demo flow test results
These scripts demonstrate:
- OAuth 2.1 Security: PKCE implementation, state parameters, secure token handling
- Process Management: Multi-server coordination, health monitoring, graceful shutdown
- Password Security: bcrypt hashing, verification, strength validation
- HTTP Client Patterns: Session management, error handling, redirect following
- Testing Automation: End-to-end flow testing, multiple account validation
- Logging and Monitoring: Structured logging, flow tracing, error reporting
These scripts are designed to work with the main OAuth learning system:
- Use the same shared utilities (
src/shared/) - Follow the same logging patterns
- Support the same demo accounts
- Work with the existing server configurations
For more information about the OAuth 2.1 learning system, see the main README.md file.