I’m building an OAuth 2.0 authorization server using Spring Security OAuth2. I’ve configured the following beans:
@Bean
public OAuth2AuthorizationService authorizationService() {
return new JdbcOAuth2AuthorizationService(jdbcTemplate, registeredClientRepository);
}
@Bean
public RegisteredClientRepository registeredClientRepository() {
return new JdbcRegisteredClientRepository(jdbcTemplate);
}
@Bean
public OAuth2AuthorizationConsentService authorizationConsentService() {
return new JdbcOAuth2AuthorizationConsentService(jdbcTemplate, registeredClientRepository);
}
I’m using JDBC to interact with the database. However, I’m unclear about how the JDBC components determine which database to connect to and where the OAuth 2.0-related data is stored.
My Questions:
- Database Configuration: How does JdbcRegisteredClientRepository know which database to use for managing registered clients? Do I need to explicitly configure a DataSource or rely on Spring Boot’s auto-configuration?
- Data Storage: Where are the authorization codes, access tokens, refresh tokens, and authorization consents stored? Are they persisted in a specific table or collection, and how does JDBC interact with this storage?
- Custom Implementations: Is it necessary to create custom implementations of RegisteredClientRepository, OAuth2AuthorizationService, and OAuth2AuthorizationConsentService to customize data storage or retrieval?
1