Skip to content

Commit

Permalink
Merge branch 'alpha' into fix/express-mount-path
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza authored Jun 27, 2024
2 parents 64126a5 + 8feac9b commit 119bf2f
Show file tree
Hide file tree
Showing 374 changed files with 34,778 additions and 23,987 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"]
}
}
10 changes: 5 additions & 5 deletions .github/workflows/ci-automated-check-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout default branch
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 14
node-version: 18
- name: Cache Node.js modules
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -36,7 +36,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout default branch
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Compose branch name for PR
id: branch
run: echo "::set-output name=name::ci-bump-environment"
Expand Down
40 changes: 19 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ on:
branches:
- '**'
env:
NODE_VERSION: 18.9.0
NODE_VERSION: 20.11.1
jobs:
check-ci:
name: Node Engine Check
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache Node.js modules
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -34,13 +34,13 @@ jobs:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache Node.js modules
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -54,13 +54,13 @@ jobs:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache Node.js modules
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
Expand All @@ -102,21 +102,19 @@ jobs:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Check NPM lock file version
uses: mansona/npm-lockfile-version@v1
with:
version: 1
version: 3
check-build:
strategy:
matrix:
include:
- name: Node 14
NODE_VERSION: 14.20.1
- name: Node 16
NODE_VERSION: 16.17.0
- name: Node 18
NODE_VERSION: 18.9.0
NODE_VERSION: 18.19.1
- name: Node 20
NODE_VERSION: 20.11.1
fail-fast: false
name: ${{ matrix.name }}
timeout-minutes: 15
Expand All @@ -131,13 +129,13 @@ jobs:
echo "::set-output name=node_major::$(echo $node_major)"
- name: Fix usage of insecure GitHub protocol
run: sudo git config --system url."https://github".insteadOf "git://github"
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.NODE_VERSION }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.NODE_VERSION }}
- name: Cache Node.js modules
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-automated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
persist-credentials: false
- uses: actions/setup-node@v2
with:
node-version: 14
node-version: 18
registry-url: https://registry.npmjs.org/
- name: Cache Node.js modules
uses: actions/cache@v2
Expand Down
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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
############################################################
# Build stage
############################################################
FROM node:lts-alpine AS build
FROM node:20.14.0-alpine3.20 AS build

RUN apk --no-cache add git
WORKDIR /src
Expand All @@ -27,7 +27,7 @@ RUN npm run prepare && npm run build
############################################################
# Release stage
############################################################
FROM node:lts-alpine AS release
FROM node:20.14.0-alpine3.20 AS release
WORKDIR /src

# Copy production node_modules
Expand Down
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
Loading

0 comments on commit 119bf2f

Please sign in to comment.