updated sops apis and questions generator

This commit is contained in:
2024-09-25 21:40:08 +00:00
parent 1bfc773782
commit cd10cdaf7d
11 changed files with 84 additions and 114 deletions
+24
View File
@@ -0,0 +1,24 @@
import os
from functools import wraps
from flask import Flask, session, redirect, url_for, request, g, jsonify
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv("API_KEY")
def auth_check(func):
@wraps(func)
def decorated_function(*args, **kwargs):
auth_header = request.headers.get('Authorization')
if not auth_header or not auth_header.startswith('Bearer '):
return jsonify({"error": "Unauthorized", "message": "API key is missing or invalid."}), 401
token = auth_header.split(' ')[1]
if token != API_KEY:
return jsonify({"error": "Unauthorized", "message": "API key does not match."}), 401
g.authenticated = True
return func(*args, **kwargs)
return decorated_function