Skip to content

Commit

Permalink
spring boot 2 -> 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jksolbakken committed Jul 19, 2023
1 parent eacba37 commit 061a203
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ val kotlinVersion = "1.9.0"
val freemarkerVersion = "2.3.32"
val kotestVersion = "5.6.2"
val bouncyCastleVersion = "1.70"
val springBootVersion = "2.7.13"
val springBootVersion = "3.1.1"
val reactorTestVersion = "3.4.24"
val ktorVersion = "2.3.2"

Expand Down
12 changes: 5 additions & 7 deletions src/test/java/examples/java/springboot/login/OAuth2LoginApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import java.io.IOException;

import static org.springframework.security.config.Customizer.withDefaults;

@SpringBootApplication
public class OAuth2LoginApp {
public static void main(String[] args) throws IOException {
Expand All @@ -41,13 +43,9 @@ static class SecurityConfiguration {

@Bean
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
return http
.authorizeExchange()
.anyExchange().authenticated()
.and()
.oauth2Login()
.and()
.build();
return http.authorizeExchange(exchanges -> exchanges.anyExchange().authenticated())
.oauth2Login(withDefaults())
.build();
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
Expand Down Expand Up @@ -39,12 +40,9 @@ class SecurityConfiguration {

@Bean
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
return http
.authorizeExchange()
.anyExchange().authenticated()
.and()
.oauth2ResourceServer(ServerHttpSecurity.OAuth2ResourceServerSpec::jwt)
.build();
return http.authorizeExchange(exchanges -> exchanges.anyExchange().authenticated())
.oauth2ResourceServer(oauth2 -> oauth2.jwt(Customizer.withDefaults()))
.build();
}

@Bean
Expand Down

0 comments on commit 061a203

Please sign in to comment.