-
Notifications
You must be signed in to change notification settings - Fork 893
Use cache store for Rack session to prevent OmniAuth callback overflow #1577
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Use the Rails cache store (Redis in production) for the framework-level | ||
| # Rack session. The application's own user authentication is handled by | ||
| # the database-backed Session model (`_session_token`); this session is | ||
| # only used by middleware such as OmniAuth during the OIDC callback flow. | ||
| # | ||
| # Storing it in the cookie (Rails' default) overflows the 4KB limit when | ||
| # OmniAuth writes the full auth hash for IdPs that return many group | ||
| # claims. See: https://github.com/we-promise/sure/issues/1571 | ||
| Rails.application.config.session_store :cache_store, | ||
| key: "_sure_session", | ||
| expire_after: 1.hour, | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| httponly: true, | ||
| secure: Rails.env.production? | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cache-backed session makes multi-step OIDC state volatile. Line 9 shifts session data to Redis-backed cache; values like 🤖 Prompt for AI Agents
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re volatile state under cache_store: this is a valid consideration but I'd argue it's outside the scope of this fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That said, the core concern in the original comment hasn't been addressed by those changes: the null_store fallback guards dev/test environments, but in production the cache store is Redis, and a Redis restart or LRU eviction can silently drop an in-flight session during the OAuth round-trip or an MFA step. The TTL being 1 hour reduces the window but doesn't eliminate it. The specific risks remain:
If Redis is configured with
If option 1 is already covered by your infrastructure/ops runbook, would you like me to open a follow-up issue to track the documentation requirement? 🧠 Learnings used |
||
Uh oh!
There was an error while loading. Please reload this page.