Skip to content

Commit a4bc090

Browse files
committed
Fix parsing of Basic HTTP Authentication Scheme on the OP side
- URL-encoding and decoding is not part of the Basic HTTP Authentication Scheme. - The user-id is not allowed to contain colons (`:`). - The password is allowed to contain colons (`:`). Quoting https://www.rfc-editor.org/rfc/rfc7617.html > To receive authorization, the client > [...] > 2. constructs the user-pass by concatenating the user-id, a single > colon (":") character, and the password, > [...] > > Furthermore, a user-id containing a colon character is invalid, as > the first colon in a user-pass string separates user-id and password > from one another; text after the first colon is part of the password. > User-ids containing colons cannot be encoded in user-pass strings. Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 7e50501 commit a4bc090

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/idpyoidc/server/client_authn.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ def basic_authn(authorization_token: str):
104104
_tok = as_bytes(authorization_token[6:])
105105
# Will raise ValueError type exception if not base64 encoded
106106
_tok = base64.b64decode(_tok)
107-
part = [unquote_plus(p) for p in as_unicode(_tok).split(":")]
108-
if len(part) == 2:
109-
return dict(zip(["id", "secret"], part))
110-
else:
107+
part = as_unicode(_tok).split(":", 1)
108+
if len(part) != 2:
111109
raise ValueError("Illegal token")
112110

111+
return dict(zip(["id", "secret"], part))
112+
113113

114114
class NoneAuthn(ClientAuthnMethod):
115115
"""

0 commit comments

Comments
 (0)