Closed. This question needs to be more
focused。它当前不接受答案。
想改善这个问题吗?更新问题,使其仅通过
editing this post专注于一个问题。
在11个月前关闭。
我将OpenApi 3用于控制器的生成接口,例如:
@ApiOperation(value = "", nickname = "security", notes = "", response = String.class, authorizations = {
@Authorization(value = "bearerAuth")
}, tags={ "common", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK.", response = String.class) })
@RequestMapping(value = "/check/security",
produces = { "application/json" },
method = RequestMethod.GET)
default ResponseEntity<String> security() {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
API的某些部分不安全,并且在@ApiOperation批注中不包含授权部分。
为了在春季实现此行为,我使用了如下波纹管配置:
http
.authorizeRequests()
.antMatchers("/check/ping").permitAll()
.antMatchers("/authorize/**").permitAll()
.anyRequest().authenticated()
但我想自动配置。如果注释中没有授权部分,则允许此路径,否则需要经过身份验证。
有可能吗?可能是自定义注释处理还是其他?