Last active
August 27, 2022 20:08
-
-
Save stefanozanella/78821e36380e4218787fd19f18f006b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
// ... | |
implementation("org.springframework.boot:spring-boot-starter-jdbc") | |
implementation("org.flywaydb:flyway-core") // Optional, but highly recommended | |
implementation("org.postgresql:postgresql") // Add the driver for your favourite database here | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
# ... | |
datasource: | |
url: jdbc:postgresql://localhost:5432/demo-app-oauth2-webhooks | |
username: stefano | |
password: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; -- src/main/resources/db/migration/V1__Add_oauth2_authorized_client_table.sql | |
CREATE TABLE oauth2_authorized_client | |
( | |
client_registration_id varchar(100) NOT NULL, | |
principal_name varchar(200) NOT NULL, | |
access_token_type varchar(100) NOT NULL, | |
access_token_value bytea NOT NULL, | |
access_token_issued_at timestamp NOT NULL, | |
access_token_expires_at timestamp NOT NULL, | |
access_token_scopes varchar(1000) DEFAULT NULL, | |
refresh_token_value bytea DEFAULT NULL, | |
refresh_token_issued_at timestamp DEFAULT NULL, | |
created_at timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, | |
PRIMARY KEY (client_registration_id, principal_name) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
class WebSecurityConfig { | |
// ... | |
@Bean | |
fun authorizedClientService( | |
jdbcOperations: JdbcOperations, | |
clientRegistrationRepository: ClientRegistrationRepository, | |
): OAuth2AuthorizedClientService = | |
JdbcOAuth2AuthorizedClientService(jdbcOperations, clientRegistrationRepository) | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment