Я создаю rest api и реализован Spring Security - все работает нормально, но я хочу (пока, когда я еще разрабатываю), чтобы иметь возможность для любого без разрешения открыть localhost: 8080/console. Мой код:H2 console и Spring Security - allowAll() не работает
@Override
protected void configure(HttpSecurity http) throws Exception {
// allow everyone to register an account; /console is just for testing
http.authorizeRequests().antMatchers("/register", "/console").permitAll();
http.authorizeRequests().anyRequest().fullyAuthenticated();
// making H2 console working
http.headers().frameOptions().disable();
/*
https://docs.spring.io/spring-security/site/docs/current/reference/html/csrf.html#when-to-use-csrf-protection
for non-browser APIs there is no need to use csrf protection
*/
http.csrf().disable();
}
И что действительно странно - локальный: 8080/регистр не требует аутентификации, но/консоль возвращается:
{
"timestamp": 1485876313847,
"status": 403,
"error": "Forbidden",
"message": "Access Denied",
"path": "/console"
}
Любой знает, как это исправить?
Это прекрасно работает тоже, нет необходимости удвоить .authorazieRequests(), хотя. 'http.authorizeRequests(). AntMatchers ("/ register", "/ console/**"). AllowAll();' – doublemc