| 작성자 | 김성민 |
|---|---|
| 날짜 | @2023년 9월 13일 |
Spring
Security 란 기본 세팅
Security 설정 인증 설정 Test 결과 Thymeleaf Login Logout (2023.09.15 추가)
Spring Boot 3.1.3
JDK 17
H2 DB
Spring Security는 Spring 기반 애플리케이션의 보안(인증과 권한, 인가 등)을 담당하는 스프링 하위 프레임워크이다. Spring Security는 ‘인증’과 ‘권한’에 대한 부분을 Filter 흐름에 따라 처리 하고 있다.
Spring Security는 기본적으로 인증 절차를 거친 후에 인가 절차를 진행하게 되며, 인가 과정에서 해당 리소스에 대한 접근 권한이 있는지 확인을 하게 된다.
build.gradle에 다음 종속성들을 추가한다.
build.gradle
...
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
runtimeOnly 'com.h2database:h2'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
}
...
application.yml을 다음과 같이 설정한다.
thymeleaf를 사용하려면 아래 두 줄을 추가한다.
application.yml