Skip to content

Commit 3658fdc

Browse files
fix: client_auth: unquote clientID and secret with Basic auth
With Basic auth, clientID and secret should be URI-encoded before used as username and password to form the Basic auth header: https://datatracker.ietf.org/doc/html/rfc6749#section-2.3.1 Existing OpenIDConnect implementations follow the standard and encode the clientID and secret ... and the client authentication for the token endpoint then fails with either `pyop.exceptions.InvalidClientAuthentication: Incorrect client_secret` or `pyop.exceptions.InvalidClientAuthentication: client_id '1621892763.....%2B%2F' unknown` - when characters like '+' or '/' are used in either the clientID or secret. This happens only for `client_secret_basic` - but not for `client_secret_post`. Fix this by explicitly URI-decoding the clientID and secret extracted from the Basic auth header (but only in this flow).
1 parent 63b55fd commit 3658fdc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/pyop/client_authentication.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import base64
22
import logging
3+
from urllib.parse import unquote
34

45
from .exceptions import InvalidClientAuthentication
56

@@ -35,7 +36,7 @@ def verify_client_authentication(clients, parsed_request, authz_header=None):
3536
auth = base64.urlsafe_b64decode(credentials.encode('utf-8')).decode('utf-8')
3637
except UnicodeDecodeError as e:
3738
raise InvalidClientAuthentication('Could not userid/password from authorization header'.format(authz_scheme))
38-
client_id, client_secret = auth.split(':')
39+
client_id, client_secret = [unquote(part) for part in auth.split(':')]
3940
else:
4041
raise InvalidClientAuthentication('Unknown scheme in authorization header, {} != Basic'.format(authz_scheme))
4142
elif 'client_id' in parsed_request:

0 commit comments

Comments
 (0)