1
0
mirror of https://github.com/LibreTranslate/LibreTranslate.git synced 2024-12-18 08:27:03 +02:00

Accept a regex for require api key origin

This commit is contained in:
Piero Toffanin 2023-01-23 16:15:23 -05:00
parent bf79912d2c
commit 94ab47c81d

View File

@ -1,6 +1,7 @@
import io import io
import os import os
import tempfile import tempfile
import re
import uuid import uuid
from functools import wraps from functools import wraps
from html import unescape from html import unescape
@ -236,7 +237,7 @@ def create_app(args):
elif ( elif (
args.require_api_key_origin args.require_api_key_origin
and api_keys_db.lookup(ak) is None and api_keys_db.lookup(ak) is None
and request.headers.get("Origin") != args.require_api_key_origin and not re.match(args.require_api_key_origin, request.headers.get("Origin"))
): ):
description = _("Please contact the server operator to get an API key") description = _("Please contact the server operator to get an API key")
if args.get_api_key_link: if args.get_api_key_link: