I would like to protect a method in my managed bean session for a specific role "ROLE_ADMIN"
configurations (ApplicationContext-security.xml):
<global-method-security pre-post-annotations="enabled" jsr250-annotations="enabled" secured-annotations="enabled"/>
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/**" access="isAuthenticated()"/>
<intercept-url pattern="/**" access="permitAll()"/>
<form-login
login-processing-url="/j_spring_security_check"
login-page="/login.jsf"
default-target-url="/main.jsf"
authentication-failure-url="/login.jsf" />
<session-management>
<concurrency-control max-sessions="1" error-if-maximum-exceeded="false" />
</session-management>
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider>
<user-service>
<user name="admin" password="admin" authorities="ROLE_USER, ROLE_ADMIN" />
<user name="user1" password="user1" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
<beans:bean id="loggerListener" class="org.springframework.security.authentication.event.LoggerListener"/>
bean protected method:
@PreAuthorize("hasRole('ROLE_ADMIN')")
public String buy() {
...
}
When I logged in user1or like anonymand clicked the buy button on a web page, it still redirects to the next page.
I expect that there has been some kind of denial of access, and this is not the case.
source
share