28 lines
742 B
Python
28 lines
742 B
Python
from functools import wraps
|
|
from flask import request, jsonify
|
|
from app.utils.logger import logger
|
|
from app.config import Config
|
|
|
|
|
|
|
|
VALID_APP_ID = Config.VALID_APP_ID
|
|
|
|
def require_app_id(f):
|
|
"""Decorator to enforce App-ID validation."""
|
|
@wraps(f)
|
|
def decorated_function(*args, **kwargs):
|
|
app_id = request.headers.get("App-ID")
|
|
|
|
if not app_id:
|
|
logger.error("Unauthorized access: Missing App-ID.")
|
|
return jsonify({"message": "Invalid request"}), 400
|
|
|
|
|
|
if app_id != VALID_APP_ID:
|
|
logger.error(f"Unauthorized access: Invalid App-ID {app_id}.")
|
|
return jsonify({"message": "Invalid request"}), 400
|
|
|
|
return f(*args, **kwargs)
|
|
|
|
return decorated_function
|