commit
c19b3febde
|
@ -2,19 +2,11 @@
|
||||||
|
|
||||||
(For contributors - scroll down)
|
(For contributors - scroll down)
|
||||||
|
|
||||||
### 1. Prerequisites (for nodegyp)
|
### 1. Global install budibase
|
||||||
|
|
||||||
We will try to make this bit easier, but for now:
|
|
||||||
|
|
||||||
- Windows - https://github.com/nodejs/node-gyp#on-windows
|
|
||||||
- Ubuntu `sudo apt-get install build-essentials`
|
|
||||||
- Mac: https://github.com/nodejs/node-gyp#on-macos
|
|
||||||
|
|
||||||
### 2. Global install budibase
|
|
||||||
|
|
||||||
`npm install -g budibase`
|
`npm install -g budibase`
|
||||||
|
|
||||||
### 3. Start using Budibase
|
### 2. Start using Budibase
|
||||||
|
|
||||||
Create a directory to store your Budibase apps
|
Create a directory to store your Budibase apps
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,6 +13,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
|
"test:watch": "jest --watch",
|
||||||
"build": "rollup -c rollup.config.js"
|
"build": "rollup -c rollup.config.js"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
@ -50,7 +51,6 @@
|
||||||
"@babel/plugin-transform-runtime": "^7.4.4",
|
"@babel/plugin-transform-runtime": "^7.4.4",
|
||||||
"@babel/preset-env": "^7.4.5",
|
"@babel/preset-env": "^7.4.5",
|
||||||
"@babel/runtime": "^7.4.5",
|
"@babel/runtime": "^7.4.5",
|
||||||
"argon2": "^0.20.1",
|
|
||||||
"babel-eslint": "^10.0.2",
|
"babel-eslint": "^10.0.2",
|
||||||
"babel-jest": "^23.6.0",
|
"babel-jest": "^23.6.0",
|
||||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
|
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
|
||||||
|
@ -72,6 +72,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nx-js/compiler-util": "^2.0.0",
|
"@nx-js/compiler-util": "^2.0.0",
|
||||||
|
"bcryptjs": "^2.4.3",
|
||||||
"date-fns": "^1.29.0",
|
"date-fns": "^1.29.0",
|
||||||
"lodash": "^4.17.13",
|
"lodash": "^4.17.13",
|
||||||
"lunr": "^2.3.5",
|
"lunr": "^2.3.5",
|
||||||
|
|
|
@ -1,17 +1,6 @@
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
Install requires [node-gyp](https://github.com/nodejs/node-gyp), due to a dependancy on [argon2](https://github.com/ranisalt/node-argon2)
|
Install packages:
|
||||||
|
|
||||||
### For node gyp on windows
|
|
||||||
|
|
||||||
`npm install --global --production windows-build-tools`
|
|
||||||
and this might help: https://github.com/nodejs/node-gyp/issues/1278
|
|
||||||
|
|
||||||
### For node gyp on ubuntu
|
|
||||||
|
|
||||||
`sudo apt-get install build-essentials`
|
|
||||||
|
|
||||||
Once you have this, try...
|
|
||||||
|
|
||||||
`npm install`
|
`npm install`
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ export const _authenticate = async (app, username, password) => {
|
||||||
|
|
||||||
const permissions = await buildUserPermissions(app, user.accessLevels);
|
const permissions = await buildUserPermissions(app, user.accessLevels);
|
||||||
|
|
||||||
const verified = await app.crypto.verify(
|
const verified = app.crypto.verify(
|
||||||
userAuth.passwordHash,
|
userAuth.passwordHash,
|
||||||
password,
|
password,
|
||||||
);
|
);
|
||||||
|
@ -89,7 +89,7 @@ export const authenticateTemporaryAccess = app => async (tempAccessCode) => {
|
||||||
if (userAuth.temporaryAccessExpiryEpoch < await app.getEpochTime()) { user = notAUser; }
|
if (userAuth.temporaryAccessExpiryEpoch < await app.getEpochTime()) { user = notAUser; }
|
||||||
|
|
||||||
const tempCode = !temp.code ? generate() : temp.code;
|
const tempCode = !temp.code ? generate() : temp.code;
|
||||||
const verified = await app.crypto.verify(
|
const verified = app.crypto.verify(
|
||||||
userAuth.temporaryAccessHash,
|
userAuth.temporaryAccessHash,
|
||||||
tempCode,
|
tempCode,
|
||||||
);
|
);
|
||||||
|
|
|
@ -66,7 +66,7 @@ export const getTemporaryCode = async (app) => {
|
||||||
const tempId = generate();
|
const tempId = generate();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
temporaryAccessHash: await app.crypto.hash(
|
temporaryAccessHash: app.crypto.hash(
|
||||||
tempCode,
|
tempCode,
|
||||||
),
|
),
|
||||||
temporaryAccessExpiryEpoch:
|
temporaryAccessExpiryEpoch:
|
||||||
|
|
|
@ -75,7 +75,7 @@ const getAccess = async (app, password) => {
|
||||||
|
|
||||||
if (isNonEmptyString(password)) {
|
if (isNonEmptyString(password)) {
|
||||||
if (isValidPassword(password)) {
|
if (isValidPassword(password)) {
|
||||||
auth.passwordHash = await app.crypto.hash(password);
|
auth.passwordHash = app.crypto.hash(password);
|
||||||
auth.temporaryAccessHash = '';
|
auth.temporaryAccessHash = '';
|
||||||
auth.temporaryAccessId = '';
|
auth.temporaryAccessId = '';
|
||||||
auth.temporaryAccessExpiryEpoch = 0;
|
auth.temporaryAccessExpiryEpoch = 0;
|
||||||
|
|
|
@ -30,7 +30,7 @@ export const _changeMyPassword = async (app, currentPw, newpassword) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isSomething(existingAuth.passwordHash)) {
|
if (isSomething(existingAuth.passwordHash)) {
|
||||||
const verified = await app.crypto.verify(
|
const verified = app.crypto.verify(
|
||||||
existingAuth.passwordHash,
|
existingAuth.passwordHash,
|
||||||
currentPw,
|
currentPw,
|
||||||
);
|
);
|
||||||
|
@ -73,7 +73,7 @@ export const _setPasswordFromTemporaryCode = async (app, tempCode, newpassword)
|
||||||
|
|
||||||
if (isSomething(existingAuth.temporaryAccessHash)
|
if (isSomething(existingAuth.temporaryAccessHash)
|
||||||
&& existingAuth.temporaryAccessExpiryEpoch > currentTime) {
|
&& existingAuth.temporaryAccessExpiryEpoch > currentTime) {
|
||||||
const verified = await app.crypto.verify(
|
const verified = app.crypto.verify(
|
||||||
existingAuth.temporaryAccessHash,
|
existingAuth.temporaryAccessHash,
|
||||||
temp.code,
|
temp.code,
|
||||||
);
|
);
|
||||||
|
@ -93,7 +93,7 @@ export const _setPasswordFromTemporaryCode = async (app, tempCode, newpassword)
|
||||||
const doSet = async (app, auth, username, newpassword) => {
|
const doSet = async (app, auth, username, newpassword) => {
|
||||||
auth.temporaryAccessHash = '';
|
auth.temporaryAccessHash = '';
|
||||||
auth.temporaryAccessExpiryEpoch = 0;
|
auth.temporaryAccessExpiryEpoch = 0;
|
||||||
auth.passwordHash = await app.crypto.hash(
|
auth.passwordHash = app.crypto.hash(
|
||||||
newpassword,
|
newpassword,
|
||||||
);
|
);
|
||||||
await app.datastore.updateJson(
|
await app.datastore.updateJson(
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import {
|
import {
|
||||||
|
|
||||||
head,
|
head,
|
||||||
tail, findIndex, startsWith,
|
tail, findIndex, startsWith,
|
||||||
dropRight, flow, takeRight, trim,
|
dropRight, flow, takeRight, trim,
|
||||||
|
@ -17,6 +16,7 @@ import {
|
||||||
getLock, NO_LOCK,
|
getLock, NO_LOCK,
|
||||||
isNolock
|
isNolock
|
||||||
} from './lock';
|
} from './lock';
|
||||||
|
import crypto from "./nodeCrypto";
|
||||||
|
|
||||||
// this is the combinator function
|
// this is the combinator function
|
||||||
export const $$ = (...funcs) => arg => flow(funcs)(arg);
|
export const $$ = (...funcs) => arg => flow(funcs)(arg);
|
||||||
|
@ -211,6 +211,7 @@ export {
|
||||||
getLock, NO_LOCK, releaseLock,
|
getLock, NO_LOCK, releaseLock,
|
||||||
extendLock, isNolock,
|
extendLock, isNolock,
|
||||||
} from './lock';
|
} from './lock';
|
||||||
|
export { crypto };
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
ifExists,
|
ifExists,
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
import bcrypt from "bcryptjs";
|
||||||
|
|
||||||
|
function hash(password) {
|
||||||
|
return bcrypt.hashSync(password, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
function verify(hash, password) {
|
||||||
|
return bcrypt.compareSync(password, hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
hash, verify
|
||||||
|
};
|
|
@ -6,7 +6,7 @@ import getAuthApi from "./authApi";
|
||||||
import getActionsApi from "./actionsApi";
|
import getActionsApi from "./actionsApi";
|
||||||
import {setupDatastore, createEventAggregator} from "./appInitialise";
|
import {setupDatastore, createEventAggregator} from "./appInitialise";
|
||||||
import {initialiseActions} from "./actionsApi/initialise"
|
import {initialiseActions} from "./actionsApi/initialise"
|
||||||
import {isSomething} from "./common";
|
import {isSomething, crypto} from "./common";
|
||||||
import {cleanup} from "./transactions/cleanup";
|
import {cleanup} from "./transactions/cleanup";
|
||||||
import {generateFullPermissions} from "./authApi/generateFullPermissions";
|
import {generateFullPermissions} from "./authApi/generateFullPermissions";
|
||||||
import {getApplicationDefinition} from "./templateApi/getApplicationDefinition";
|
import {getApplicationDefinition} from "./templateApi/getApplicationDefinition";
|
||||||
|
@ -111,5 +111,6 @@ export {initialiseData} from "./appInitialise/initialiseData";
|
||||||
export {getDatabaseManager} from "./appInitialise/databaseManager";
|
export {getDatabaseManager} from "./appInitialise/databaseManager";
|
||||||
export {hierarchy};
|
export {hierarchy};
|
||||||
export {common};
|
export {common};
|
||||||
|
export {crypto};
|
||||||
|
|
||||||
export default getAppApis;
|
export default getAppApis;
|
|
@ -7,7 +7,7 @@ import {permission} from "../src/authApi/permissions";
|
||||||
|
|
||||||
describe("authApi > authenticate", () => {
|
describe("authApi > authenticate", () => {
|
||||||
|
|
||||||
it("should return user + access when correct password supplied", async () => {
|
fit("should return user + access when correct password supplied", async () => {
|
||||||
const {authApi, app} = await setupApphierarchy(basicAppHierarchyCreator_WithFields);
|
const {authApi, app} = await setupApphierarchy(basicAppHierarchyCreator_WithFields);
|
||||||
const u = await validUser(app, authApi, "password");
|
const u = await validUser(app, authApi, "password");
|
||||||
const result = await authApi.authenticate(u.name, "password");
|
const result = await authApi.authenticate(u.name, "password");
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
import {hash, verify} from "argon2";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
hash, verify
|
|
||||||
};
|
|
|
@ -6,7 +6,9 @@ import {setupDatastore} from "../src/appInitialise";
|
||||||
import {configFolder, fieldDefinitions,
|
import {configFolder, fieldDefinitions,
|
||||||
templateDefinitions,
|
templateDefinitions,
|
||||||
joinKey,
|
joinKey,
|
||||||
isSomething} from "../src/common";
|
isSomething,
|
||||||
|
crypto as nodeCrypto
|
||||||
|
} from "../src/common";
|
||||||
import { getNewIndexTemplate } from "../src/templateApi/createNodes";
|
import { getNewIndexTemplate } from "../src/templateApi/createNodes";
|
||||||
import {indexTypes} from "../src/templateApi/indexes";
|
import {indexTypes} from "../src/templateApi/indexes";
|
||||||
import getTemplateApi from "../src/templateApi";
|
import getTemplateApi from "../src/templateApi";
|
||||||
|
@ -17,7 +19,6 @@ import {createBehaviourSources} from "../src/actionsApi/buildBehaviourSource";
|
||||||
import {createAction, createTrigger} from "../src/templateApi/createActions";
|
import {createAction, createTrigger} from "../src/templateApi/createActions";
|
||||||
import {initialiseActions} from "../src/actionsApi/initialise";
|
import {initialiseActions} from "../src/actionsApi/initialise";
|
||||||
import {cleanup} from "../src/transactions/cleanup";
|
import {cleanup} from "../src/transactions/cleanup";
|
||||||
import nodeCrypto from "./nodeCrypto";
|
|
||||||
import {permission} from "../src/authApi/permissions";
|
import {permission} from "../src/authApi/permissions";
|
||||||
import {generateFullPermissions} from "../src/authApi/generateFullPermissions"
|
import {generateFullPermissions} from "../src/authApi/generateFullPermissions"
|
||||||
import {initialiseData} from "../src/appInitialise/initialiseData";
|
import {initialiseData} from "../src/appInitialise/initialiseData";
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
const {hash, verify} = require("argon2");
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
hash, verify
|
|
||||||
};
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,7 +19,6 @@
|
||||||
"@budibase/client": "^0.0.15",
|
"@budibase/client": "^0.0.15",
|
||||||
"@budibase/core": "^0.0.15",
|
"@budibase/core": "^0.0.15",
|
||||||
"@koa/router": "^8.0.0",
|
"@koa/router": "^8.0.0",
|
||||||
"argon2": "^0.23.0",
|
|
||||||
"fs-extra": "^8.1.0",
|
"fs-extra": "^8.1.0",
|
||||||
"koa": "^2.7.0",
|
"koa": "^2.7.0",
|
||||||
"koa-body": "^4.1.0",
|
"koa-body": "^4.1.0",
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
const crypto = require("../nodeCrypto");
|
const {getAppApis, getTemplateApi, crypto } = require("@budibase/core");
|
||||||
const {getAppApis, getTemplateApi} = require("@budibase/core");
|
|
||||||
const getDatastore = require("./datastore");
|
const getDatastore = require("./datastore");
|
||||||
const { masterAppPackage } = require("../utilities/createAppPackage");
|
const { masterAppPackage } = require("../utilities/createAppPackage");
|
||||||
const getDatabaseManager = require("../utilities/databaseManager");
|
const getDatabaseManager = require("../utilities/databaseManager");
|
||||||
|
|
20
readme.md
20
readme.md
|
@ -2,19 +2,11 @@
|
||||||
|
|
||||||
(For contributors - scroll down)
|
(For contributors - scroll down)
|
||||||
|
|
||||||
### 1. Prerequisites (for nodegyp)
|
### 1. Global install budibase
|
||||||
|
|
||||||
We will try to make this bit easier, but for now:
|
|
||||||
|
|
||||||
- Windows - https://github.com/nodejs/node-gyp#on-windows
|
|
||||||
- Ubuntu `sudo apt-get install build-essentials`
|
|
||||||
- Mac: https://github.com/nodejs/node-gyp#on-macos
|
|
||||||
|
|
||||||
### 2. Global install budibase
|
|
||||||
|
|
||||||
`npm install -g budibase`
|
`npm install -g budibase`
|
||||||
|
|
||||||
### 3. Start using Budibase
|
### 2. Start using Budibase
|
||||||
|
|
||||||
Create a directory to store your Budibase apps
|
Create a directory to store your Budibase apps
|
||||||
|
|
||||||
|
@ -44,16 +36,8 @@ Once you have created your app, you need to create yourself an instance of your
|
||||||
|
|
||||||
## Getting Started for Contributors
|
## Getting Started for Contributors
|
||||||
|
|
||||||
Install requires [node-gyp](https://github.com/nodejs/node-gyp), due to a dependancy on [argon2](https://github.com/ranisalt/node-argon2)
|
|
||||||
|
|
||||||
### 1. Prerequisites
|
### 1. Prerequisites
|
||||||
|
|
||||||
*nodegyp -*
|
|
||||||
|
|
||||||
- Windows - https://github.com/nodejs/node-gyp#on-windows
|
|
||||||
- Ubuntu `sudo apt-get install build-essentials`
|
|
||||||
- Mac: https://github.com/nodejs/node-gyp#on-macos
|
|
||||||
|
|
||||||
*yarn -* `npm install -g yarn`
|
*yarn -* `npm install -g yarn`
|
||||||
|
|
||||||
*jest* - `npm install -g jest`
|
*jest* - `npm install -g jest`
|
||||||
|
|
Loading…
Reference in New Issue