Skip to content

Commit cbf6fd0

Browse files
author
Marcin Maciaszczyk
authored
Set 'SameSite=Strict' for all cookies (#2019)
1 parent 5d2b4fe commit cbf6fd0

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/app/core/services/auth/auth.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ export class Auth {
2424
if (this.compareNonceWithToken(token, nonce)) {
2525
// remove URL fragment with token, so that users can't accidentally copy&paste it and send it to others
2626
this.removeFragment();
27-
this._cookieService.set(Auth.Cookie.Token, token, 1, '/', null, true);
27+
this._cookieService.set(Auth.Cookie.Token, token, 1, '/', null, true, 'Strict');
2828
// localhost is only served via http, though secure cookie is not possible
2929
// following line will only work when domain is localhost
30-
this._cookieService.set(Auth.Cookie.Token, token, 1, '/', 'localhost');
31-
this._cookieService.set(Auth.Cookie.Token, token, 1, '/', '127.0.0.1');
30+
this._cookieService.set(Auth.Cookie.Token, token, 1, '/', 'localhost', false, 'Strict');
31+
this._cookieService.set(Auth.Cookie.Token, token, 1, '/', '127.0.0.1', false, 'Strict');
3232
}
3333
this._previousRouteService.loadRouting();
3434
}
@@ -89,7 +89,7 @@ export class Auth {
8989
}
9090

9191
login(): void {
92-
this._cookieService.set(Auth.Cookie.Autoredirect, 'true', 1, '/');
92+
this._cookieService.set(Auth.Cookie.Autoredirect, 'true', 1, '/', null, false, 'Strict');
9393
}
9494

9595
logout(): void {

src/app/pages/frontpage/frontpage.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ export class FrontpageComponent implements OnInit {
2828
const nonceRegExp = /[\?&#]nonce=([^&]+)/;
2929
const nonceStr = nonceRegExp.exec(this._auth.getOIDCProviderURL());
3030
if (!!nonceStr && nonceStr.length >= 2 && !!nonceStr[1]) {
31-
this._cookieService.set(Auth.Cookie.Nonce, nonceStr[1], null, '/', null, true);
31+
this._cookieService.set(Auth.Cookie.Nonce, nonceStr[1], null, '/', null, true, 'Strict');
3232
// localhost is only served via http, though secure cookie is not possible
3333
// following line will only work when domain is localhost
34-
this._cookieService.set(Auth.Cookie.Nonce, nonceStr[1], null, '/', 'localhost');
35-
this._cookieService.set(Auth.Cookie.Nonce, nonceStr[1], null, '/', '127.0.0.1');
34+
this._cookieService.set(Auth.Cookie.Nonce, nonceStr[1], null, '/', 'localhost', false, 'Strict');
35+
this._cookieService.set(Auth.Cookie.Nonce, nonceStr[1], null, '/', '127.0.0.1', false, 'Strict');
3636
}
3737
}
3838

0 commit comments

Comments
 (0)