Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace python-jose with PyJWT #227

Merged
merged 1 commit into from
Sep 28, 2017
Merged

Replace python-jose with PyJWT #227

merged 1 commit into from
Sep 28, 2017

Conversation

sirosen
Copy link
Member

@sirosen sirosen commented Sep 28, 2017

Inspired in part by the discovery that a python-jose dependency, pycrypto, can't install on macOS 10.13.
python-jose advertises that it can support cryptography as a backend, but there's no install method which chooses that crypto lib -- you'd need to manually install cryptography and install python-jose without resolving its dependencies. pyjwt[crypto] works out of the box.

This may enable us to make globus-sdk[jwt] the default install, and make the jwt extra empty. It depends on whether or not the cross-platform promise of cryptography lives up to its name.

Update requirement/optional dependency spec to state globus-sdk[jwt], no mention of python-jose (obviously), but less obviously no mention of pyjwt or cryptography.

Some implementation details:

  • pyjwt does not decode JWKs into RSA keys internally -- but it provides a facility to do this
  • pyjwt does not validate the at_hash claim; we're dropping this validation, and relying on signature and audience validation as good enough
  • get the valid signing algos from the OIDC conf and pass them to pyjwt; pyjwt will then pull the used algo from the id_token and match it against this list (currently RS512 only)
    • Had to update a mock to support this

Once we have this, we can discuss next steps (release v1.2.1 of the SDK with it, or maybe try having it install on appveyor). There's also an interesting interplay between pyjwt[crypto]->cryptography and globus-cli[delegate-proxy]->cryptography which we should discuss/explore.

@sirosen sirosen added bug Something isn't working correctly enhancement New feature or improvement portability/compatiblity labels Sep 28, 2017
You may install supported versions of ``python-jose`` by install the SDK with
its ``globus_sdk[jwt]`` extra. Simply specify ``globus_sdk[jwt]`` in your
dependencies.
install ``globus_sd[jwt]``. This extra target includes dependencies which we
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo (globus_sd)

Replace python-jose with pyjwt+cryptography.

Update requirement/optional dependency spec to state `globus-sdk[jwt]`,
no mention of python-jose (obviously), but less obviously no mention of
pyjwt or cryptography.

`globus-sdk[jwt]` extra now specfies pyjwt[crypto], which installs pyjwt
and cryptography.

Some implementation details:
- pyjwt does not decode JWKs into RSA keys internally -- but it
  provides a facility to do this
- pyjwt does not validate the `at_hash` claim; we're dropping this
  validation, and relying on signature and audience validation as good
  enough
- get the valid signing algos from the OIDC conf and pass them to pyjwt;
  pyjwt will then pull the used algo from the id_token and match it
  against this list (currently RS512 only)
  - Had to update a mock to support this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly enhancement New feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants