bigwolfe commited on
Commit
085e790
·
1 Parent(s): 95e364f

Update auth middleware

Browse files
backend/src/api/middleware/auth_middleware.py CHANGED
@@ -9,6 +9,8 @@ from fastapi import Header, HTTPException, status
9
 
10
  from ...models.auth import JWTPayload
11
  from ...services.auth import AuthError, AuthService
 
 
12
 
13
  auth_service = AuthService()
14
 
@@ -38,6 +40,17 @@ def get_auth_context(
38
  Raises HTTPException if the header is missing/invalid.
39
  """
40
  if not authorization:
 
 
 
 
 
 
 
 
 
 
 
41
  raise _unauthorized("Authorization header required")
42
 
43
  scheme, _, token = authorization.partition(" ")
 
9
 
10
  from ...models.auth import JWTPayload
11
  from ...services.auth import AuthError, AuthService
12
+ from ...services.config import get_config
13
+ from datetime import datetime, timezone
14
 
15
  auth_service = AuthService()
16
 
 
40
  Raises HTTPException if the header is missing/invalid.
41
  """
42
  if not authorization:
43
+ # Check for No-Auth mode (Hackathon/Demo)
44
+ config = get_config()
45
+ if config.enable_noauth_mcp:
46
+ # Create a dummy payload for demo user
47
+ payload = JWTPayload(
48
+ sub="demo-user",
49
+ iat=int(datetime.now(timezone.utc).timestamp()),
50
+ exp=int(datetime.now(timezone.utc).timestamp()) + 3600
51
+ )
52
+ return AuthContext(user_id="demo-user", token="no-auth", payload=payload)
53
+
54
  raise _unauthorized("Authorization header required")
55
 
56
  scheme, _, token = authorization.partition(" ")