From 94ab47c81d46534e98fe057279dee58a7a0bb5af Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Mon, 23 Jan 2023 16:15:23 -0500 Subject: [PATCH] Accept a regex for require api key origin --- libretranslate/app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libretranslate/app.py b/libretranslate/app.py index b29cce5..5f808fe 100644 --- a/libretranslate/app.py +++ b/libretranslate/app.py @@ -1,6 +1,7 @@ import io import os import tempfile +import re import uuid from functools import wraps from html import unescape @@ -236,7 +237,7 @@ def create_app(args): elif ( args.require_api_key_origin 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") if args.get_api_key_link: