ハムザ:
私は応答でそれを置くことができますどのように、私は、ヘッダー内のJWTのトークンを送信するが、クライアントは応答のボディにそれを必要とします:
@Overrideは
ボイドsuccessfulAuthentication(保護
HttpServletRequestのリクエスト、HttpServletResponseの応答れるFilterChain鎖、認証authResultが)
にIOException、ServletExceptionがを{スロー
User springUser = (User) authResult.getPrincipal();
String jwt = Jwts.builder()
.setSubject(springUser.getUsername())
.setExpiration(new Date(System.currentTimeMillis()+SecurityConstants.EXPIRATION_TIME))
.signWith(SignatureAlgorithm.HS256, SecurityConstants.SECRET)
.claim("roles",springUser.getAuthorities())
.compact();
response.addHeader(SecurityConstants.HEADER_STRING, SecurityConstants.TOKEN_PREFIX+jwt);
}
私は応答でトークンを配置する必要があり
氏スキップ:
私が正しくあなたを理解していれば、あなただけのレスポンスボディを作成する必要があります
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(
"{\"" + SecurityConstants.HEADER_STRING + "\":\"" + SecurityConstants.TOKEN_PREFIX+jwt + "\"}"
);