ciyidogan commited on
Commit
de463c8
·
verified ·
1 Parent(s): 70429fe

Update admin_routes.py

Browse files
Files changed (1) hide show
  1. admin_routes.py +0 -50
admin_routes.py CHANGED
@@ -17,29 +17,6 @@ from pydantic import BaseModel, Field
17
  import httpx
18
 
19
  from config_provider import ConfigProvider
20
- from utils import log
21
-
22
- # ===================== JWT Config =====================
23
- def get_jwt_config():
24
- """Get JWT configuration based on environment"""
25
- # Check if we're in HuggingFace Space
26
- if os.getenv("SPACE_ID"):
27
- # Cloud mode - use secrets from environment
28
- jwt_secret = os.getenv("JWT_SECRET")
29
- if not jwt_secret:
30
- log("⚠️ WARNING: JWT_SECRET not found in environment, using fallback")
31
- jwt_secret = "flare-admin-secret-key-change-in-production" # Fallback
32
- else:
33
- # On-premise mode - use .env file
34
- from dotenv import load_dotenv
35
- load_dotenv()
36
- jwt_secret = os.getenv("JWT_SECRET", "flare-admin-secret-key-change-in-production")
37
-
38
- return {
39
- "secret": jwt_secret,
40
- "algorithm": os.getenv("JWT_ALGORITHM", "HS256"),
41
- "expiration_hours": int(os.getenv("JWT_EXPIRATION_HOURS", "24"))
42
- }
43
 
44
  # ===================== Constants & Config =====================
45
  security = HTTPBearer()
@@ -140,33 +117,6 @@ class APIUpdate(BaseModel):
140
  class TestRequest(BaseModel):
141
  test_type: str # "all", "ui", "backend", "integration", "spark"
142
 
143
- # ===================== Auth Helpers =====================
144
- def create_token(username: str) -> str:
145
- """Create JWT token for user"""
146
- config = get_jwt_config()
147
- expiry = datetime.now(timezone.utc) + timedelta(hours=config["expiration_hours"])
148
-
149
- payload = {
150
- "sub": username,
151
- "exp": expiry,
152
- "iat": datetime.now(timezone.utc)
153
- }
154
-
155
- return jwt.encode(payload, config["secret"], algorithm=config["algorithm"])
156
-
157
- def verify_token(credentials: HTTPAuthorizationCredentials = Depends(security)) -> str:
158
- """Verify JWT token and return username"""
159
- token = credentials.credentials
160
- config = get_jwt_config()
161
-
162
- try:
163
- payload = jwt.decode(token, config["secret"], algorithms=[config["algorithm"]])
164
- return payload["sub"]
165
- except jwt.ExpiredSignatureError:
166
- raise HTTPException(status_code=401, detail="Token expired")
167
- except jwt.InvalidTokenError:
168
- raise HTTPException(status_code=401, detail="Invalid token")
169
-
170
  # ===================== Auth Endpoints =====================
171
  @router.post("/login", response_model=LoginResponse)
172
  async def login(request: LoginRequest):
 
17
  import httpx
18
 
19
  from config_provider import ConfigProvider
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  # ===================== Constants & Config =====================
22
  security = HTTPBearer()
 
117
  class TestRequest(BaseModel):
118
  test_type: str # "all", "ui", "backend", "integration", "spark"
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  # ===================== Auth Endpoints =====================
121
  @router.post("/login", response_model=LoginResponse)
122
  async def login(request: LoginRequest):