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

Add support for pyjwt leeway #790

Merged
merged 1 commit into from
Jul 20, 2023
Merged

Conversation

sirosen
Copy link
Member

@sirosen sirosen commented Jul 19, 2023

See also: globus/globus-cli#820


On the surface, this may look like a potentially incompatible change because we remove leeway from the passed jwt_params. However, those are passed to options and leeway isn't a supported value there for pyjwt, so the change is in effect strictly additive.

pyjwt source has a comment indicating that leeway might be added to options in the future (it would make sense), along with values we control like audience. For the time being, however, this makes sense as a mechanism for passing leeway for JWT handling in the SDK.

Because the same leeway is used for the iat, nbf, and exp claims, we can check that leeway is passed correctly by using it to make a very old exp claim pass validation in our tests.

A new default is set for leeway of 0.5s internally. This is not part of the decode_id_token docs -- kept as an implementation detail -- but it makes the default behavior slightly more tolerant of clock drift. As such, this part of the change is documented as a fix in the changelog, whereas the rest is an addition.


📚 Documentation preview 📚: https://globus-sdk-python--790.org.readthedocs.build/en/790/

On the surface, this may look like a potentially incompatible change
because we remove `leeway` from the passed `jwt_params`. However,
those are passed to `options` and `leeway` isn't a supported value
there for pyjwt, so the change is in effect strictly additive.

pyjwt source has a comment indicating that `leeway` might be added to
`options` in the future (it would make sense), along with values we
control like `audience`. For the time being, however, this makes sense
as a mechanism for passing `leeway` for JWT handling in the SDK.

Because the same `leeway` is used for the `iat`, `nbf`, and `exp`
claims, we can check that `leeway` is passed correctly by using it to
make a very old `exp` claim pass validation in our tests.

A new default is set for `leeway` of 0.5s internally. This is not part
of the `decode_id_token` docs -- kept as an implementation detail --
but it makes the default behavior slightly more tolerant of clock
drift. As such, this part of the change is documented as a fix in the
changelog, whereas the rest is an addition.
@sirosen sirosen merged commit e34974f into globus:main Jul 20, 2023
13 checks passed
@sirosen sirosen deleted the support-jwt-leeway branch July 20, 2023 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants