Migrate OAuth state store from in-memory to Redis#24
Conversation
Agent-Logs-Url: https://github.com/poly-workshop/identra/sessions/49272a53-7a4a-43de-b5f6-1ad1af5036c1 Co-authored-by: slhmy <31381093+slhmy@users.noreply.github.com>
Agent-Logs-Url: https://github.com/poly-workshop/identra/sessions/49272a53-7a4a-43de-b5f6-1ad1af5036c1 Co-authored-by: slhmy <31381093+slhmy@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Migrates OAuth state storage from an in-process sync.Map/map implementation to Redis so OAuth flows work correctly in multi-replica deployments and across restarts.
Changes:
- Updated
oauth.StateStoreinterface to acceptcontext.Contextand return errors. - Added a Redis-backed OAuth state store with TTL-based expiry and atomic consume semantics.
- Wired the new Redis state store into
Serviceand updated OAuth call sites to propagatectxand handle errors.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| internal/infrastructure/oauth/state_store.go | Extends the StateStore interface with context + error returns; adapts the in-memory store implementation. |
| internal/infrastructure/cache/redis_oauth_state_store.go | Introduces Redis-backed StateStore using SET with TTL and Lua GET+DEL for atomic consume. |
| internal/application/identra/service.go | Instantiates and uses the Redis OAuth state store (shared Redis client), updating call sites accordingly. |
| import ( | ||
| "sync" | ||
| "time" | ||
| "context" | ||
| "sync" | ||
| "time" | ||
| ) |
There was a problem hiding this comment.
This file isn’t gofmt-formatted (imports and block indentation lost). Please run gofmt on this file so it matches the rest of the Go codebase and avoids noisy diffs/lint failures.
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "errors" | ||
| "time" | ||
|
|
||
| "github.com/poly-workshop/identra/internal/infrastructure/oauth" | ||
| goredis "github.com/redis/go-redis/v9" | ||
| ) |
There was a problem hiding this comment.
This new file isn’t gofmt-formatted (imports and indentation). Please run gofmt so it matches existing Redis cache implementations (e.g., redis_email_code_store.go) and keeps diffs readable.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/poly-workshop/identra/sessions/1181e47e-b283-40fb-a256-5038f22c2498 Co-authored-by: slhmy <31381093+slhmy@users.noreply.github.com>
Applied in 52c479d: ran |
StateStoreinterface inoauth/state_store.goto acceptcontext.Contextand return errors, update in-memory implementation accordinglyStateStoreimplementation incache/redis_oauth_state_store.goservice.goto instantiate the Redis state store and update all call sites to passctxand handle errorsExpiresAtis not populated (Redis TTL handles expiry)oauth/state_store.goandcache/redis_oauth_state_store.gonilinstead offalsefor missing keys