java - 特定 API 春季启动的基本身份验证 - 返回 200 ok 但意外正文
问题描述
我正在使用 spring boot 和 java 构建 Web 应用程序。在实现外部 API 的过程中,所有请求都返回相同的响应 - 200 ok 但奇怪的 Json 主体甚至不存在于 API 响应中。
- API 需要使用用户名和密码进行基本身份验证,可能是授权有问题???
这是我的控制器: 我的控制器:
还有我的 webConfigure :
`
@Autowired
UserDetailsServiceImpl userDetailsService;
@Autowired
private AuthEntryPointJwt unauthorizedHandler;
@Bean
public AuthTokenFilter authenticationJwtTokenFilter() {
return new AuthTokenFilter();
}
@Override
public void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
authenticationManagerBuilder.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/readJson/**" , "/auth/**" , "/ratehawk/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable().exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().authorizeRequests()
.antMatchers("/readJson/**").permitAll().anyRequest().authenticated();
http.addFilterBefore(authenticationJwtTokenFilter(), UsernamePasswordAuthenticationFilter.class);
}
} `
如果有人知道为什么会这样?谢谢你最好的问候伊丹
解决方案
推荐阅读
- css - CSS中用户拖动和用户选择的区别
- javascript - 具有交替行和行号的文本区域
- kubernetes - 一段时间后在 Cloudant 中出现 401 客户端错误
- python - Python - ValueError:从 CSV 绘制图形时,min() arg 是一个空序列
- sql - PostgreSQL 中的 SQL 窗口函数
- css - SVG 无响应,脱离容器
- r - 使用方法“pmm”,同时从插补中排除变量
- laravel - Swift_AddressEncoder_IdnAddressEncoder 类不存在
- ios - iOS 图表放大一系列值
- python - 连接 Excel 文件,使用文件名作为索引引发错误