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 the OIDC at_hash claim #296

Closed
wants to merge 2 commits into from

Commits on Oct 19, 2017

  1. Add support for the OIDC at_hash claim

    Use PyJWT to compute the at_hash value for OpenID Connect:
    http://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken
    
    This makes more sense in PyJWT than its client code because of the tight
    coupling between the chosen signing algorithm and the computation of the
    at_hash. Any client code would have to jump through hoops to get this to
    work nicely based on the algorithm being fed to PyJWT.
    
    Closes jpadilla#295
    
    Primary changes:
    
    Add support for access_token=... as a param to PyJWT.encode and
    PyJWT.decode . On encode, the at_hash claim is computed and added to the
    payload. On decode, unpacks the at_hash value, raising a missing claim
    error if its missing, and compares it to a freshly computed at_hash.
    Raises a new error type if they don't match.
    Does not use the verification options dict, as it's redundant with the
    caller supplying access_token in this case.
    
    Supporting changes:
    - Add tests for the above
    - Let PyJWT and PyJWS get an algorithm object from a string as a method
    - Add a method, compute_at_hash, to PyJWT objects
    - PyJWT._validate_claims now takes the header as an arg (needed to get
      algo)
    sirosen committed Oct 19, 2017
    Configuration menu
    Copy the full SHA
    fb399e3 View commit details
    Browse the repository at this point in the history
  2. Add verify_at_hash option (default=False)

    To make it easier to enforce verification of at_hash in future major
    versions of PyJWT, add the verify_at_hash option to the implementation,
    defaulting to False. It's now necessary for callers to set
    `options={'verify_at_hash': True}` in addition to `access_token=...`,
    but it keeps backwards compatibility for users who are acting on OIDC ID
    Tokens with current versions of PyJWT.
    Whenever PyJWT 2.0 is created, this can be changed to default to True
    sirosen committed Oct 19, 2017
    Configuration menu
    Copy the full SHA
    5709301 View commit details
    Browse the repository at this point in the history