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 two OpenID Connect key-pairs #11626

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

mitchellhenke
Copy link
Contributor

🛠 Summary of changes

Following up on #11612, this adds a secondary OpenID Connect key-pair that gives us the ability to do a zero downtime rotation. The two externally facing elements that require changes are:

  • Our /api/openid_connect/certs route which relying parties use to verify our signed payloads (token, security events)
  • Our verification of the deprecated id_token_hint parameter in OIDC Logout

Previously, we did not allow "missing" app artifacts, but we may not always have a secondary key-pair, so the class was modified to allow it (though it still defaults to not allowing it).

@mitchellhenke mitchellhenke requested review from Sgtpluck and a team December 11, 2024 22:33
Comment on lines +97 to +100
_matching_cert = [
AppArtifacts.store.oidc_primary_public_key,
AppArtifacts.store.oidc_secondary_public_key,
].compact.find do |key|
Copy link
Contributor

Choose a reason for hiding this comment

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

having an unused variable here has me 👀

would it make sense to break this into two methods, or to just ditch the variable entirely? Or switch to .each with a return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah, I don't think the assignment is doing anything. I was originally considering using the matching cert to log which key was used, but I decided against it since logout is deprecated. I removed the assignment.

lib/app_artifacts.rb Outdated Show resolved Hide resolved
key_from_response = JWT::JWK.import(json[:keys].first).public_key
public_key = AppArtifacts.store.oidc_public_key
# Primary key should be first
primary_key_from_response = JWT::JWK.import(json[:keys].first).public_key
Copy link
Contributor

Choose a reason for hiding this comment

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

The .keys[1] jumped out at me, maybe we could destructuring to avoid hardcoding indexes?

Suggested change
primary_key_from_response = JWT::JWK.import(json[:keys].first).public_key
primary_key_from_response, secondary_key_from_response = json[:keys].map do |key|
JWT::JWK.import(key).public_key
end

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