From ee79d601057c697fa5ca6e8aa56eeccf7363d258 Mon Sep 17 00:00:00 2001 From: kyle hoell Date: Mon, 7 Dec 2020 18:01:22 -0500 Subject: [PATCH] updated setup --- backend/cookies/createCookies.ts | 17 +++-- backend/enviroment/env.ts | 6 +- webUISetup/index.html | 104 +++++++++++++++++++------------ webUISetup/src/index.js | 97 ++++++++++++++++++++-------- webUISetup/src/styles.css | 16 +++++ 5 files changed, 166 insertions(+), 74 deletions(-) diff --git a/backend/cookies/createCookies.ts b/backend/cookies/createCookies.ts index ba11d2c..0f87a4f 100644 --- a/backend/cookies/createCookies.ts +++ b/backend/cookies/createCookies.ts @@ -1,23 +1,28 @@ import {Response } from "express"; +import env from "../enviroment/env"; const maxAgeAccess = 60 * 1000 * 20; const maxAgeRefresh = 60 * 1000 * 60 * 24 * 30; const maxAgeStreamVideo = 60 * 1000 * 60 * 24; +const secureCookies = env.secureCookies ? env.secureCookies === "true" ? true : false : false; + +console.log("Secure Cookies", secureCookies); + export const createLoginCookie = (res: Response, accessToken: string, refreshToken: string) => { res.cookie("access-token",accessToken, { httpOnly: true, maxAge: maxAgeAccess, sameSite: "strict", - secure: process.env.NODE_ENV === "production" + secure: secureCookies }) res.cookie("refresh-token",refreshToken, { httpOnly: true, maxAge: maxAgeRefresh, sameSite: "strict", - secure: process.env.NODE_ENV === "production" + secure: secureCookies }) } @@ -27,14 +32,14 @@ export const createLogoutCookie = (res: Response) => { httpOnly: true, maxAge: 0, sameSite: "strict", - secure: process.env.NODE_ENV === "production" + secure: secureCookies }) res.cookie("refresh-token", {}, { httpOnly: true, maxAge: 0, sameSite: "strict", - secure: process.env.NODE_ENV === "production" + secure: secureCookies }) } @@ -44,7 +49,7 @@ export const createStreamVideoCookie = (res: Response, streamVideoAccessToken: s httpOnly: true, maxAge: maxAgeStreamVideo, sameSite: "strict", - secure: process.env.NODE_ENV === "production" + secure: secureCookies }) } @@ -54,6 +59,6 @@ export const removeStreamVideoCookie = (res: Response) => { httpOnly: true, maxAge: 0, sameSite: "strict", - secure: process.env.NODE_ENV === "production" + secure: secureCookies }) } \ No newline at end of file diff --git a/backend/enviroment/env.ts b/backend/enviroment/env.ts index 1c83bc9..01acd34 100644 --- a/backend/enviroment/env.ts +++ b/backend/enviroment/env.ts @@ -18,7 +18,8 @@ export default { sendgridKey: process.env.SENDGRID_KEY, sendgridEmail: process.env.SENDGRID_EMAIL, remoteURL: process.env.REMOTE_URL, - disableEmailVerification: process.env.DISABLE_EMAIL_VERIFICATION + disableEmailVerification: process.env.DISABLE_EMAIL_VERIFICATION, + secureCookies: process.env.SECURE_COOKIES } module.exports = { @@ -41,5 +42,6 @@ module.exports = { sendgridKey: process.env.SENDGRID_KEY, sendgridEmail: process.env.SENDGRID_EMAIL, remoteURL: process.env.REMOTE_URL, - disableEmailVerification: process.env.DISABLE_EMAIL_VERIFICATION + disableEmailVerification: process.env.DISABLE_EMAIL_VERIFICATION, + secureCookies: process.env.SECURE_COOKIES } \ No newline at end of file diff --git a/webUISetup/index.html b/webUISetup/index.html index 7d14e92..83bc321 100644 --- a/webUISetup/index.html +++ b/webUISetup/index.html @@ -60,40 +60,6 @@ -
-
-

Activate Commercial Mode?

-
-
- -
-
- -
-
-

Enter Stripe API Key

-
-
-
- -
-
-
- - -

Enter MongoDB URL

@@ -110,7 +76,7 @@

Use WebUI For Encryption Key (Recommended, Selecting No Will Require You To Enter An Encryption Key Now, Which Is Less Secure)

- @@ -124,13 +90,14 @@
-

Enter The Client URL/IP Address (Must Be A Valid Link, Include Port With IP Address If Needed)

+

Enter The Client URL/IP Address (Must Be A Valid Link, If Using a URL Start With "https://" or "http://", Include Port With IP Address If Needed, Do Not End The URL In a Slash "/")

+

Error: URL Cannot End In a Slash ("/")

@@ -141,7 +108,7 @@
@@ -185,7 +152,7 @@
-
+ + +
+
+

Enter Access Token Secret

+
+
+
+ +
+
+
+

Enter Refresh Token Secret

+
+
+
+ +
+
+
+ +
+
+

Enter Cookie Secret

+
+
+
+ +
+
+
+ +
+
+

Use Secure Cookies? (You Can Only Use Secure Cookies If You Are Using HTTPS/SSL, Do Not Select This Option If You Do Not Have HTTPS or else Cookies/Logging in Will Not Work At All. This is Highly Recommended if You Have HTTPS/SSL)

+
+
+ +
+
+ +
+
+

Use SendGrid To Send Emails? (For Account Email Verification And Password Resets)

+
+
+ +
+
+ +

Enter A SendGrid API Key

@@ -207,7 +231,7 @@
-
+

Enter Email Address, This Will Be The Email Address For Sending Email Verifications, And Password Resets.

@@ -220,7 +244,7 @@
-

Use SSL? (Will Require SSL Certificate certificate.crt, certificate.ca-bundle, And certificate.key At Root Of The Project)

+

Use SSL? (Will Require SSL Certificate certificate.crt, certificate.ca-bundle, And certificate.key At Root Of The Project. If You Are Hosting On a Service That Already Provides HTTPS/SSL Select No)