Update samples to use Spring Security 6
Issue gh-46
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
id("org.springframework.boot") version "2.5.0"
|
||||
id("io.spring.dependency-management") version "1.0.9.RELEASE"
|
||||
id("org.springframework.boot") version "3.0.0-M1"
|
||||
id("io.spring.dependency-management") version "1.0.11.RELEASE"
|
||||
kotlin("jvm") version "1.6.0"
|
||||
kotlin("plugin.spring") version "1.6.0"
|
||||
}
|
||||
@@ -12,15 +12,16 @@ repositories {
|
||||
maven {
|
||||
url = uri("https://repo.spring.io/snapshot")
|
||||
}
|
||||
maven {
|
||||
url = uri("https://repo.spring.io/milestone")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
implementation("org.springframework.boot:spring-boot-starter-security")
|
||||
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
|
||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||
implementation("org.thymeleaf.extras:thymeleaf-extras-springsecurity5")
|
||||
implementation("org.thymeleaf.extras:thymeleaf-extras-springsecurity6")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("org.springframework.security:spring-security-test")
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
+5
-10
@@ -19,7 +19,6 @@ package org.springframework.security.samples.config
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
|
||||
import org.springframework.security.config.web.servlet.invoke
|
||||
import org.springframework.security.core.userdetails.User
|
||||
import org.springframework.security.core.userdetails.UserDetailsService
|
||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager
|
||||
@@ -33,15 +32,11 @@ class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
fun filterChain(http: HttpSecurity): SecurityFilterChain {
|
||||
http {
|
||||
authorizeRequests {
|
||||
authorize("/css/**", permitAll)
|
||||
authorize("/user/**", hasAuthority("ROLE_USER"))
|
||||
}
|
||||
formLogin {
|
||||
loginPage = "/log-in"
|
||||
}
|
||||
}
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/css/**").permitAll()
|
||||
.antMatchers("/user/**").hasAuthority("ROLE_USER")
|
||||
.and()
|
||||
.formLogin().loginPage("/log-in")
|
||||
return http.build()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user