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

[Issue #3193] Use the KID value in login gov token validation #3283

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

chouinar
Copy link
Collaborator

Summary

Fixes #3193

Time to review: 5 mins

Changes proposed

Rather than iterate over all public keys from login.gov - instead directly use the one with the same KID (key ID)

Context for reviewers

The KID is the Key ID, in the public endpoint from an OAuth server that gives you a list of keys the ID should be present there, and the header for a given token will have the KID as well. However these weren't guaranteed in the OAuth spec so I waited to assume they existed until I tested with real login.gov - they do exist.

Quite a bit of structure needed to be reorganized with this as the way we also structure the public keys went from a list to a dict. There was a lot of assumed failure cases if no key was found that worked that were removed and now the logic is a bit more directly:

  • If a public key can't be found refresh the public keys
  • If a public key is found, validate with it
  • Otherwise error

We also no longer need to account for the "failed validation, but assume we used the wrong key" scenario since we'll have the exact key.

Additional information

Everything continues to work uneventfully locally, the KID is set (always issuer1) in both places.

@chouinar chouinar requested a review from mdragon as a code owner December 18, 2024 16:48
@chouinar chouinar merged commit e72c729 into main Dec 19, 2024
4 checks passed
@chouinar chouinar deleted the chouinar/3193-key-id branch December 19, 2024 17:57
doug-s-nava pushed a commit that referenced this pull request Dec 30, 2024
## Summary
Fixes #3193 

### Time to review: __5 mins__

## Changes proposed
Rather than iterate over all public keys from login.gov - instead
directly use the one with the same KID (key ID)

## Context for reviewers
The KID is the Key ID, in the public endpoint from an OAuth server that
gives you a list of keys the ID should be present there, and the header
for a given token will have the KID as well. However these weren't
guaranteed in the OAuth spec so I waited to assume they existed until I
tested with real login.gov - they do exist.

Quite a bit of structure needed to be reorganized with this as the way
we also structure the public keys went from a list to a dict. There was
a lot of assumed failure cases if no key was found that worked that were
removed and now the logic is a bit more directly:
* If a public key can't be found refresh the public keys
* If a public key is found, validate with it
* Otherwise error

We also no longer need to account for the "failed validation, but assume
we used the wrong key" scenario since we'll have the exact key.

## Additional information
Everything continues to work uneventfully locally, the KID is set
(always `issuer1`) in both places.
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.

Use the KID value in the login gov token validation logic
2 participants