vhr1007 commited on
Commit
88bbe7d
1 Parent(s): bcd2179
Files changed (2) hide show
  1. config.py +1 -0
  2. utils/auth_x.py +7 -1
config.py CHANGED
@@ -5,3 +5,4 @@ QDRANT_URL = os.getenv('QDRANT_URL')
5
  QDRANT_ACCESS_TOKEN = os.getenv('QDRANT_ACCESS_TOKEN')
6
  OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
7
  JWKS_URL = os.getenv('JWKS_URL')
 
 
5
  QDRANT_ACCESS_TOKEN = os.getenv('QDRANT_ACCESS_TOKEN')
6
  OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
7
  JWKS_URL = os.getenv('JWKS_URL')
8
+ X_API_KEY = os.getenv('X_API_KEY') # Replace with your actual API key
utils/auth_x.py CHANGED
@@ -1,7 +1,13 @@
1
  from fastapi import Header, HTTPException
 
 
 
2
 
3
  def x_api_key_auth(x_api_key: str = Header(...)):
4
- expected_api_key = "your_expected_api_key" # Replace with your actual API key
 
 
5
  if x_api_key != expected_api_key:
6
  raise HTTPException(status_code=401, detail="Invalid API Key")
 
7
  return True
 
1
  from fastapi import Header, HTTPException
2
+ import os
3
+ import logging
4
+ from config import X_API_KEY
5
 
6
  def x_api_key_auth(x_api_key: str = Header(...)):
7
+ logging.info("Validating x-api-key")
8
+ #api_key = os.getenv('X_API_KEY')
9
+ expected_api_key = X_API_KEY # Replace with your actual API key
10
  if x_api_key != expected_api_key:
11
  raise HTTPException(status_code=401, detail="Invalid API Key")
12
+ logging.info("x-api-key is valid")
13
  return True