Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add thymeleaf XML namespace to index.html
- https://github.com/thymeleaf/thymeleaf-extras-springsecurity
- Thymeleaf Extras
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
- xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
- <div sec:authorize="hasRole('ADMIN')">
- This content is only shown to administrators.ยงยง
- </div>
- <div sec:authorize="hasRole('USER')">
- This content is only shown to users.
- Content is not just hidden from view but will not be rendered when our application server returns the page to the browser.
- </div>
- retrieve the user's username and roles and display these in our HTML
- <div>
- User: <span sec:authentication="name">NOT FOUND</span>
- Spring Roles: <span sec:authentication="principal.authorities">NOT FOUND</span>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement