mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
GraphQl 0.11.18.1 - better api_token initialization + menu fixes
Some checks are pending
docker / docker_dev (push) Waiting to run
Some checks are pending
docker / docker_dev (push) Waiting to run
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user