SpringSecurity + Thymeleaf

킹콩(King Kong)·2024년 12월 11일

https://velog.io/@code12/Spring-Security-Spring-Boot%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-Thymeleaf-%EC%97%B0%EA%B2%B0

Dependency 추가

<!-- Thymeleaf SpringSecurity -->
<dependency>
	<groupId>org.thymeleaf.extras</groupId>
	<artifactId>thymeleaf-extras-springsecurity6</artifactId>
</dependency>

name space 추가

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">

권한별 제어

SecurityConfigThymeleaf
requestMatchers("/member/**").hasRole("ADMIN")sec:authorize="hasRole('ADMIN')"
requestMatchers("/user/**").hasAnyRole("ADMIN", "USER")sec:authorize="hasAnyRole('ADMIN', 'USER')"
profile
IT를 쉽게 이해해 보아요~😄

0개의 댓글