summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkadabusha <47604788+kadabusha@users.noreply.github.com>2022-07-19 14:25:20 +0300
committerGitHub <noreply@github.com>2022-07-19 17:25:20 +0600
commit0bef0fbff5c245668578a43774d8620bdba4a6f7 (patch)
tree86104acd0442f69d242dfc929d1e44220fb15e3e
parentc8fda69f09bc293960c141288633fbd1399e0b2b (diff)
downloadpyjwt-0bef0fbff5c245668578a43774d8620bdba4a6f7.tar.gz
Fix for headers disorder issue (#721)
* Fix for headers disorder issue Related issue #715 * Added comment with reference to issue Needed to trigger tests once more time. * Fix for hardcoded value in docs after adding sort to jwt/api_jws.py * Removed unneeded comment - issue #721
-rw-r--r--README.rst2
-rw-r--r--docs/index.rst2
-rw-r--r--jwt/api_jws.py3
3 files changed, 4 insertions, 3 deletions
diff --git a/README.rst b/README.rst
index 49aa77a..432631e 100644
--- a/README.rst
+++ b/README.rst
@@ -42,7 +42,7 @@ Usage
>>> import jwt
>>> encoded = jwt.encode({"some": "payload"}, "secret", algorithm="HS256")
>>> print(encoded)
- eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzb21lIjoicGF5bG9hZCJ9.Joh1R2dYzkRvDkqv3sygm5YyK8Gi4ShZqbhK2gxcs2U
+ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzb21lIjoicGF5bG9hZCJ9.4twFt5NiznN84AWoo1d7KO1T_yoc0Z6XOpOVswacPZg
>>> jwt.decode(encoded, "secret", algorithms=["HS256"])
{'some': 'payload'}
diff --git a/docs/index.rst b/docs/index.rst
index 63e6794..5cdf565 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -32,7 +32,7 @@ Example Usage
>>> import jwt
>>> encoded_jwt = jwt.encode({"some": "payload"}, "secret", algorithm="HS256")
>>> print(encoded_jwt)
- eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzb21lIjoicGF5bG9hZCJ9.Joh1R2dYzkRvDkqv3sygm5YyK8Gi4ShZqbhK2gxcs2U
+ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzb21lIjoicGF5bG9hZCJ9.4twFt5NiznN84AWoo1d7KO1T_yoc0Z6XOpOVswacPZg
>>> jwt.decode(encoded_jwt, "secret", algorithms=["HS256"])
{'some': 'payload'}
diff --git a/jwt/api_jws.py b/jwt/api_jws.py
index 75f826d..90206c9 100644
--- a/jwt/api_jws.py
+++ b/jwt/api_jws.py
@@ -132,8 +132,9 @@ class PyJWS:
# True is the standard value for b64, so no need for it
del header["b64"]
+ # Fix for headers misorder - issue #715
json_header = json.dumps(
- header, separators=(",", ":"), cls=json_encoder
+ header, separators=(",", ":"), cls=json_encoder, sort_keys=True
).encode()
segments.append(base64url_encode(json_header))