Skip to content

Commit e208e4e

Browse files
committed
fix: remove query and fragment from htu url. See #1
1 parent 9f9fcf1 commit e208e4e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

solid_client_credentials/dpop_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import datetime
22
import math
33
from typing import Optional
4+
from urllib.parse import urlsplit
45
from uuid import uuid4
56

67
import jwt
@@ -53,7 +54,7 @@ def request_access_token(
5354

5455
def create_dpop_header(url: str, method: str, key: jwk.JWK) -> str:
5556
payload = {
56-
"htu": url,
57+
"htu": urlsplit(url)._replace(query="", fragment="").geturl(),
5758
"htm": method.upper(),
5859
"jti": str(uuid4()),
5960
"iat": math.floor(datetime.datetime.now(tz=datetime.timezone.utc).timestamp()),

tests/test_auth.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,20 @@ def can_make_authenticated_request(expect, random_css_account: CssAcount):
2020
private_url = f"{random_css_account.pod_base_url}profile/"
2121
res = requests.get(private_url, auth=auth, timeout=5000)
2222
expect(res.status_code) == 200
23+
24+
def can_make_request_with_query_param(expect, random_css_account: CssAcount):
25+
credentials = get_client_credentials(random_css_account)
26+
issuer = random_css_account.css_base_url
27+
28+
token_provider = DpopTokenProvider(
29+
issuer_url=issuer,
30+
client_id=credentials.client_id,
31+
client_secret=credentials.client_secret,
32+
)
33+
auth = SolidClientCredentialsAuth(token_provider)
34+
35+
# should remove query params
36+
# https://datatracker.ietf.org/doc/html/rfc9449#section-4.2
37+
private_url = f"{random_css_account.pod_base_url}profile/?somekey=removeme"
38+
res = requests.get(private_url, auth=auth, timeout=5000)
39+
expect(res.status_code) == 200

0 commit comments

Comments
 (0)