21 lines
630 B
Python
21 lines
630 B
Python
from flask import request
|
|
from app.helpers.response_helper import ResponseHelper
|
|
from app.utils.logger import logger
|
|
import os
|
|
|
|
VALID_APP_IDS = os.getenv("VALID_APP_ID", "")
|
|
|
|
def require_app_id():
|
|
"""Middleware to check if App-ID is present and valid."""
|
|
app_id = request.headers.get("App-ID")
|
|
|
|
if not app_id:
|
|
logger.error("Unauthorized access: Missing App-ID.")
|
|
return ResponseHelper.unauthorized("Missing App-ID")
|
|
|
|
if app_id not in VALID_APP_IDS:
|
|
logger.error(f"Unauthorized access: Invalid App-ID {app_id}.")
|
|
return ResponseHelper.unauthorized("Invalid App-ID")
|
|
|
|
return None
|