updated setup
This commit is contained in:
@@ -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
|
||||
})
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
+64
-40
@@ -60,40 +60,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section-wrapper">
|
||||
<div id="docker-text__wrapper">
|
||||
<p id="docker-text">Activate Commercial Mode?</p>
|
||||
</div>
|
||||
<div id="docker-select__wrapper">
|
||||
<select id="commercial-select" name="Commercial" class="docker-select">
|
||||
<option value="no">No</option>
|
||||
<option value="yes">Yes</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="stripe-wrapper" class="docker-hidden">
|
||||
<div id="docker-text__wrapper">
|
||||
<p id="docker-text">Enter Stripe API Key</p>
|
||||
</div>
|
||||
<div id="docker-select__wrapper">
|
||||
<form id="mongo-form">
|
||||
<input id="stripe-input" class="mongo-input" placeholder="Stripe API Key" type="password"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div id="stripe-wrapper-email" class="docker-hidden">
|
||||
<div id="docker-text__wrapper">
|
||||
<p id="docker-text">Enter Stripe API Key</p>
|
||||
</div>
|
||||
<div id="docker-select__wrapper">
|
||||
<form id="mongo-form">
|
||||
<input id="stripe-input-email" class="mongo-input" placeholder="Stripe Email"/>
|
||||
</form>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div id="mongoURL-wrapper" class="section-wrapper">
|
||||
<div id="docker-text__wrapper">
|
||||
<p id="docker-text">Enter MongoDB URL</p>
|
||||
@@ -110,7 +76,7 @@
|
||||
<p id="docker-text">Use WebUI For Encryption Key (Recommended, Selecting No Will Require You To Enter An Encryption Key Now, Which Is Less Secure)</p>
|
||||
</div>
|
||||
<div id="docker-select__wrapper">
|
||||
<select id="encryption-select" name="docker" class="docker-select">
|
||||
<select id="encryption-select" name="encryption-key" class="docker-select">
|
||||
<option value="yes">Yes</option>
|
||||
<option value="no">No</option>
|
||||
</select>
|
||||
@@ -124,13 +90,14 @@
|
||||
|
||||
<div class="section-wrapper">
|
||||
<div id="docker-text__wrapper">
|
||||
<p id="docker-text">Enter The Client URL/IP Address (Must Be A Valid Link, Include Port With IP Address If Needed)</p>
|
||||
<p id="docker-text">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 "/")</p>
|
||||
</div>
|
||||
<div id="docker-select__wrapper">
|
||||
<form id="mongo-form">
|
||||
<input id="client-input" class="mongo-input" placeholder="Client URL"/>
|
||||
</form>
|
||||
</div>
|
||||
<p id="client-input-invalid-text" class="invalid-input-text-hidden">Error: URL Cannot End In a Slash ("/")</p>
|
||||
</div>
|
||||
|
||||
<div class="section-wrapper">
|
||||
@@ -141,7 +108,7 @@
|
||||
<select id="db-select" name="docker" class="docker-select">
|
||||
<option value="fs">FileSystem</option>
|
||||
<option value="s3">Amazon S3</option>
|
||||
<option value="mongo">MongoDB</option>
|
||||
<option value="mongo">MongoDB (Not Recommended)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -185,7 +152,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="filesystem-wrapper" class="section-wrapper">
|
||||
<!-- <div id="filesystem-wrapper" class="section-wrapper">
|
||||
<div id="docker-text__wrapper">
|
||||
<p id="docker-text">Enter JWT Secret</p>
|
||||
</div>
|
||||
@@ -194,9 +161,66 @@
|
||||
<input id="jwt-input" class="mongo-input" placeholder="JWT Secret" type="password"/>
|
||||
</form>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div id="filesystem-wrapper" class="section-wrapper">
|
||||
<div id="docker-text__wrapper">
|
||||
<p id="docker-text">Enter Access Token Secret</p>
|
||||
</div>
|
||||
<div id="docker-select__wrapper">
|
||||
<form id="mongo-form">
|
||||
<input id="access-token-input" class="mongo-input" placeholder="Access Token Secret" type="password"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="filesystem-wrapper" class="section-wrapper">
|
||||
<div id="docker-text__wrapper">
|
||||
<p id="docker-text">Enter Refresh Token Secret</p>
|
||||
</div>
|
||||
<div id="docker-select__wrapper">
|
||||
<form id="mongo-form">
|
||||
<input id="refresh-token-input" class="mongo-input" placeholder="Refresh Token Secret" type="password"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="filesystem-wrapper" class="section-wrapper">
|
||||
<div id="docker-text__wrapper">
|
||||
<p id="docker-text">Enter Cookie Secret</p>
|
||||
</div>
|
||||
<div id="docker-select__wrapper">
|
||||
<form id="mongo-form">
|
||||
<input id="cookie-input" class="mongo-input" placeholder="Cookie Secret" type="password"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="ssl-select-wrapper" class="section-wrapper">
|
||||
<div id="docker-text__wrapper">
|
||||
<p id="docker-text">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)</p>
|
||||
</div>
|
||||
<div id="docker-select__wrapper">
|
||||
<select id="secure-cookie-select" name="secure-cookie" class="docker-select">
|
||||
<option value="no">No</option>
|
||||
<option value="yes">Yes</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section-wrapper">
|
||||
<div id="docker-text__wrapper">
|
||||
<p id="docker-text">Use SendGrid To Send Emails? (For Account Email Verification And Password Resets)</p>
|
||||
</div>
|
||||
<div id="docker-select__wrapper">
|
||||
<select id="sendgrid-select" name="sendgrid" class="docker-select">
|
||||
<option value="no">No</option>
|
||||
<option value="yes">Yes</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="sendgrid-wrapper" class="docker-hidden">
|
||||
<div id="docker-text__wrapper">
|
||||
<p id="docker-text">Enter A SendGrid API Key</p>
|
||||
</div>
|
||||
@@ -207,7 +231,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="filesystem-wrapper" class="section-wrapper">
|
||||
<div id="sendgrid-wrapper2" class="docker-hidden">
|
||||
<div id="docker-text__wrapper">
|
||||
<p id="docker-text">Enter Email Address, This Will Be The Email Address For Sending Email Verifications, And Password Resets.</p>
|
||||
</div>
|
||||
@@ -220,7 +244,7 @@
|
||||
|
||||
<div id="ssl-select-wrapper" class="section-wrapper">
|
||||
<div id="docker-text__wrapper">
|
||||
<p id="docker-text">Use SSL? (Will Require SSL Certificate certificate.crt, certificate.ca-bundle, And certificate.key At Root Of The Project)</p>
|
||||
<p id="docker-text">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)</p>
|
||||
</div>
|
||||
<div id="docker-select__wrapper">
|
||||
<select id="ssl-select" name="docker" class="docker-select">
|
||||
|
||||
+71
-26
@@ -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");
|
||||
|
||||
|
||||
@@ -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; */
|
||||
|
||||
Reference in New Issue
Block a user