Skip to content

fix(persistence): replace in-memory stores with JDBC-backed repositories#4

Merged
stupidly-logical merged 2 commits intomainfrom
fix/persistence
Apr 4, 2026
Merged

fix(persistence): replace in-memory stores with JDBC-backed repositories#4
stupidly-logical merged 2 commits intomainfrom
fix/persistence

Conversation

@stupidly-logical
Copy link
Copy Markdown
Owner

Summary

  • Replaces InMemoryRegisteredClientRepository with JdbcRegisteredClientRepository
  • Replaces implicit in-memory token store with JdbcOAuth2AuthorizationService and JdbcOAuth2AuthorizationConsentService
  • Replaces InMemoryUserDetailsManager with JdbcUserDetailsManager
  • Configures spring.sql.init to load all required Spring Security JDBC schemas on startup
  • Seeds test data only when records don't already exist (idempotent startup)

Fixes

Issues #7, #8, #9 from the production checklist.

Test plan

  • Server starts and initialises all 4 JDBC schemas against H2
  • Client credentials flow works after restart (client persisted in DB)
  • Authorization code flow works after restart (token persisted in DB)
  • User login works after restart (users persisted in DB)
  • Re-starting the server does not duplicate test data

🤖 Generated with Claude Code

- Use JdbcRegisteredClientRepository for client registrations (survives restart)
- Use JdbcOAuth2AuthorizationService for tokens and authorization codes
- Use JdbcOAuth2AuthorizationConsentService for user consents
- Use JdbcUserDetailsManager for user accounts
- Configure spring.sql.init to load Spring Security schemas on startup
- Add spring.jpa.defer-datasource-initialization=true so schemas init before Hibernate
- Seed test data only when not already present

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… errors

spring.sql.init schemas (users, registered-client, etc.) are not yet applied
when @bean factory methods run. Moving userExists/findByClientId calls into
ApplicationRunner beans ensures they execute after full context initialization,
including spring.sql.init.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@stupidly-logical stupidly-logical merged commit 307d59c into main Apr 4, 2026
2 checks passed
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.

1 participant