diff --git a/InvenTree/InvenTree/middleware.py b/InvenTree/InvenTree/middleware.py index 86b254ac46..1a25202f23 100644 --- a/InvenTree/InvenTree/middleware.py +++ b/InvenTree/InvenTree/middleware.py @@ -21,6 +21,7 @@ logger = logging.getLogger('inventree') def get_token_from_request(request): """Extract token information from a request object.""" auth_keys = ['Authorization', 'authorization'] + token_keys = ['token', 'bearer'] token = None @@ -28,9 +29,10 @@ def get_token_from_request(request): if auth_header := request.headers.get(k, None): auth_header = auth_header.strip().lower().split() - if len(auth_header) > 1 and auth_header[0].startswith('token'): - token = auth_header[1] - break + if len(auth_header) > 1: + if auth_header[0].strip().lower().replace(':', '') in token_keys: + token = auth_header[1] + break return token