im using spring security and my config is
@Override
protected void configure(HttpSecurity http) throws Exception {
http.
authorizeRequests()
.antMatchers("/**").permitAll()
.antMatchers("/admin/**").hasAuthority("ADMIN").anyRequest().authenticated()
.and().csrf().disable().formLogin().loginPage("/adminlogin").failureUrl("/adminlogin?error=true")
.defaultSuccessUrl("/admin/dashboard")
.usernameParameter("email")
.passwordParameter("password")
.and().logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/adminlogin?logout=true").and().exceptionHandling()
.accessDeniedPage("/accessdenied");
}
now what i am trying to achieve that all links are accessible without any security but link start with /admin/** only allow to user with role "admin".
but rite now it allow /admin/** to everyone.
any suggestions.
i have tried many solutions from stackoverflow i.e How to fix role in Spring Security? but no luck. the behavior remains same,it allows even /admin/ urls to use publicly.