Skip to content

Commit 03a2f5c

Browse files
authored
Merge pull request #100 from bookernath/jwt
Refine JWT checks
2 parents f476e0a + 84f5706 commit 03a2f5c

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

bigcommerce/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def oauth_verify_payload(cls, signed_payload, client_secret):
2828
return connection.OAuthConnection.verify_payload(signed_payload, client_secret)
2929

3030
@classmethod
31-
def oauth_verify_payload_jwt(cls, signed_payload, client_secret):
32-
return connection.OAuthConnection.verify_payload_jwt(signed_payload, client_secret)
31+
def oauth_verify_payload_jwt(cls, signed_payload, client_secret, client_id):
32+
return connection.OAuthConnection.verify_payload_jwt(signed_payload, client_secret, client_id)
3333

3434
def __getattr__(self, item):
3535
return ApiResourceWrapper(item, self)

bigcommerce/connection.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,16 @@ def verify_payload(signed_payload, client_secret):
230230
return loads(dc_json.decode()) if authorised else False
231231

232232
@staticmethod
233-
def verify_payload_jwt(signed_payload, client_secret):
233+
def verify_payload_jwt(signed_payload, client_secret, client_id):
234234
"""
235235
Given a signed payload JWT (usually passed as parameter in a GET request to the app's load URL)
236236
and a client secret, authenticates the payload and returns the user's data, or error on fail.
237237
"""
238-
return jwt.decode(signed_payload, client_secret, algorithms="HS256")
238+
return jwt.decode(signed_payload,
239+
client_secret,
240+
algorithms=["HS256"],
241+
audience=client_id,
242+
verify_iss=False)
239243

240244
def fetch_token(self, client_secret, code, context, scope, redirect_uri,
241245
token_url='https://login.bigcommerce.com/oauth2/token'):

0 commit comments

Comments
 (0)