I am trying to add a link to a new row in a table , this link should only be accessible to the ADMIN Role.
spring boot : 1.4.0.RELEASE & thymeleaf-extras-springsecurity4.version : 2.1.2.RELEASE
<sec:authorize access="hasRole('ROLE_ADMIN')">
<tr>
<td>...</td>
<td>...</td>
</tr>
</sec:authorize>
Namespaces used are :
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
WebSecurityConfigAdapter:
http.authorizeRequests()
.antMatchers("/api/systemuser/*").access("hasRole('ROLE_ADMIN')")
//.antMatchers("/*").access("hasRole('ROLE_ADMIN')")
//.antMatchers("/ui/report/win").access("hasRole('ROLE_USER')")
//.antMatchers("/userError").access("hasRole('ROLE_ERROR')")
.antMatchers("/swagger*/**", "/about", "/").authenticated()
.anyRequest().authenticated()
.and()
.httpBasic()
.authenticationEntryPoint(authenticationEntryPoint)
;
http.csrf().disable();
But with this code , even users without ADMIN privileges are able to view the row of the table .
Can someone please help me with the way forward?
.access()and use thehasRole("ADMIN")method directly. You shouldn't need theROLE_prefix anymore either. - vphilipnyc