반응형
설정
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
코드
<!DOCTYPE html> <html lang="en" xmlns:sec="http://www.w3.org/1999/xhtml"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <h1>Member Page</h1> <div sec:authorize="hasRole('ADMIN')">ADMIN ROLE</div> <div sec:authorize="hasRole('MEMBER')">MANAGER ROLE</div> <div sec:authorize="hasRole('USER')">USER ROLE</div> <div sec:authorize="hasAnyRole('ADMIN', 'MEMBER')">ADMIN OR MANAGER ROLE</div> <div sec:authorize="isAuthenticated()"> 인증한 경우 </div> <div sec:authorize="isAnonymous()"> 익명인 경우(인증한 경우를 제외한 경우) </div> Authenticated username: <div sec:authentication="name"></div> Authenticated user roles: <div sec:authentication="principal.authorities"> </div> </div> </body> </html>
- 모든 권한을 가진 1user@dutmdcjf.com으로 접속한 경우

- USER 권한만 가진 100user@dutmdcjf.com으로 접속한 경우

반응형
'Spring Security' 카테고리의 다른 글
Spring Security OAuth 2.0를 이해해보자 (0) | 2023.06.14 |
---|---|
Google Login (OAuth2.0: Open Authorization) (0) | 2022.10.15 |
WebSecurityConfigurerAdapter Deprecated (0) | 2022.10.14 |
Spring Security 프로젝트 시작 (0) | 2022.10.14 |
Spring Security @PreAuthorize, @PostAuthorize, @Secured (0) | 2022.10.02 |