urstark commited on
Commit
add8fe7
·
1 Parent(s): df715f7

Hardened dual-header auth and fixed deployment scope for HF Space

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -63,9 +63,10 @@ def require_auth(f):
63
 
64
  auth = request.headers.get("Authorization")
65
  secret = request.headers.get("X-Secret-Token")
66
- token = secret or (auth.split(" ")[1] if auth and auth.startswith("Bearer ") else None)
67
 
68
- if not token or token != SECRET_TOKEN:
 
69
  raise HTTPException(status_code=401, detail="Unauthorized")
70
  return await f(*args, **kwargs)
71
  return decorated
 
63
 
64
  auth = request.headers.get("Authorization")
65
  secret = request.headers.get("X-Secret-Token")
66
+ bearer = auth.split(" ")[1] if auth and auth.startswith("Bearer ") else None
67
 
68
+ # Enforce dual-header authentication for strict internal security
69
+ if bearer != SECRET_TOKEN or secret != SECRET_TOKEN:
70
  raise HTTPException(status_code=401, detail="Unauthorized")
71
  return await f(*args, **kwargs)
72
  return decorated