Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions intuitlib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
from datetime import datetime
import random
import string
from jose import jwk
import requests
from requests.sessions import Session
import six
from requests_oauthlib import OAuth1
from jwt import PyJWKSet


from intuitlib.enums import Scopes
Expand Down Expand Up @@ -165,9 +164,8 @@ def validate_id_token(id_token, client_id, intuit_issuer, jwk_uri):
return False

message = id_token_parts[0] + '.' + id_token_parts[1]
Comment thread
Natim marked this conversation as resolved.
Outdated
keys_dict = get_jwk(id_token_header['kid'], jwk_uri)
public_key = get_jwk(id_token_header['kid'], jwk_uri)
Comment thread
Natim marked this conversation as resolved.
Outdated

public_key = jwk.construct(keys_dict)
is_signature_valid = public_key.verify(message.encode('utf-8'), id_token_signature)
return is_signature_valid

Expand All @@ -178,15 +176,14 @@ def get_jwk(kid, jwk_uri):
:param jwk_uri: JWK URI

:raises HTTPError: if response status != 200
:return: dict containing keys
:return: Algorithm with the key loaded.
"""

response = requests.get(jwk_uri)
if response.status_code != 200:
raise AuthClientError(response)
data = response.json()
keys = next(key for key in data["keys"] if key['kid'] == kid)
return keys
return PyJWKSet.from_dict(data)[kid]
Comment thread
Natim marked this conversation as resolved.
Outdated
Comment thread
Natim marked this conversation as resolved.
Outdated

def _correct_padding(val):
"""Correct padding for JWT
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
python_jose>=2.0.2
requests>=2.13.0
mock>=2.0.0
requests_oauthlib>=1.0.0
Expand All @@ -8,3 +7,4 @@ pytest>=3.8.0
pytest-cov==2.5.0
six>=1.10.0
enum-compat
pyjwt[crypto]>=2.0.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
packages=find_packages(exclude=('tests*',)),
namespace_packages=('intuitlib',),
install_requires=[
'python_jose>=2.0.2',
'pyjwt[crypto]>=2.0.0',
'requests>=2.13.0',
'requests_oauthlib>=1.0.0',
'six>=1.10.0',
Expand Down