spring引导中的HttpServlent.getHeaders()在从Flatter http请求请求时返回null,但带有postman返回值
spring引导中的HttpServlent.getHeaders()在从Flatter http请求请求时返回null,但带有postman返回值 这是我的密码 导入静态org.springframework.http.HttpHeaders.AUTHORIZATION 公共类AuthenticationFilter扩展了AbstractAuthenticationProcessingFilter{spring引导中的HttpServlent.getHeaders()在从Flatter http请求请求时返回null,但带有postman返回值,spring,flutter,http,security,request,Spring,Flutter,Http,Security,Request,spring引导中的HttpServlent.getHeaders()在从Flatter http请求请求时返回null,但带有postman返回值 这是我的密码 导入静态org.springframework.http.HttpHeaders.AUTHORIZATION 公共类AuthenticationFilter扩展了AbstractAuthenticationProcessingFilter{ AuthenticationFilter(final RequestMatcher requi
AuthenticationFilter(final RequestMatcher requiresAuth) {
super(requiresAuth);
}
@Override
public Authentication attemptAuthentication(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws AuthenticationException, IOException, ServletException {
Optional tokenParam = Optional.ofNullable(httpServletRequest.getHeader(AUTHORIZATION)); / / /Authorization: Bearer TOKEN
String token= httpServletRequest.getHeader(AUTHORIZATION);
token= StringUtils.removeStart(token, "Bearer").trim();
Authentication requestAuthentication = new UsernamePasswordAuthenticationToken(token, token);
return getAuthenticationManager().authenticate(requestAuthentication);
}
@Override
protected void successfulAuthentication(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain, final Authentication authResult) throws IOException, ServletException {
SecurityContextHolder.getContext().setAuthentication(authResult);
chain.doFilter(request, response);
}
}
错误消息=>from origin'http://localhost:52607'已被CORS策略阻止:对飞行前请求的响应未通过访问控制检查:它没有HTTP ok状态