Skip to content

Commit 4ce6420

Browse files
committed
feat: add 'secureCookies' configuration variable to explicitly set the secure flag and prevent confusion
1 parent 77eef18 commit 4ce6420

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

backend/prisma/seed/config.seed.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ const configVariables: ConfigVariables = {
2020
defaultValue: "http://localhost:3000",
2121
secret: false,
2222
},
23+
secureCookies: {
24+
type: "boolean",
25+
defaultValue: "false",
26+
},
2327
showHomePage: {
2428
type: "boolean",
2529
defaultValue: "true",

backend/src/auth/auth.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export class AuthController {
176176
request.cookies.access_token,
177177
);
178178

179-
const isSecure = this.config.get("general.appUrl").startsWith("https");
179+
const isSecure = this.config.get("general.secureCookies");
180180
response.cookie("access_token", "", {
181181
maxAge: -1,
182182
secure: isSecure,

backend/src/auth/auth.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ export class AuthService {
334334
refreshToken?: string,
335335
accessToken?: string,
336336
) {
337-
const isSecure = this.config.get("general.appUrl").startsWith("https");
337+
const isSecure = this.config.get("general.secureCookies");
338338
if (accessToken)
339339
response.cookie("access_token", accessToken, {
340340
sameSite: "lax",

backend/src/user/user.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class UserController {
5353
@GetUser() user: User,
5454
@Res({ passthrough: true }) response: Response,
5555
) {
56-
const isSecure = this.config.get("general.appUrl").startsWith("https");
56+
const isSecure = this.config.get("general.secureCookies");
5757

5858
response.cookie("access_token", "accessToken", {
5959
maxAge: -1,

frontend/src/i18n/translations/en-US.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ export default {
410410
"admin.config.general.app-url": "App URL",
411411
"admin.config.general.app-url.description":
412412
"On which URL Pingvin Share is available",
413+
"admin.config.general.secure-cookies": "Secure cookies",
414+
"admin.config.general.secure-cookies.description":
415+
"Whether to set the secure flag on cookies. If enabled, the site will not function when accessed over HTTP.",
413416
"admin.config.general.show-home-page": "Show home page",
414417
"admin.config.general.show-home-page.description":
415418
"Whether to show the home page",

0 commit comments

Comments
 (0)