Skip to content

Commit 9bde482

Browse files
authored
Merge pull request #25 from IdentityPython/fix-op-parse-basic-auth
Fix parsing of Basic HTTP Authentication Scheme on the OP side
2 parents 7e50501 + 9143ddf commit 9bde482

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
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
"""

tests/test_server_17_client_authn.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,6 @@ def test_basic_auth_wrong_label():
459459

460460

461461
def test_basic_auth_wrong_token():
462-
_token = "{}:{}:foo".format(client_id, client_secret)
463-
token = as_unicode(base64.b64encode(as_bytes(_token)))
464-
with pytest.raises(ValueError):
465-
basic_authn("Basic {}".format(token))
466-
467462
_token = "{}:{}".format(client_id, client_secret)
468463
with pytest.raises(ValueError):
469464
basic_authn("Basic {}".format(_token))

tests/test_server_20d_client_authn.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,6 @@ def test_basic_auth_wrong_label():
413413

414414

415415
def test_basic_auth_wrong_token():
416-
_token = "{}:{}:foo".format(client_id, client_secret)
417-
token = as_unicode(base64.b64encode(as_bytes(_token)))
418-
with pytest.raises(ValueError):
419-
basic_authn("Basic {}".format(token))
420-
421416
_token = "{}:{}".format(client_id, client_secret)
422417
with pytest.raises(ValueError):
423418
basic_authn("Basic {}".format(_token))

0 commit comments

Comments
 (0)