简介
我刚刚问过另一个可能导致解决方案的question,但是可能有更好的方法。安全性由spring-security提供。
问题描述
我将用户存储在DynamoDB
中。通过遵循某个流程 - 这不是一个案例 - 可能会获得一个特殊的veryImportantUser=true
参数。在这种情况下,我想返回自定义状态代码202
,因此前端可以向用户显示某些视图。
我有什么:
我有MyAuthenticationSuccessHandler
以下onAuthentcationSuccess
:
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
super.onAuthenticationSuccess(request, response, authentication);
MyUserDetails userDetails = (MyUserDetails)SecurityContexHolder.getContext().getAuthentication().getPrincipal();
if (userDetails.isVIP())
response.setStatus(HttpServletResponse.SC_ACCEPTED);
}
问题:
我在该方法中放置了断点并触发了它。响应状态设置为202
,但在我的Postman
我收到状态200
。我可以用其他方式处理RequestHeaderAuthenticationFilter
吗?我很乐意在不挣扎xml
配置的情况下做到这一点。