-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_auth.py
More file actions
70 lines (56 loc) · 2.1 KB
/
Copy pathsetup_auth.py
File metadata and controls
70 lines (56 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
"""Setup script for authentication system."""
import psycopg2
import sys
import logging
from job_search_storage import DB_CONFIG
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def setup_auth_database():
"""Set up the authentication database schema."""
try:
# Connect to database
conn = psycopg2.connect(**DB_CONFIG)
conn.autocommit = True
with conn.cursor() as cursor:
# Read and execute the schema
with open('create_users_schema.sql', 'r') as f:
schema_sql = f.read()
cursor.execute(schema_sql)
logger.info("✅ Authentication database schema created successfully")
except Exception as e:
logger.error(f"❌ Error setting up authentication database: {e}")
return False
finally:
if 'conn' in locals():
conn.close()
return True
def install_dependencies():
"""Install required dependencies for authentication."""
import subprocess
try:
logger.info("Installing authentication dependencies...")
subprocess.check_call([
sys.executable, "-m", "pip", "install",
"python-jose[cryptography]", "passlib[bcrypt]", "python-multipart"
])
logger.info("✅ Authentication dependencies installed successfully")
return True
except Exception as e:
logger.error(f"❌ Error installing dependencies: {e}")
return False
if __name__ == "__main__":
print("StackScout Authentication Setup")
print("=" * 40)
# Install dependencies
if not install_dependencies():
sys.exit(1)
# Setup database
if not setup_auth_database():
sys.exit(1)
print("\n✅ Authentication system setup complete!")
print("\nNext steps:")
print("1. Start the server: python stackscout_web.py")
print("2. Test authentication: python test_auth.py")
print("3. Register at: http://localhost:8000/auth/register")
print("4. Login at: http://localhost:8000/auth/login")