GraphQl 0.11.18.1 - better api_token initialization + menu fixes
Some checks are pending
docker / docker_dev (push) Waiting to run

This commit is contained in:
jokob-sk
2024-11-18 12:16:49 +11:00
parent 76d1ec46a6
commit 69d41f2ed4
2 changed files with 12 additions and 10 deletions

View File

@@ -17,14 +17,16 @@ app = Flask(__name__)
# Retrieve API token and port
graphql_port_value = get_setting_value("GRAPHQL_PORT")
api_token_value = get_setting_value("API_TOKEN")
# Endpoint for GraphQL queries
@app.route("/graphql", methods=["POST"])
def graphql_endpoint():
# Check for API token in headers
token = request.headers.get("Authorization")
if token != f"Bearer {api_token_value}":
incoming_header_token = request.headers.get("Authorization")
api_token_value = get_setting_value("API_TOKEN")
if incoming_header_token != f"Bearer {api_token_value}":
mylog('verbose', [f'[graphql_server] Unauthorized access attempt'])
return jsonify({"error": "Unauthorized"}), 401