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?
-
-
-
- No
- Yes
-
-
-
-
-
-
-
-
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)
-
+
Yes
No
@@ -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 @@
FileSystem
Amazon S3
- MongoDB
+ MongoDB (Not Recommended)
@@ -185,7 +152,7 @@
-
+
+
+
+
+
Enter Access Token Secret
+
+
+
+
+
+
Enter Refresh Token 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)
+
+
+
+ No
+ Yes
+
+
+
+
+
+
+
Use SendGrid To Send Emails? (For Account Email Verification And Password Resets)
+
+
+
+ No
+ Yes
+
+
+
+
+
-
+
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)
diff --git a/webUISetup/src/index.js b/webUISetup/src/index.js
index fbb78fa..d197aed 100644
--- a/webUISetup/src/index.js
+++ b/webUISetup/src/index.js
@@ -19,14 +19,19 @@ const s3IDInput = document.getElementById("s3-id-input");
const s3KeyInput = document.getElementById("s3-key-input");
const s3BucketInput = document.getElementById("s3-bucket-input");
const fsInput = document.getElementById("fs-input");
-const jwtInput = document.getElementById("jwt-input");
const SSLSelect = document.getElementById("ssl-select");
const sendGridInput = document.getElementById("sendgrid-input");
const sendGridInputEmail = document.getElementById("sendgrid-input-email");
-const commericalSelection = document.getElementById('commercial-select');
-const stripeWrapper = document.getElementById('stripe-wrapper');
// const stripeEmailWrapper = document.getElementById('stripe-wrapper-email');
-const stripeInput = document.getElementById('stripe-input');
+const sendGridSelect = document.getElementById("sendgrid-select")
+const sendGridWrapper = document.getElementById("sendgrid-wrapper");
+const sendGridWrapper2 = document.getElementById("sendgrid-wrapper2");
+const clientInvalidInputText = document.getElementById("client-input-invalid-text");
+
+const accessTokenInput = document.getElementById("access-token-input");
+const refreshTokenInput = document.getElementById("refresh-token-input")
+const cookieInput = document.getElementById("cookie-input");
+const secureCookieSelect = document.getElementById("secure-cookie-select");
//const stripeInputEmail = document.getElementById('stripe-input-email');
dockerSelection.addEventListener("change", (e) => {
@@ -54,17 +59,6 @@ dockerSelectionMongoURL.addEventListener("change", () => {
}
})
-commericalSelection.addEventListener('change', (e) => {
-
- const commericalMode = commericalSelection.value === 'yes';
-
- if (commericalMode) {
- stripeWrapper.className = 'section-wrapper';
- } else {
- stripeWrapper.className = 'docker-hidden'
- }
-})
-
encryptionSelect.addEventListener("change", () => {
const useWebUIForEncryption = encryptionSelect.value === "yes";
@@ -81,6 +75,8 @@ encryptionSelect.addEventListener("change", () => {
dbSelect.addEventListener("change", () => {
+ console.log("db select on change")
+
const storageType = dbSelect.value;
if (storageType === "s3") {
@@ -100,6 +96,52 @@ dbSelect.addEventListener("change", () => {
}
})
+sendGridSelect.addEventListener("change", () => {
+
+ //section-wrapper
+
+ const sendGridEnabled = sendGridSelect.value === "yes";
+
+ if (sendGridEnabled) {
+
+ sendGridWrapper.className = 'section-wrapper'
+ sendGridWrapper2.className = 'section-wrapper'
+
+ } else {
+
+ sendGridWrapper.classList = "docker-hidden";
+ sendGridWrapper2.classList = "docker-hidden";
+ }
+})
+
+clientInput.addEventListener("input", () => {
+
+ const value = clientInput.value;
+ console.log("value", value)
+
+ if (value && value.length !== 0) {
+
+ const lastCharacter = value[value.length - 1];
+ console.log("last character", lastCharacter)
+
+ if (lastCharacter === "/") {
+
+ clientInput.className = "mongo-input input-invalid"
+ clientInvalidInputText.className = "invalid-input-text"
+
+ } else {
+
+ clientInput.className = "mongo-input";
+ clientInvalidInputText.className = "invalid-input-text-hidden"
+ }
+
+ } else {
+ clientInput.className = "mongo-input"
+ clientInvalidInputText.className = "invalid-input-text-hidden"
+ }
+
+})
+
saveButton.addEventListener("click", () => {
let clientObj = {}
@@ -107,8 +149,8 @@ saveButton.addEventListener("click", () => {
// Client
clientObj.REMOTE_URL = clientInput.value;
- if (dbSelect.value !== "fs") clientObj.DISABLE_STORAGE = true;
- if (commericalSelection.value === "yes") clientObj.COMMERCIAL_MODE = true;
+ clientObj.DISABLE_STORAGE = true;
+ //if (dbSelect.value !== "fs") clientObj.DISABLE_STORAGE = true;
// Server
serverObj.HTTP_PORT = 3000;
@@ -119,33 +161,36 @@ saveButton.addEventListener("click", () => {
if (encryptionSelect.value !== "yes") serverObj.KEY = encryptionInput.value;
if (dockerSelection.value === "yes") serverObj.DOCKER = true;
if (SSLSelect.value === "yes") serverObj.SSL = true;
- if (commericalSelection.value === "yes") serverObj.STRIPE_KEY = stripeInput.value;
- serverObj.DB_TYPE = dbSelect.value;
- serverObj.PASSWORD = jwtInput.value;
- serverObj.SENDGRID_KEY = sendGridInput.value;
- serverObj.SENDGRID_EMAIL = sendGridInputEmail.value
+ if (secureCookieSelect.value === "yes") serverObj.SECURE_COOKIES = true;
+ if (sendGridSelect.value === "no") serverObj.DISABLE_EMAIL_VERIFICATION = true;
+ if (sendGridSelect.value === "yes") serverObj.SENDGRID_KEY = sendGridInput.value;
+ if (sendGridSelect.value === "yes") serverObj.SENDGRID_EMAIL = sendGridInputEmail.value
+ serverObj.DB_TYPE = dbSelect.value;
serverObj.REMOTE_URL = clientInput.value;
+ serverObj.PASSWORD_ACCESS = accessTokenInput.value;
+ serverObj.PASSWORD_REFRESH = refreshTokenInput.value;
+ serverObj.PASSWORD_COOKIE = cookieInput.value;
if (dbSelect.value === "s3") {
serverObj.S3_ID = s3IDInput.value;
serverObj.S3_KEY = s3KeyInput.value;
serverObj.S3_BUCKET = s3BucketInput.value;
- clientObj.DISABLE_STORAGE = true;
} else if (dbSelect.value === "fs") {
serverObj.FS_DIRECTORY = fsInput.value;
serverObj.ROOT = fsInput.value;
- } else {
- clientObj.DISABLE_STORAGE = true;
- }
+ }
const data = {
clientObj,
serverObj
}
+ console.log("data", data);
+ return;
+
axios.post("/submit", data).then((result) => {
console.log("Submitted");
diff --git a/webUISetup/src/styles.css b/webUISetup/src/styles.css
index 40d09b2..11a501a 100644
--- a/webUISetup/src/styles.css
+++ b/webUISetup/src/styles.css
@@ -129,6 +129,22 @@ html {
width: 286px;
}
+.input-invalid {
+ border: 1px solid red;
+ outline: 1px solid red;
+}
+
+.invalid-input-text {
+ text-align: center;
+ font-size: 17px;
+ margin-top: 5px;
+ color: red;
+}
+
+.invalid-input-text-hidden {
+ display: none;
+}
+
.encryption-key-input {
border: 1px solid #f1f3f4;
/* height: 50px; */