Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit 0a9189f

Browse files
committed
Updated cookie SameSite policy for all cookies created
1 parent 62ef9b8 commit 0a9189f

File tree

8 files changed

+30
-23
lines changed

8 files changed

+30
-23
lines changed

src/javascript/_common/language.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const Language = (() => {
2626
const setCookieLanguage = (lang) => {
2727
if (!Cookies.get('language') || lang) {
2828
const cookie = new CookieStorage('language');
29-
cookie.write((lang || getLanguage()).toUpperCase());
29+
cookie.write((lang || getLanguage()).toUpperCase(), undefined, true, 'none');
3030
}
3131
};
3232

src/javascript/_common/storage.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,28 +136,30 @@ CookieStorage.prototype = {
136136
}
137137
this.initialized = true;
138138
},
139-
write(val, expireDate, isSecure) {
139+
write(val, expireDate, isSecure, sameSite) {
140140
if (!this.initialized) this.read();
141141
this.value = val;
142142
if (expireDate) this.expires = expireDate;
143143
Cookies.set(this.cookie_name, this.value, {
144-
expires: this.expires,
145-
path : this.path,
146-
domain : this.domain,
147-
secure : !!isSecure,
144+
expires : this.expires,
145+
path : this.path,
146+
domain : this.domain,
147+
secure : !!isSecure,
148+
sameSite: sameSite || 'strict',
148149
});
149150
},
150151
get(key) {
151152
if (!this.initialized) this.read();
152153
return this.value[key];
153154
},
154-
set(key, val) {
155+
set(key, val, options) {
155156
if (!this.initialized) this.read();
156157
this.value[key] = val;
157158
Cookies.set(this.cookie_name, this.value, {
158159
expires: new Date(this.expires),
159160
path : this.path,
160161
domain : this.domain,
162+
...options,
161163
});
162164
},
163165
remove() {

src/javascript/app/base/footer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const Footer = (() => {
7777
$dialog_notification.slideUp(200);
7878
el_footer.style.paddingBottom = '0px';
7979
$status_notification.css('bottom', `${gap_to_notification}px`);
80-
Cookies.set('CookieConsent', 1);
80+
Cookies.set('CookieConsent', 1, { sameSite: 'strict', secure: true });
8181
});
8282
window.addEventListener('resize', () => {
8383
adjustElevioAndScrollup($dialog_notification.height() + gap_dialog_to_elevio,

src/javascript/app/base/interview_popup.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ const InterviewPopup = (() => {
2222
$interview_popup.removeClass('invisible');
2323
}, 2000);
2424
$interview_no_thanks.one('click', () => {
25-
Cookies.set('InterviewConsent', 1);
25+
Cookies.set('InterviewConsent', 1, { sameSite: 'strict', secure: true });
2626
$interview_popup.addClass('invisible');
2727
});
2828
$interview_ask_later.one('click', () => {
2929
const interval_time = 1 / 12;
3030
Cookies.set('InterviewConsent', 1, {
31-
expires: interval_time,
31+
expires : interval_time,
32+
sameSite: 'strict',
33+
secure : true,
3234
});
3335
$interview_popup.addClass('invisible');
3436
});
@@ -42,7 +44,7 @@ const InterviewPopup = (() => {
4244
const pre_phone = `&entry.1442583433=${get_settings.phone}`;
4345
const encode_uri = (`${url}${pre_name}${pre_email}${pre_country}${pre_phone}`).replace(/\+/g, '%2B');
4446
$interview_popup.addClass('invisible');
45-
Cookies.set('InterviewConsent', 1);
47+
Cookies.set('InterviewConsent', 1, { sameSite: 'strict', secure: true });
4648
window.open(encode_uri, '_blank');
4749
});
4850
});

src/javascript/app/base/page.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,11 @@ const Page = (() => {
146146
}
147147

148148
Cookies.set('affiliate_tracking', cookie_hash, {
149-
expires: 365, // expires in 365 days
150-
path : '/',
151-
domain : `.${location.hostname.split('.').slice(-2).join('.')}`,
149+
expires : 365, // expires in 365 days
150+
path : '/',
151+
domain : `.${location.hostname.split('.').slice(-2).join('.')}`,
152+
sameSite: 'none',
153+
secure : true,
152154
});
153155
return true;
154156
};

src/javascript/app/common/guide.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const Guide = (() => {
6161
const setDisabled = () => {
6262
if (!isDisabled()) {
6363
const disabled = Cookies.get(cookie_name);
64-
Cookies.set(cookie_name, (!disabled ? opt.script : `${disabled},${opt.script}`));
64+
Cookies.set(cookie_name, (!disabled ? opt.script : `${disabled},${opt.script}`), { sameSite: 'strict', secure: true });
6565
}
6666
};
6767

src/javascript/app/common/traffic_source.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const TrafficSource = (() => {
5151
if (params.utm_source) { // url params can be stored only if utm_source is available
5252
param_keys.map((key) => {
5353
if (params[key] && !current_values[key]) {
54-
cookie.set(key, params[key]);
54+
cookie.set(key, params[key], { sameSite: 'none', secure: true });
5555
}
5656
});
5757
}
@@ -68,7 +68,7 @@ const TrafficSource = (() => {
6868
referrer = doc_ref;
6969
}
7070
if (referrer && !current_values.referrer && !params.utm_source && !current_values.utm_source) {
71-
cookie.set('referrer', (Url.getLocation(referrer)).hostname);
71+
cookie.set('referrer', (Url.getLocation(referrer)).hostname, { sameSite: 'none', secure: true });
7272
}
7373
};
7474

src/javascript/app/pages/user/account/authenticate.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,9 @@ const Authenticate = (() => {
902902
const token = response.service_token.token;
903903
const in_90_minutes = 1 / 16;
904904
Cookies.set('onfido_token', token, {
905-
expires: in_90_minutes,
906-
secure : true,
905+
expires : in_90_minutes,
906+
secure : true,
907+
sameSite: 'strict',
907908
});
908909
resolve({ token });
909910
});
@@ -930,7 +931,7 @@ const Authenticate = (() => {
930931
}
931932

932933
const service_token_response = await getOnfidoServiceToken();
933-
934+
934935
if (
935936
service_token_response.error &&
936937
service_token_response.error.code === 'MissingPersonalDetails'
@@ -954,7 +955,7 @@ const Authenticate = (() => {
954955

955956
$('#missing_personal_fields').html(error_msgs);
956957
}
957-
958+
958959
const { identity, document } = authentication_status;
959960

960961
const is_fully_authenticated = identity.status === 'verified' && document.status === 'verified';
@@ -965,7 +966,7 @@ const Authenticate = (() => {
965966
$('#authentication_tab').setVisibility(0);
966967
$('#authentication_verified').setVisibility(1);
967968
}
968-
969+
969970
if (has_personal_details_error) {
970971
$('#personal_details_error').setVisibility(1);
971972
} else if (!identity.further_resubmissions_allowed) {
@@ -1036,7 +1037,7 @@ const Authenticate = (() => {
10361037
$('#authentication_loading').setVisibility(0);
10371038
$('#authentication_unneeded').setVisibility(1);
10381039
}
1039-
1040+
10401041
const has_svg_account = Client.hasSvgAccount();
10411042
if (is_required || has_svg_account){
10421043
initTab();

0 commit comments

Comments
 (0)