Skip to content

Commit 930bf19

Browse files
authored
Merge pull request #26 from IdentityPython/quote_plus_rm
Removed quote_plus from ClientSecretBasic credential creation.
2 parents 9bde482 + dab212f commit 930bf19

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

src/idpyoidc/client/client_auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def _get_authentication_token(self, request, service, **kwargs):
122122
passwd = self._get_passwd(request, service, **kwargs)
123123
user = self._get_user(service, **kwargs)
124124

125-
credentials = "{}:{}".format(quote_plus(user), quote_plus(passwd))
125+
credentials = f"{user}:{passwd}"
126126
return base64.urlsafe_b64encode(credentials.encode("utf-8")).decode("utf-8")
127127

128128
@staticmethod
@@ -191,7 +191,7 @@ def construct(self, request, service=None, http_args=None, **kwargs):
191191

192192
_token = self._get_authentication_token(request, service, **kwargs)
193193

194-
http_args["headers"]["Authorization"] = "Basic {}".format(_token)
194+
http_args["headers"]["Authorization"] = f"Basic {_token}"
195195

196196
self.modify_request(request, service)
197197

tests/test_client_06_client_authn.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test_quote():
8181

8282
assert (
8383
http_args["headers"]["Authorization"] == "Basic "
84-
"Nzk2ZDhmYWUtYTQyZi00ZTRmLWFiMjUtZDYyMDViNmQ0ZmEyOk1LRU0lMkZBN1BrbjdKdVUwTEFjeHlIVkt2d2RjenN1Z2FQVTBCaWVMYjRDYlFBZ1FqJTJCeXBjYW5GT0NiMCUyRkZBNWg="
84+
'Nzk2ZDhmYWUtYTQyZi00ZTRmLWFiMjUtZDYyMDViNmQ0ZmEyOk1LRU0vQTdQa243SnVVMExBY3h5SFZLdndkY3pzdWdhUFUwQmllTGI0Q2JRQWdRait5cGNhbkZPQ2IwL0ZBNWg='
8585
)
8686

8787

@@ -93,15 +93,10 @@ def test_construct(self, entity):
9393
csb = ClientSecretBasic()
9494
http_args = csb.construct(request, _service)
9595

96-
credentials = "{}:{}".format(quote_plus("A"), quote_plus("white boarding pass"))
97-
98-
assert http_args == {
99-
"headers": {
100-
"Authorization": "Basic {}".format(
101-
base64.urlsafe_b64encode(credentials.encode("utf-8")).decode("utf-8")
102-
)
103-
}
104-
}
96+
_authz = http_args["headers"]["Authorization"]
97+
assert _authz.startswith("Basic ")
98+
_token = _authz.split(" ",1)[1]
99+
assert base64.urlsafe_b64decode(_token) == b'A:white boarding pass'
105100

106101
def test_does_not_remove_padding(self):
107102
request = AccessTokenRequest(code="foo", redirect_uri="http://example.com")

tests/test_client_12_client_auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_quote():
6161

6262
assert (
6363
http_args["headers"]["Authorization"] == "Basic "
64-
"Nzk2ZDhmYWUtYTQyZi00ZTRmLWFiMjUtZDYyMDViNmQ0ZmEyOk1LRU0lMkZBN1BrbjdKdVUwTEFjeHlIVkt2d2RjenN1Z2FQVTBCaWVMYjRDYlFBZ1FqJTJCeXBjYW5GT0NiMCUyRkZBNWg="
64+
'Nzk2ZDhmYWUtYTQyZi00ZTRmLWFiMjUtZDYyMDViNmQ0ZmEyOk1LRU0vQTdQa243SnVVMExBY3h5SFZLdndkY3pzdWdhUFUwQmllTGI0Q2JRQWdRait5cGNhbkZPQ2IwL0ZBNWg='
6565
)
6666

6767

@@ -73,7 +73,7 @@ def test_construct(self, entity):
7373
csb = ClientSecretBasic()
7474
http_args = csb.construct(request, _token_service)
7575

76-
credentials = "{}:{}".format(quote_plus("A"), quote_plus("white boarding pass"))
76+
credentials = "{}:{}".format("A", "white boarding pass")
7777

7878
assert http_args == {
7979
"headers": {

tests/test_client_25_cc_oauth2_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_token_get_request(self):
4040
assert _info["url"] == "https://example.com/token"
4141
assert _info["body"] == "grant_type=client_credentials"
4242
assert _info["headers"] == {
43-
"Authorization": "Basic Y2xpZW50X2lkOmFub3RoZXIrcGFzc3dvcmQ=",
43+
"Authorization": "Basic Y2xpZW50X2lkOmFub3RoZXIgcGFzc3dvcmQ=",
4444
"Content-Type": "application/x-www-form-urlencoded",
4545
}
4646

0 commit comments

Comments
 (0)