- Implement secure user registration and login - Add password hashing with PBKDF2 and random salts - Create session-based authentication with secure tokens - Support user deactivation and session management - Include comprehensive unit tests for authentication - Integrate authentication demo into main application 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Main application entry point for the sandbox project.
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
from datetime import datetime
|
|
from src.auth import UserManager
|
|
|
|
def load_config():
|
|
"""Load configuration from config.json"""
|
|
try:
|
|
with open('config.json', 'r') as f:
|
|
return json.load(f)
|
|
except FileNotFoundError:
|
|
return {"debug": True, "version": "1.0.0"}
|
|
|
|
def main():
|
|
"""Main function"""
|
|
config = load_config()
|
|
print(f"Sandbox Project v{config.get('version', '1.0.0')}")
|
|
print(f"Debug mode: {config.get('debug', False)}")
|
|
print(f"Current time: {datetime.now()}")
|
|
|
|
if config.get("debug"):
|
|
print("Running in debug mode")
|
|
|
|
# Initialize authentication system
|
|
auth_manager = UserManager()
|
|
print("\n--- Authentication System Demo ---")
|
|
|
|
try:
|
|
# Register a demo user
|
|
auth_manager.register_user("demo_user", "demo@example.com", "secure_password123")
|
|
print("✓ Demo user registered successfully")
|
|
|
|
# Authenticate the user
|
|
session_token = auth_manager.authenticate("demo_user", "secure_password123")
|
|
print("✓ User authenticated successfully")
|
|
print(f"Session token: {session_token[:20]}...")
|
|
|
|
# Validate session
|
|
username = auth_manager.validate_session(session_token)
|
|
print(f"✓ Session validated for user: {username}")
|
|
|
|
except Exception as e:
|
|
print(f"✗ Authentication error: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
main() |