只是空虚的存在
WebSecurityConfigurerAdapter
破坏我的应用程序的OAuth2。
我得到
$ curl -i -X POST -H "Content-Type: application/json" -H "Authorization: Bearer 27f9e2b7-4441-4c03-acdb-7e7dc358f783" -d '{"apiKey": "key", "tag": "tag"}' localhost:8080/isTagAvailable
HTTP/1.1 302
Location: http://localhost:8080/error
当我期望的时候
$ curl -i -X POST -H "Content-Type: application/json" -H "Authorization: Bearer 27f9e2b7-4441-4c03-acdb-7e7dc358f783" -d '{"apiKey": "key", "tag": "tag"}' localhost:8080/isTagAvailable
HTTP/1.1 401
{"error":"invalid_token","error_description":"Invalid access token: 27f9e2b7-4441-4c03-acdb-7e7dc358f783"}
我不得不对
整个
类以便OAuth2工作。甚至只是评论
configure
方法不起作用。为什么?
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/robots.txt").permitAll()
.and()
.authorizeRequests()
.antMatchers("/isTagAvailable").hasRole("USER")
// .anyRequest().authenticated()
.and()
.httpBasic().disable();
}
}
I learned how to add security logging
但是
it didn't print out any useful information
.