Move WEBAUTHN_SESSION to RUNTIME_STORE#4360
Conversation
📝 WalkthroughWalkthroughWebAuthn session persistence moved to ChangesWebAuthn runtime store migration
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant PasskeyService
participant RuntimeStoreProvider
participant RUNTIME_STORE
PasskeyService->>RuntimeStoreProvider: Store or retrieve WebAuthn session
RuntimeStoreProvider->>RUNTIME_STORE: Persist or query namespaced session
RUNTIME_STORE-->>RuntimeStoreProvider: Session data or empty result
RuntimeStoreProvider-->>PasskeyService: Return operation result
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/internal/authn/passkey/init.go`:
- Around line 23-31: Update the relevant documentation under
docs/content/guides/ to describe the Initialize passkey session-store change:
remove references to Redis/configuration-based selection, identify the shared
RUNTIME_STORE replacement, and provide migration steps for existing self-hosted
deployments moving from the WEBAUTHN_SESSION table to the RUNTIME_STORE
partition, including the updated cleanup behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e2aa1f9a-d5f4-4d7b-b4c7-4748e023451f
📒 Files selected for processing (14)
backend/cmd/server/servicemanager.gobackend/dbscripts/runtime_transient/postgres-cleanup.sqlbackend/dbscripts/runtime_transient/postgres.sqlbackend/dbscripts/runtime_transient/sqlite.sqlbackend/internal/authn/passkey/init.gobackend/internal/authn/passkey/redisClient_mock_test.gobackend/internal/authn/passkey/redis_store.gobackend/internal/authn/passkey/redis_store_test.gobackend/internal/authn/passkey/store.gobackend/internal/authn/passkey/store_constants.gobackend/internal/authn/passkey/store_test.gobackend/internal/authn/passkey/webauthn_service.gobackend/pkg/thunderidengine/providers/constants.gobackend/scripts/cleanup_runtime_transient_db.sh
💤 Files with no reviewable changes (6)
- backend/internal/authn/passkey/store_constants.go
- backend/internal/authn/passkey/redisClient_mock_test.go
- backend/internal/authn/passkey/redis_store.go
- backend/internal/authn/passkey/webauthn_service.go
- backend/dbscripts/runtime_transient/sqlite.sql
- backend/internal/authn/passkey/redis_store_test.go
| "github.com/thunder-id/thunderid/pkg/thunderidengine/providers" | ||
| ) | ||
|
|
||
| // Initialize initializes the WebAuthn authentication service. | ||
| func Initialize(entitySvc entity.EntityServiceInterface) PasskeyServiceInterface { | ||
| var store sessionStoreInterface | ||
| if config.GetServerRuntime().Config.Database.RuntimeTransient.Type == provider.DataSourceTypeRedis { | ||
| store = newRedisSessionStore(provider.GetRedisProvider()) | ||
| } else { | ||
| store = newSessionStore() | ||
| } | ||
|
|
||
| return newPasskeyService(entitySvc, store) | ||
| func Initialize( | ||
| entitySvc entity.EntityServiceInterface, | ||
| runtimeStore providers.RuntimeStoreProvider, | ||
| ) PasskeyServiceInterface { | ||
| return newPasskeyService(entitySvc, newSessionStore(runtimeStore)) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🔴 Documentation Required
This PR introduces user-facing changes that are not covered by documentation updates under docs/.
Please update the relevant documentation before merging.
Missing documentation:
- Removed Redis/config-based passkey session store selection:
Initializeno longer branches on runtime configuration to choose Redis vs. DB-backed session storage; it now always uses the shared runtime store. Document this removed configuration knob and its replacement in a configuration reference or upgrade guide (e.g.docs/content/guides/). WEBAUTHN_SESSIONtable removal /RUNTIME_STOREmigration: the dedicatedWEBAUTHN_SESSIONtable is dropped in favor of aRUNTIME_STOREpartition (backend/dbscripts/runtime_transient/postgres.sql), and the cleanup script/table list changed accordingly (backend/scripts/cleanup_runtime_transient_db.sh). Document the required migration steps for existing self-hosted deployments in an upgrade/migration guide underdocs/content/guides/.
As per path instructions: "Check whether this change introduces or modifies any of the following: ... Configuration options (YAML/TOML keys, environment variables, deployment settings) ... If ANY of the above are detected and the PR does NOT include corresponding updates under docs/ ... post a single consolidated PR-level comment."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@backend/internal/authn/passkey/init.go` around lines 23 - 31, Update the
relevant documentation under docs/content/guides/ to describe the Initialize
passkey session-store change: remove references to Redis/configuration-based
selection, identify the shared RUNTIME_STORE replacement, and provide migration
steps for existing self-hosted deployments moving from the WEBAUTHN_SESSION
table to the RUNTIME_STORE partition, including the updated cleanup behavior.
Source: Path instructions
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
7dc64d6 to
d656fe8
Compare
Purpose
Move WEBAUTHN_SESSION to RUNTIME_STORE
🔧 Summary of Breaking Changes
WEBAUTHN_SESSION table is removed and the data will be stored in the RUNTIME_STORE
💥 Impact
The data stored in the WEBAUTHN_SESSION will be lost. This is not a critical impact as it's have only the information related to the webauthn session. The users might need go through the flow again.
Approach
Related Issues
Related PRs
Checklist
breaking changelabel added.Security checks
Summary by CodeRabbit
Improvements
Database Updates
Tests