我的配置如下,但是返回的json中么有验证的详细信息,请问什么原因?
rest client:
###
# @name register
POST {{host}}/authorize/register HTTP/1.1
Content-Type: application/json
{
"name": "aa"
}
返回的JSON:
HTTP/1.1 400
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Type: application/json
Transfer-Encoding: chunked
Date: Thu, 09 Sep 2021 06:00:45 GMT
Connection: close
{
“timestamp”: “2021-09-09T06:00:45.649+00:00”,
“status”: 400,
“error”: “Bad Request”,
“path”: “/authorize/register”
}
SecurityConfig.java
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests(req -> req
.antMatchers("/authorize/**").permitAll()
.antMatchers("/admin/**").hasRole("ADMIN")
.antMatchers("/api/**").hasRole("USER")
.anyRequest().authenticated())
.addFilterAt(restAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
.csrf(csrf -> csrf.disable());
API:
@RestController
@RequestMapping("/authorize")
public class AuthorizeController {
@PostMapping("register")
public UserDto register(@Valid @RequestBody UserDto userDto) {
return userDto;
}
}