mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
parent
cf7a20e1b7
commit
b42f8a620b
@ -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,7 +29,8 @@ 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'):
|
||||
if len(auth_header) > 1:
|
||||
if auth_header[0].strip().lower().replace(':', '') in token_keys:
|
||||
token = auth_header[1]
|
||||
break
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user