Skip to content

Commit

Permalink
defined cookie domain name
Browse files Browse the repository at this point in the history
  • Loading branch information
linxiaoxin committed Jul 24, 2024
1 parent 55091ee commit c4e59ba
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public ResponseEntity<UserProfile> getAccess(@RequestBody TokenRequest request){

//create cookie and return code with cookie session
HttpHeaders headers = new HttpHeaders();
headers.add("Set-Cookie", String.format("%s=%s; Max-Age=%s; Path=/; HttpOnly;", COOKIE_NAME, userProfile.getSessionId(),sessionTimeout));
headers.add("Set-Cookie", String.format("%s=%s; Max-Age=%s; Domain=%s; Path=/; HttpOnly;"
, COOKIE_NAME
, userProfile.getSessionId()
,sessionTimeout
, "dkraju438qs82.cloudfront.net"));

return ResponseEntity.status(HttpStatus.OK).headers(headers).body(userProfile);
}
Expand All @@ -54,7 +58,7 @@ public ResponseEntity<String> signOut(@CookieValue(COOKIE_NAME) String cookie, @
authenticationService.signOut(cookie, signOutRequest.getClientId());
//expire cookie to remove from session
HttpHeaders headers = new HttpHeaders();
headers.add("Set-Cookie", String.format("%s=%s; Max-Age=0; Path=/; HttpOnly;", COOKIE_NAME,""));
headers.add("Set-Cookie", String.format("%s=%s; Max-Age=0; Domain=%s; Path=/; HttpOnly;", COOKIE_NAME,"", "dkraju438qs82.cloudfront.net"));

return ResponseEntity.status(HttpStatus.OK).headers(headers).body(null);
}
Expand Down

0 comments on commit c4e59ba

Please sign in to comment.