mirror of
https://github.com/stonith404/pingvin-share.git
synced 2024-11-15 03:50:11 +01:00
feat: add 'secureCookies' configuration variable to explicitly set the secure flag and prevent confusion
This commit is contained in:
parent
77eef187b7
commit
4ce64206be
@ -20,6 +20,10 @@ const configVariables: ConfigVariables = {
|
|||||||
defaultValue: "http://localhost:3000",
|
defaultValue: "http://localhost:3000",
|
||||||
secret: false,
|
secret: false,
|
||||||
},
|
},
|
||||||
|
secureCookies: {
|
||||||
|
type: "boolean",
|
||||||
|
defaultValue: "false",
|
||||||
|
},
|
||||||
showHomePage: {
|
showHomePage: {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
defaultValue: "true",
|
defaultValue: "true",
|
||||||
|
@ -176,7 +176,7 @@ export class AuthController {
|
|||||||
request.cookies.access_token,
|
request.cookies.access_token,
|
||||||
);
|
);
|
||||||
|
|
||||||
const isSecure = this.config.get("general.appUrl").startsWith("https");
|
const isSecure = this.config.get("general.secureCookies");
|
||||||
response.cookie("access_token", "", {
|
response.cookie("access_token", "", {
|
||||||
maxAge: -1,
|
maxAge: -1,
|
||||||
secure: isSecure,
|
secure: isSecure,
|
||||||
|
@ -334,7 +334,7 @@ export class AuthService {
|
|||||||
refreshToken?: string,
|
refreshToken?: string,
|
||||||
accessToken?: string,
|
accessToken?: string,
|
||||||
) {
|
) {
|
||||||
const isSecure = this.config.get("general.appUrl").startsWith("https");
|
const isSecure = this.config.get("general.secureCookies");
|
||||||
if (accessToken)
|
if (accessToken)
|
||||||
response.cookie("access_token", accessToken, {
|
response.cookie("access_token", accessToken, {
|
||||||
sameSite: "lax",
|
sameSite: "lax",
|
||||||
|
@ -53,7 +53,7 @@ export class UserController {
|
|||||||
@GetUser() user: User,
|
@GetUser() user: User,
|
||||||
@Res({ passthrough: true }) response: Response,
|
@Res({ passthrough: true }) response: Response,
|
||||||
) {
|
) {
|
||||||
const isSecure = this.config.get("general.appUrl").startsWith("https");
|
const isSecure = this.config.get("general.secureCookies");
|
||||||
|
|
||||||
response.cookie("access_token", "accessToken", {
|
response.cookie("access_token", "accessToken", {
|
||||||
maxAge: -1,
|
maxAge: -1,
|
||||||
|
@ -410,6 +410,9 @@ export default {
|
|||||||
"admin.config.general.app-url": "App URL",
|
"admin.config.general.app-url": "App URL",
|
||||||
"admin.config.general.app-url.description":
|
"admin.config.general.app-url.description":
|
||||||
"On which URL Pingvin Share is available",
|
"On which URL Pingvin Share is available",
|
||||||
|
"admin.config.general.secure-cookies": "Secure cookies",
|
||||||
|
"admin.config.general.secure-cookies.description":
|
||||||
|
"Whether to set the secure flag on cookies. If enabled, the site will not function when accessed over HTTP.",
|
||||||
"admin.config.general.show-home-page": "Show home page",
|
"admin.config.general.show-home-page": "Show home page",
|
||||||
"admin.config.general.show-home-page.description":
|
"admin.config.general.show-home-page.description":
|
||||||
"Whether to show the home page",
|
"Whether to show the home page",
|
||||||
|
Loading…
Reference in New Issue
Block a user