Ich erstelle Rest api und implementiert Spring Security - alles funktioniert gut, aber ich will (für jetzt, wenn ich noch entwickle) für jeden ohne Berechtigung zu können Öffne localhost: 8080/Konsole. Mein Code:H2-Konsole und Spring Security - permitAll() funktioniert nicht
@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();
}
Und was ist wirklich seltsam - localhost: 8080/Register benötigt keine Authentifizierung aber/console kehrt:
{
"timestamp": 1485876313847,
"status": 403,
"error": "Forbidden",
"message": "Access Denied",
"path": "/console"
}
Wer weiß, wie man es beheben?
Auch dies funktioniert gut, wenn auch keine Notwendigkeit zu verdoppeln .authorazieRequests(). 'http.authorizeRequests(). AntMatchers ("/ register", "/ console/**"). PermitAll();' – doublemc