From 5c3cf0a39253d06cacd67a370207740699da062b Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Wed, 8 Sep 2021 16:14:39 -0400 Subject: [PATCH] ReqKey check --- app/app.py | 4 ++-- app/templates/index.html | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/app.py b/app/app.py index df00f76..f62f901 100644 --- a/app/app.py +++ b/app/app.py @@ -135,9 +135,9 @@ def create_app(args): ak = json.get("api_key") else: ak = request.values.get("api_key") - + if ( - api_keys_db.lookup(ak) is None and request.headers.get("Origin") != args.require_api_key_origin + api_keys_db.lookup(ak) is None and (request.headers.get("Origin") != args.require_api_key_origin or (args.require_api_key_origin and request.headers.get("ReqKey") != "1")) ): abort( 403, diff --git a/app/templates/index.html b/app/templates/index.html index fe5ac16..426f377 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -428,6 +428,7 @@ data.append("api_key", localStorage.getItem("api_key") || ""); request.open('POST', BaseUrl + '/translate', true); + request.setRequestHeader("ReqKey", "1"); request.onload = function() { try{