Implement support for user consent #4

Manually merged
ansv7779 merged 13 commits from user-consent into main 2025-04-25 10:22:44 +02:00
2 changed files with 19 additions and 0 deletions
Showing only changes of commit e79387bc2e - Show all commits

View File

@ -3,8 +3,12 @@ package se.su.dsv.oauth2;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.simple.JdbcClient; import org.springframework.jdbc.core.simple.JdbcClient;
import org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationConsentService;
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationConsentService;
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService; import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository;
@Configuration @Configuration
@Profile("!embedded") @Profile("!embedded")
@ -18,4 +22,12 @@ public class PersistentConfiguration {
public OAuth2AuthorizationService authorizationService(JdbcClient jdbcClient) { public OAuth2AuthorizationService authorizationService(JdbcClient jdbcClient) {
return new SerializingJDBCOAuth2AuthorizationService(jdbcClient); return new SerializingJDBCOAuth2AuthorizationService(jdbcClient);
} }
@Bean
public OAuth2AuthorizationConsentService authorizationConsentService(
JdbcOperations jdbcOperations,
RegisteredClientRepository registeredClientRepository)
{
return new JdbcOAuth2AuthorizationConsentService(jdbcOperations, registeredClientRepository);
}
} }

View File

@ -0,0 +1,7 @@
CREATE TABLE oauth2_authorization_consent
(
registered_client_id varchar(100) NOT NULL,
principal_name varchar(200) NOT NULL,
authorities varchar(1000) NOT NULL,
PRIMARY KEY (registered_client_id, principal_name)
);