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

PXP-6617 Remove scopes from aud claim in tokens #839

Merged
merged 34 commits into from
Jun 7, 2021
Merged

PXP-6617 Remove scopes from aud claim in tokens #839

merged 34 commits into from
Jun 7, 2021

Conversation

vpsx
Copy link
Contributor

@vpsx vpsx commented Sep 23, 2020

Remove scopes from aud claim in Fence-issued tokens. Add custom scope claim for scopes, along with custom validation. Use and validate aud claim as originally intended. (Previously, the aud claim was being used for both audiences and scopes, and Fence/authutils had custom validation logic for the aud claim.)

Greater detail in the commit messages.

For a short definition of the aud claim see here.

Requires these changes to authutils: uc-cdis/authutils#47

New Features

Breaking Changes

  • Remove scopes from "aud" claim in Fence-issued tokens. This means that in general, old tokens (minted by previous Fence releases) will not pass validation by this Fence.
  • Access tokens will still include scopes for compatibility with other microservices, but scopes are no longer guaranteed and should no longer be expected in the aud claim from this version on. ID tokens, refresh tokens, and API keys will not have scopes in the aud claim.
  • Add custom "scope" claim in tokens and put scopes there instead. Custom validation for scopes claim added in Authutils 6.0.1
  • Add issuer to "aud" claim (alongside other aud values--so when there is a Fence client involved, this means the aud claim will include both Fence's BASE_URL and the client_id)
  • Remove custom "aud" claim validation and use normal validation instead (by bumping to Authutils 6.0.1). This means checking that the aud claim contains a value that identifies the consuming service, i.e. Fence's BASE_URL.

Bug Fixes

Improvements

Dependency updates

Requires authutils 6.0.1.

Deployment changes

  • This commit includes patches to allow old style refresh tokens and API keys to pass new style validation, while issuing new style refresh tokens and API keys. Since refresh tokens and API keys have a default TTL of 30 days, stay on this tag for 30 days if possible.
  • Old access tokens will NOT work once this is deployed so active sessions may be temporarily interrupted.

@github-actions
Copy link

github-actions bot commented Sep 23, 2020

The style in this PR agrees with black. ✔️

This formatting comment was generated automatically by a script in uc-cdis/wool.

@coveralls
Copy link

coveralls commented Sep 23, 2020

Pull Request Test Coverage Report for Build 11137

  • 32 of 55 (58.18%) changed or added relevant lines in 9 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.09%) to 70.684%

Changes Missing Coverage Covered Lines Changed/Added Lines %
fence/oidc/grants/refresh_token_grant.py 4 7 57.14%
fence/resources/storage/cdis_jwt.py 3 7 42.86%
fence/jwt/validate.py 3 19 15.79%
Totals Coverage Status
Change from base Build 11098: -0.09%
Covered Lines: 6047
Relevant Lines: 8555

💛 - Coveralls

@vpsx vpsx force-pushed the fix/jwt-aud branch 2 times, most recently from b46f5cb to 69da6dd Compare September 23, 2020 21:43
@lgtm-com
Copy link

lgtm-com bot commented Sep 23, 2020

This pull request fixes 1 alert when merging 69da6dd into ed8b837 - view on LGTM.com

fixed alerts:

  • 1 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Oct 9, 2020

This pull request fixes 1 alert when merging 363a4a5 into 50ff568 - view on LGTM.com

fixed alerts:

  • 1 for Unused import

vpsx added 15 commits May 27, 2021 09:47
* Don't pass scope to audiences arg in generate_token_response
* In generate_id_token itself:
* Don't append to audiences itself; instead make a copy
* Check if client_id is None
* Don't include aud claim in token if aud is empty
* New scope arg in validate_jwt defaults to {'openid'} but allows None
* No longer use aud claim for scopes
* add separate scope claim to id, refresh tkns (already in access tkns)
* rm scopes from aud claim in all tokens
* set aud claim to client_id in all oidc tokens
* also do all of the above for user API key
* update docstrings some fence.jwt.token functions
* see TECHDEBT.md for context
* also rm unused has_oauth import
* previously passed 'openid' only to appease validation code, bc using aud for scopes
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.

4 participants