[OIDC] fix auth_time to use the actual authorizing session#211
Open
24c02 wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes OIDC auth_time so ID tokens use the specific identity session that authorized the OAuth grant, rather than guessing from the identity’s newest active session.
Changes:
- Adds
Current.identity_sessionand sets it fromApplicationController. - Stamps OAuth access grants with
source_session_idand patches ID token generation to use that session. - Adds request specs and an
identity_sessionfactory covering auth-time behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
app/controllers/application_controller.rb |
Sets current request identity session before other callbacks. |
app/models/current.rb |
Adds request-local current identity session storage. |
config/initializers/doorkeeper_openid_connect.rb |
Reads auth/reauth session state from Current.identity_session. |
config/initializers/doorkeeper_oidc_patches.rb |
Threads source session from authorization grant into ID token auth_time. |
db/migrate/20260328000001_add_source_session_id_to_oauth_access_grants.rb |
Adds source session reference to OAuth grants. |
db/schema.rb |
Reflects the new grant column and foreign key. |
spec/factories/identity_sessions.rb |
Adds identity session factory for specs. |
spec/requests/oidc_auth_time_spec.rb |
Adds OIDC auth_time request and config block specs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,6 @@ | |||
| class AddSourceSessionIdToOAuthAccessGrants < ActiveRecord::Migration[8.0] | |||
| def change | |||
| add_column :oauth_access_grants, :source_session_id, :bigint | |||
Comment on lines
+15
to
+17
| Rails.application.config.to_prepare do | ||
| # Stamp source_session_id on the grant at authorization time | ||
| Doorkeeper::OAuth::Authorization::Code.prepend(Module.new do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
more of a doozy than i woulda thought!