Skip to content

[OIDC] fix auth_time to use the actual authorizing session#211

Open
24c02 wants to merge 2 commits into
mainfrom
oidc-session-rework
Open

[OIDC] fix auth_time to use the actual authorizing session#211
24c02 wants to merge 2 commits into
mainfrom
oidc-session-rework

Conversation

@24c02
Copy link
Copy Markdown
Member

@24c02 24c02 commented Mar 29, 2026

more of a doozy than i woulda thought!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_session and sets it from ApplicationController.
  • Stamps OAuth access grants with source_session_id and patches ID token generation to use that session.
  • Adds request specs and an identity_session factory 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
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