-
Notifications
You must be signed in to change notification settings - Fork 0
/
SecurityConfiguration.kt
38 lines (34 loc) · 1.13 KB
/
SecurityConfiguration.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.daisuzz.samplethymeleaftodo.configuration
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.invoke
import org.springframework.security.crypto.password.NoOpPasswordEncoder
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.security.web.SecurityFilterChain
@Configuration
class SecurityConfiguration {
@Bean
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
http.invoke {
authorizeRequests {
authorize(anyRequest, authenticated)
}
formLogin { }
httpBasic { }
csrf {
disable()
}
logout {
logoutUrl = "/logout"
logoutSuccessUrl = "/"
}
}
return http.build()
}
// for testing
@Bean
fun passwordEncoder(): PasswordEncoder {
return NoOpPasswordEncoder.getInstance()
}
}