[chore]: Separated Simbrella to bank calls
This commit is contained in:
@@ -1,8 +1,20 @@
|
||||
# app/middlewares/auth.py
|
||||
from flask import request, jsonify
|
||||
from flask import request
|
||||
from app.helpers.response_helper import ResponseHelper
|
||||
from app.utils.logger import logger
|
||||
|
||||
# Define a valid API key (store securely in environment variables)
|
||||
VALID_API_KEY = "your-secure-api-key"
|
||||
|
||||
def require_api_key():
|
||||
"""Middleware to check if API key is present"""
|
||||
"""Middleware to check if API key is present and valid."""
|
||||
api_key = request.headers.get("X-API-KEY")
|
||||
|
||||
if not api_key:
|
||||
return jsonify({"error": "Missing API key"}), 403
|
||||
logger.error("Unauthorized access: Missing API key.")
|
||||
return ResponseHelper.unauthorized("Missing API key")
|
||||
|
||||
if api_key != VALID_API_KEY:
|
||||
logger.error("Unauthorized access: Invalid API key.")
|
||||
return ResponseHelper.unauthorized("Invalid API key")
|
||||
|
||||
return None
|
||||
Reference in New Issue
Block a user