Spring Security antMachers -


i using spring security 3.2.0.release. want redirect user url if not permitted see page, how can this?

.antmatchers("/cabinet/control/members/*").hasrole("owner").redirectto(..) 

you have define access denied handler/page, see spring security reference:

if accessdeniedexception thrown , user has been authenticated, means operation has been attempted don’t have enough permissions. in case, exceptiontranslationfilter invoke second strategy, accessdeniedhandler. default, accessdeniedhandlerimpl used, sends 403 (forbidden) response client. alternatively can configure instance explicitly (as in above example) , set error page url forwards request [13]. can simple "access denied" page, such jsp, or more complex handler such mvc controller. , of course, can implement interface , use own implementation.

example:

@override protected void configure(final httpsecurity http) throws exception {     http         .authorizerequests()             .antmatchers("/cabinet/control/members/*").hasrole("owner")             .and()         .exceptionhandling()             .accessdeniedpage("/access_denied.jsp")             .and()         .formlogin(); } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -