Skip to content

Commit a9cc756

Browse files
authored
Merge branch 'master' into klenotiw/add-stale-and-waiting-workflows
2 parents b280c62 + e7bef94 commit a9cc756

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
name: Python ${{ matrix.version }}
77
strategy:
88
matrix:
9-
version: [3.6, 3.10.0]
9+
version: [3.7, 3.10.0]
1010

1111
steps:
1212
- name: Checkout

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
== Unreleased
22

3+
== Version 12.0.1
4+
- Allow up to 10 seconds clock skew to avoid `ImmatureSignatureError`
5+
([#609](https://github.com/Shopify/shopify_python_api/pull/609))
6+
37
== Version 12.0.0
48
- Update API version with 2022-04 release, remove API version 2021-07 ([#591](https://github.com/Shopify/shopify_python_api/pull/591))
59

shopify/session_token.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
ALGORITHM = "HS256"
1515
PREFIX = "Bearer "
1616
REQUIRED_FIELDS = ["iss", "dest", "sub", "jti", "sid"]
17+
LEEWAY_SECONDS = 10
1718

1819

1920
class SessionTokenError(Exception):
@@ -54,6 +55,9 @@ def _decode_session_token(session_token, api_key, secret):
5455
secret,
5556
audience=api_key,
5657
algorithms=[ALGORITHM],
58+
# AppBridge frequently sends future `nbf`, and it causes `ImmatureSignatureError`.
59+
# Accept few seconds clock skew to avoid this error.
60+
leeway=LEEWAY_SECONDS,
5761
options={"require": REQUIRED_FIELDS},
5862
)
5963
except jwt.exceptions.PyJWTError as exception:

shopify/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "12.0.0"
1+
VERSION = "12.0.1"

test/session_token_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_raises_if_token_authentication_header_is_not_bearer(self):
4848
self.assertEqual("The HTTP_AUTHORIZATION_HEADER provided does not contain a Bearer token", str(cm.exception))
4949

5050
def test_raises_jwt_error_if_session_token_is_expired(self):
51-
self.payload["exp"] = timestamp((datetime.now() + timedelta(0, -10)))
51+
self.payload["exp"] = timestamp((datetime.now() + timedelta(0, -11)))
5252

5353
with self.assertRaises(session_token.SessionTokenError) as cm:
5454
session_token.decode_from_header(self.build_auth_header(), api_key=self.api_key, secret=self.secret)
@@ -103,3 +103,8 @@ def test_returns_decoded_payload(self):
103103
)
104104

105105
self.assertEqual(self.payload, decoded_payload)
106+
107+
def test_allow_10_seconds_clock_skew_in_nbf(self):
108+
self.payload["nbf"] = timestamp((datetime.now() + timedelta(seconds=10)))
109+
110+
session_token.decode_from_header(self.build_auth_header(), api_key=self.api_key, secret=self.secret)

0 commit comments

Comments
 (0)