updated sops apis and questions generator
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user