Jelajahi Sumber

Update :servlet:spring-boot:kotlin:hello-security to 7

Josh Cummings 1 bulan lalu
induk
melakukan
56be3b0776

+ 6 - 11
servlet/spring-boot/kotlin/hello-security/build.gradle.kts

@@ -1,10 +1,8 @@
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
 plugins {
     alias(libs.plugins.org.springframework.boot)
     alias(libs.plugins.io.spring.dependency.management)
-    kotlin("jvm") version "2.0.0"
-    kotlin("plugin.spring") version "2.0.0"
+    kotlin("jvm") version "2.2.0"
+    kotlin("plugin.spring") version "2.2.0"
 }
 
 repositories {
@@ -23,17 +21,14 @@ dependencies {
     implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
     implementation("org.springframework.boot:spring-boot-starter-web")
     implementation("org.thymeleaf.extras:thymeleaf-extras-springsecurity6")
+    implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
+    implementation("org.jetbrains.kotlin:kotlin-reflect")
+    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
+    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
     testImplementation("org.springframework.boot:spring-boot-starter-test")
     testImplementation("org.springframework.security:spring-security-test")
 }
 
-tasks.withType<KotlinCompile> {
-    kotlinOptions {
-        freeCompilerArgs = listOf("-Xjsr305=strict")
-        jvmTarget = "17"
-    }
-}
-
 tasks.withType<Test> {
     useJUnitPlatform()
 }

+ 1 - 1
servlet/spring-boot/kotlin/hello-security/gradle.properties

@@ -1 +1 @@
-spring-security.version=6.5.0-SNAPSHOT
+spring-security.version=7.0.0-SNAPSHOT

+ 1 - 1
servlet/spring-boot/kotlin/hello-security/src/main/kotlin/org/springframework/security/samples/config/SecurityConfig.kt

@@ -36,7 +36,7 @@ class SecurityConfig {
     @Bean
     fun filterChain(http: HttpSecurity): SecurityFilterChain {
         http {
-            authorizeRequests {
+            authorizeHttpRequests {
                 authorize("/css/**", permitAll)
                 authorize("/user/**", hasAuthority("ROLE_USER"))
             }

+ 2 - 2
servlet/spring-boot/kotlin/hello-security/src/test/kotlin/org/springframework/security/samples/KotlinApplicationTests.kt

@@ -34,11 +34,11 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
 class KotlinApplicationTests(@Autowired private val mockMvc: MockMvc) {
 
     @Test
-    fun `index page is not protected`() {
+    fun `index page is protected`() {
         this.mockMvc
                 .get("/")
                 .andExpect {
-                    status { isOk() }
+                    status { is3xxRedirection() }
                 }
     }