Skip to content

Commit

Permalink
build: Release (#2510)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza authored Nov 16, 2023
2 parents 5b85740 + daba564 commit 6ec8f9c
Show file tree
Hide file tree
Showing 363 changed files with 16,845 additions and 12,481 deletions.
24 changes: 20 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
{
"root": true,
"extends": "eslint:recommended",
"env": {
"es6": true,
"node": true,
"browser": true
},
"parser": "@babel/eslint-parser",
"extends": "eslint:recommended",
"plugins": [
"react"
],
"parserOptions": {
"sourceType": "module"
"ecmaVersion": 6,
"sourceType": "module",
"requireConfigFile": false
},
"plugins": ["react"],
"rules": {
"indent": ["error", 2, { "SwitchCase": 1 }],
"linebreak-style": ["error", "unix"],
"no-trailing-spaces": 2,
"eol-last": 2,
"space-in-parens": ["error", "never"],
"no-multiple-empty-lines": 1,
"prefer-const": "error",
"space-infix-ops": "error",
"no-useless-escape": "off",
"require-atomic-updates": "off",
"react/jsx-uses-vars": 1,
"react/jsx-uses-react": 1,
"react/react-in-jsx-scope": 1,
"no-console": 0,
"no-case-declarations": 0,
"quotes": ["error", "single"],
"eol-last": ["error", "always"]
"no-var": "error",
"no-prototype-builtins": "off",
"curly": ["error", "all"]
}
}
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
semi: true
trailingComma: "es5"
singleQuote: true
arrowParens: "avoid"
printWidth: 100
42 changes: 21 additions & 21 deletions Parse-Dashboard/Authentication.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
var bcrypt = require('bcryptjs');
var csrf = require('csurf');
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
const bcrypt = require('bcryptjs');
const csrf = require('csurf');
const passport = require('passport');
const LocalStrategy = require('passport-local').Strategy;
const OTPAuth = require('otpauth')

/**
Expand All @@ -20,11 +20,11 @@ function Authentication(validUsers, useEncryptedPasswords, mountPath) {

function initialize(app, options) {
options = options || {};
var self = this;
const self = this;
passport.use('local', new LocalStrategy(
{passReqToCallback:true},
function(req, username, password, cb) {
var match = self.authenticate({
const match = self.authenticate({
name: username,
pass: password,
otpCode: req.body.otpCode
Expand All @@ -47,13 +47,13 @@ function initialize(app, options) {
});

passport.deserializeUser(function(username, cb) {
var user = self.authenticate({
const user = self.authenticate({
name: username
}, true);
cb(null, user);
});

var cookieSessionSecret = options.cookieSessionSecret || require('crypto').randomBytes(64).toString('hex');
const cookieSessionSecret = options.cookieSessionSecret || require('crypto').randomBytes(64).toString('hex');
const cookieSessionMaxAge = options.cookieSessionMaxAge;
app.use(require('connect-flash')());
app.use(require('body-parser').urlencoded({ extended: true }));
Expand All @@ -67,16 +67,16 @@ function initialize(app, options) {

app.post('/login',
csrf(),
(req,res,next) => {
let redirect = 'apps';
if (req.body.redirect) {
redirect = req.body.redirect.charAt(0) === '/' ? req.body.redirect.substring(1) : req.body.redirect
}
return passport.authenticate('local', {
successRedirect: `${self.mountPath}${redirect}`,
failureRedirect: `${self.mountPath}login${req.body.redirect ? `?redirect=${req.body.redirect}` : ''}`,
failureFlash : true
})(req, res, next)
(req,res,next) => {
let redirect = 'apps';
if (req.body.redirect) {
redirect = req.body.redirect.charAt(0) === '/' ? req.body.redirect.substring(1) : req.body.redirect
}
return passport.authenticate('local', {
successRedirect: `${self.mountPath}${redirect}`,
failureRedirect: `${self.mountPath}login${req.body.redirect ? `?redirect=${req.body.redirect}` : ''}`,
failureFlash : true
})(req, res, next)
},
);

Expand All @@ -100,13 +100,13 @@ function authenticate(userToTest, usernameOnly) {
let otpValid = true;

//they provided auth
let isAuthenticated = userToTest &&
const isAuthenticated = userToTest &&
//there are configured users
this.validUsers &&
//the provided auth matches one of the users
this.validUsers.find(user => {
let isAuthenticated = false;
let usernameMatches = userToTest.name == user.user;
const usernameMatches = userToTest.name == user.user;
if (usernameMatches && user.mfa && !usernameOnly) {
if (!userToTest.otpCode) {
otpMissingLength = user.mfaDigits || 6;
Expand All @@ -126,7 +126,7 @@ function authenticate(userToTest, usernameOnly) {
}
}
}
let passwordMatches = this.useEncryptedPasswords && !usernameOnly ? bcrypt.compareSync(userToTest.pass, user.pass) : userToTest.pass == user.pass;
const passwordMatches = this.useEncryptedPasswords && !usernameOnly ? bcrypt.compareSync(userToTest.pass, user.pass) : userToTest.pass == user.pass;
if (usernameMatches && (usernameOnly || passwordMatches)) {
isAuthenticated = true;
matchingUsername = user.user;
Expand Down
4 changes: 2 additions & 2 deletions Parse-Dashboard/CLI/mfa.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const showInstructions = ({ app, username, passwordCopied, encrypt, config }) =>
`\n${getOrder()}. Make sure that "useEncryptedPasswords" is set to "true" in your dashboard configuration.` +
'\n You chose to generate an encrypted password for this user.' +
'\n Any existing users with non-encrypted passwords will require newly created, encrypted passwords.'
);
);
}
console.log(
'\n------------------------------------------------------------------------------\n'
Expand Down Expand Up @@ -198,7 +198,7 @@ module.exports = {
}
]);
const { algorithm, digits, period } = await getAlgorithm();
const secret =generateSecret({ app, username, algorithm, digits, period });
const secret = generateSecret({ app, username, algorithm, digits, period });
Object.assign(config, secret.config);
showQR(secret.config.url);
}
Expand Down
40 changes: 20 additions & 20 deletions Parse-Dashboard/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const path = require('path');
const packageJson = require('package-json');
const csrf = require('csurf');
const Authentication = require('./Authentication.js');
var fs = require('fs');
const fs = require('fs');

const currentVersionFeatures = require('../package.json').parseDashboardFeatures;

var newFeaturesInLatestVersion = [];
let newFeaturesInLatestVersion = [];
packageJson('parse-dashboard', { version: 'latest', fullMetadata: true })
.then(latestPackage => {
if (latestPackage.parseDashboardFeatures instanceof Array) {
Expand All @@ -31,29 +31,29 @@ function getMount(mountPath) {
}

function checkIfIconsExistForApps(apps, iconsFolder) {
for (var i in apps) {
var currentApp = apps[i];
var iconName = currentApp.iconName;
var path = iconsFolder + '/' + iconName;
for (const i in apps) {
const currentApp = apps[i];
const iconName = currentApp.iconName;
const path = iconsFolder + '/' + iconName;

fs.stat(path, function(err) {
if (err) {
if ('ENOENT' == err.code) {// file does not exist
console.warn('Icon with file name: ' + iconName +' couldn\'t be found in icons folder!');
} else {
console.log(
'An error occurd while checking for icons, please check permission!');
}
if ('ENOENT' == err.code) {// file does not exist
console.warn('Icon with file name: ' + iconName + ' couldn\'t be found in icons folder!');
} else {
console.log(
'An error occurd while checking for icons, please check permission!');
}
} else {
//every thing was ok so for example you can read it and send it to client
//every thing was ok so for example you can read it and send it to client
}
} );
});
}
}

module.exports = function(config, options) {
options = options || {};
var app = express();
const app = express();
// Serve public files.
app.use(express.static(path.join(__dirname,'public')));

Expand All @@ -72,7 +72,7 @@ module.exports = function(config, options) {

// CSRF error handler
app.use(function (err, req, res, next) {
if (err.code !== 'EBADCSRFTOKEN') return next(err)
if (err.code !== 'EBADCSRFTOKEN') {return next(err)}

// handle CSRF token errors here
res.status(403)
Expand All @@ -81,8 +81,8 @@ module.exports = function(config, options) {

// Serve the configuration.
app.get('/parse-dashboard-config.json', function(req, res) {
let apps = config.apps.map((app) => Object.assign({}, app)); // make a copy
let response = {
const apps = config.apps.map((app) => Object.assign({}, app)); // make a copy
const response = {
apps: apps,
newFeaturesInLatestVersion: newFeaturesInLatestVersion,
};
Expand Down Expand Up @@ -159,7 +159,7 @@ module.exports = function(config, options) {
// running parse-dashboard from globally installed npm.
if (config.iconsFolder) {
try {
var stat = fs.statSync(config.iconsFolder);
const stat = fs.statSync(config.iconsFolder);
if (stat.isDirectory()) {
app.use('/appicons', express.static(config.iconsFolder));
//Check also if the icons really exist
Expand Down Expand Up @@ -213,7 +213,7 @@ module.exports = function(config, options) {
}
return res.redirect(`${mountPath}login`);
}
if (users && req.user && req.user.matchingUsername ) {
if (users && req.user && req.user.matchingUsername) {
res.append('username', req.user.matchingUsername);
}
res.send(`<!DOCTYPE html>
Expand Down
28 changes: 14 additions & 14 deletions Parse-Dashboard/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ module.exports = (options) => {
process.exit(-1);
}

let explicitConfigFileProvided = !!options.config;
const explicitConfigFileProvided = !!options.config;
let configFile = null;
let configFromCLI = null;
let configServerURL = options.serverURL || process.env.PARSE_DASHBOARD_SERVER_URL;
let configGraphQLServerURL = options.graphQLServerURL || process.env.PARSE_DASHBOARD_GRAPHQL_SERVER_URL;
let configMasterKey = options.masterKey || process.env.PARSE_DASHBOARD_MASTER_KEY;
let configAppId = options.appId || process.env.PARSE_DASHBOARD_APP_ID;
let configAppName = options.appName || process.env.PARSE_DASHBOARD_APP_NAME;
let configUserId = options.userId || process.env.PARSE_DASHBOARD_USER_ID;
let configUserPassword = options.userPassword || process.env.PARSE_DASHBOARD_USER_PASSWORD;
let configSSLKey = options.sslKey || process.env.PARSE_DASHBOARD_SSL_KEY;
let configSSLCert = options.sslCert || process.env.PARSE_DASHBOARD_SSL_CERT;
const configServerURL = options.serverURL || process.env.PARSE_DASHBOARD_SERVER_URL;
const configGraphQLServerURL = options.graphQLServerURL || process.env.PARSE_DASHBOARD_GRAPHQL_SERVER_URL;
const configMasterKey = options.masterKey || process.env.PARSE_DASHBOARD_MASTER_KEY;
const configAppId = options.appId || process.env.PARSE_DASHBOARD_APP_ID;
const configAppName = options.appName || process.env.PARSE_DASHBOARD_APP_NAME;
const configUserId = options.userId || process.env.PARSE_DASHBOARD_USER_ID;
const configUserPassword = options.userPassword || process.env.PARSE_DASHBOARD_USER_PASSWORD;
const configSSLKey = options.sslKey || process.env.PARSE_DASHBOARD_SSL_KEY;
const configSSLCert = options.sslCert || process.env.PARSE_DASHBOARD_SSL_CERT;

function handleSIGs(server) {
const signals = {
Expand Down Expand Up @@ -143,10 +143,10 @@ module.exports = (options) => {

const app = express();

if (allowInsecureHTTP || trustProxy || dev) app.enable('trust proxy');
if (allowInsecureHTTP || trustProxy || dev) {app.enable('trust proxy');}

config.data.trustProxy = trustProxy;
let dashboardOptions = { allowInsecureHTTP, cookieSessionSecret, dev, cookieSessionMaxAge };
const dashboardOptions = { allowInsecureHTTP, cookieSessionSecret, dev, cookieSessionMaxAge };
app.use(mountPath, parseDashboard(config.data, dashboardOptions));
let server;
if(!configSSLKey || !configSSLCert){
Expand All @@ -156,8 +156,8 @@ module.exports = (options) => {
});
} else {
// Start the server using SSL.
var privateKey = fs.readFileSync(configSSLKey);
var certificate = fs.readFileSync(configSSLCert);
const privateKey = fs.readFileSync(configSSLKey);
const certificate = fs.readFileSync(configSSLCert);

server = require('https').createServer({
key: privateKey,
Expand Down
Loading

0 comments on commit 6ec8f9c

Please sign in to comment.