The below setup allows anonymous user to access restricted antMatcher
s defined below. I tried placing /**
at end of this chain and still not able to solve this.
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/**").permitAll()
.and()
.authorizeRequests()
.antMatchers("/user/**").not().anonymous()
.anyRequest().authenticated()
.antMatchers("/user/**").not().anonymous()
.anyRequest().authenticated()
.antMatchers("/owner/**").access("hasRole('OWNER')")
.anyRequest().authenticated()
.antMatchers("/admin/**").access("hasRole('ADMIN')")
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
I wish a setup with authorization.
/**
for anonymous/admin
for admin users/owner
for owner users/user
for other users
Authentication with specific roles are working fine.
Edit: If I give /browse/**
to allow anonymous user, I can allow as I wish. But I don't want to see browse pattern in the URL as I am delivering pages through Spring MVC and makes me to move my pages to under /browse
URL pattern.
How to deliver pages in Spring MVC for any user without any pattern match in the beginning of URL like browse or something? Can I use static and public folders under resources to deliver such pages? Good practice?