add basic auth to server for beta editor setup

This commit is contained in:
Cassie Tarakajian 2018-08-21 16:09:41 -04:00
parent 63fe883528
commit bd476d3d38
5 changed files with 659 additions and 388 deletions

View file

@ -5,8 +5,6 @@ metadata:
annotations:
kubernetes.io/ingress.global-static-ip-name: "test-web-editor"
spec:
tls:
- secretName: sslcerts
backend:
serviceName: web-editor-node
servicePort: 8000

1031
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -88,6 +88,7 @@
"escape-string-regexp": "^1.0.5",
"eslint-loader": "^1.3.0",
"express": "^4.13.4",
"express-basic-auth": "^1.1.5",
"express-session": "^1.13.0",
"htmlhint": "^0.9.13",
"is-url": "^1.2.2",

View file

@ -8,6 +8,7 @@ import connectMongo from 'connect-mongo';
import passport from 'passport';
import path from 'path';
import { URL } from 'url';
import basicAuth from 'express-basic-auth';
// Webpack Requirements
import webpack from 'webpack';
@ -32,6 +33,16 @@ import { get404Sketch } from './views/404Page';
const app = new Express();
const MongoStore = connectMongo(session);
// For basic auth, in setting up beta editor
if (process.env.BASIC_USERNAME && process.env.BASIC_PASSWORD) {
app.use(basicAuth({
users: {
[process.env.BASIC_USERNAME]: process.env.BASIC_PASSWORD
},
challenge: true
}));
}
const corsOriginsWhitelist = [
/p5js\.org$/,
];

View file

@ -1,4 +1,6 @@
const webpack = require('webpack');
const path = require('path');
if (process.env.NODE_ENV === 'development') {
require('dotenv').config();
}