Skip to content

Commit

Permalink
refactor: SameSite Enum 활용 #357
Browse files Browse the repository at this point in the history
  • Loading branch information
jhon3242 committed Oct 24, 2024
1 parent 9c1f71e commit 4dd8346
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.server.Cookie.SameSite;
import org.springframework.http.ResponseCookie;
import org.springframework.stereotype.Component;

@Component
public class RoomMemberCookieEncryptor {

private static final String DEFAULT_PATH = "/api/balances/rooms";
private static final String NONE = "None";
private static final String LAX = "Lax";
private static final String LOCALHOST = "http://localhost";

private final EncryptionUtils encryptionUtils;
Expand All @@ -34,9 +33,9 @@ public ResponseCookie getEncodedCookie(Object value, String origin) {

private String getSameSiteOption(String origin) {
if (origin != null && origin.startsWith(LOCALHOST)) {
return NONE;
return SameSite.NONE.attributeValue();
}
return LAX;
return SameSite.LAX.attributeValue();
}

public Long getDecodedCookieValue(String cookieValue) {
Expand Down

0 comments on commit 4dd8346

Please sign in to comment.