Fix OAuth 2 handler to support retrieving parameters from other places; various OAuth client (such as the Go library) send the values in the request body or even the Auth header
This commit is contained in:
parent
91b464d0de
commit
fb8e718c44
3 changed files with 35 additions and 14 deletions
16
util/headers.py
Normal file
16
util/headers.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
import base64
|
||||
|
||||
def parse_basic_auth(header_value):
|
||||
""" Attempts to parse the given header value as a Base64-encoded Basic auth header. """
|
||||
|
||||
if not header_value:
|
||||
return None
|
||||
|
||||
parts = header_value.split(' ')
|
||||
if len(parts) != 2 or parts[0].lower() != 'basic':
|
||||
return None
|
||||
|
||||
try:
|
||||
return base64.b64decode(parts[1])
|
||||
except ValueError:
|
||||
return None
|
Reference in a new issue