Does a post always use redirect to respond to a request. If so, how can I ensure that the response headers are also carried forward to the redirected url? Currently, I'm setting a JWT token in the response headers that I send but the redirected url doesn't contain the token. Can someone tell me how I can ensure that I get the JWT token so that I can use it in my further requests.
String token = JWT.create()
.withSubject(((LdapUserDetails) authentication.getPrincipal()).getUsername())
.withExpiresAt(new Date(System.currentTimeMillis() + EXPIRATION_TIME))
.sign(HMAC512(SECRET.getBytes()));
response.addHeader(HEADER_STRING, TOKEN_PREFIX + token);
Object redirectURLObject = request.getSession().getAttribute(REDIRECT_URL_SESSION_ATTRIBUTE_NAME);
if(redirectURLObject != null)
setDefaultTargetUrl(redirectURLObject.toString());
else{
setDefaultTargetUrl("http://localhost:8000");
}
request.getSession().removeAttribute(REDIRECT_URL_SESSION_ATTRIBUTE_NAME);
super.onAuthenticationSuccess(request, response, authentication);