From 2007fc0fa46631d3f4ae66a46f8119a171f85a4e Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 9 Aug 2017 14:54:43 -0600 Subject: [PATCH 01/20] Update README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index a9d1172..1a7abff 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,19 @@ We're still in a stage where the installation generally requires many manual ste See [INSTALL.md](/INSTALL.md) +Usage +----- + +Here's how you run the thing, once installed: + +``` +/opt/walnut/bin/node /srv/walnut/core/bin/walnut.js +``` + +It listens on all addresses, port 3000. + +TODO: Add config to restrict listening to localhost. + API --- From 845989e16cbe5213d9bcfcc71dfcd2299fc33724 Mon Sep 17 00:00:00 2001 From: Drew Warren Date: Wed, 9 Aug 2017 17:42:15 -0600 Subject: [PATCH 02/20] Update INSTALL.md --- INSTALL.md | 1 + 1 file changed, 1 insertion(+) diff --git a/INSTALL.md b/INSTALL.md index cf5c950..70a44bf 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -224,6 +224,7 @@ It is intended to provide a way to use various mail services in the future, just bear with us for the time being (or open a Merge Request). ```bash +mkdir -p /srv/walnut/var/$my_domain vim /srv/walnut/var/$my_domain/config.json ``` From 1564655d2a50f7654ba4bf5bc962b86301815282 Mon Sep 17 00:00:00 2001 From: Drew Warren Date: Wed, 9 Aug 2017 17:51:47 -0600 Subject: [PATCH 03/20] Update INSTALL.md --- INSTALL.md | 1 - 1 file changed, 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 70a44bf..f39f152 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -231,7 +231,6 @@ vim /srv/walnut/var/$my_domain/config.json ```json { "mailgun.org": { "apiKey": "key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" - , "apiPublicKey": "pubkey-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" , "auth": { "user": "robtherobot@example.com" , "pass": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" From bb1ee7ab99bfebd0065359556860a2f71fe2cf1e Mon Sep 17 00:00:00 2001 From: Drew Warren Date: Thu, 10 Aug 2017 12:46:44 -0600 Subject: [PATCH 04/20] Update INSTALL.md --- INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index f39f152..98b0cbf 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -224,8 +224,8 @@ It is intended to provide a way to use various mail services in the future, just bear with us for the time being (or open a Merge Request). ```bash -mkdir -p /srv/walnut/var/$my_domain -vim /srv/walnut/var/$my_domain/config.json +mkdir -p /srv/walnut/var/provider.$my_domain +vim /srv/walnut/var/provider.$my_domain/config.json ``` ```json From 32f835aa30ca13df697fbaf0af11760407849c72 Mon Sep 17 00:00:00 2001 From: richdex14 Date: Mon, 4 Sep 2017 13:30:10 -0600 Subject: [PATCH 05/20] Update install.sh to use portable `sudo_cmd` syntax --- install.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 33d8948..3559ad4 100644 --- a/install.sh +++ b/install.sh @@ -1,5 +1,9 @@ #!/bin/bash +# Not every platform has or needs sudo, gotta save them O(1)s... +sudo_cmd="" +((EUID)) && [[ -z "$ANDROID_ROOT" ]] && sudo_cmd="sudo" + set -e set -u @@ -54,9 +58,9 @@ detect_http_get install_walnut() { - sudo mkdir -p /srv/walnut/{var,etc,packages,node_modules} + $sudo_cmd mkdir -p /srv/walnut/{var,etc,packages,node_modules} # www-data exists on linux, _www exists on mac OS - sudo chown -R $(whoami):www-data /srv/walnut || sudo chown -R $(whoami):_www /srv/walnut + $sudo_cmd chown -R $(whoami):www-data /srv/walnut || $sudo_cmd chown -R $(whoami):_www /srv/walnut if [ ! -d "/srv/walnut/core/" ]; then git clone https://git.daplie.com/Daplie/walnut.js.git /srv/walnut/core fi @@ -72,7 +76,7 @@ install_walnut() /srv/walnut/core/install-helper.sh /srv/walnut # Now that the install is finished we need to set the owner to the user that will actually # be running the walnut server. - sudo chown -R www-data:www-data /srv/walnut || sudo chown -R _www:_www /srv/walnut + $sudo_cmd chown -R www-data:www-data /srv/walnut || $sudo_cmd chown -R _www:_www /srv/walnut } # Install node From ed241595741db7d604820353ef45a8e66c9b0a74 Mon Sep 17 00:00:00 2001 From: richdex14 Date: Mon, 4 Sep 2017 13:42:38 -0600 Subject: [PATCH 06/20] Update install.sh to checkout master form walnut repo, `v1` tag outdated. --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 3559ad4..be94f3b 100644 --- a/install.sh +++ b/install.sh @@ -68,7 +68,7 @@ install_walnut() if [ ! -d "./.git/" ]; then echo "'/srv/walnut/core' exists but is not a git repository... not sure what to do here..." fi - git checkout v1 + git checkout master git pull popd rm -rf /srv/walnut/core/node_modules From ac5343c716773305c280c2e3c67be2bdcb468066 Mon Sep 17 00:00:00 2001 From: richdex14 Date: Mon, 4 Sep 2017 14:44:55 -0600 Subject: [PATCH 07/20] Update install-helper.sh to remove `v1` tag, which is outdated. --- install-helper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-helper.sh b/install-helper.sh index 2008c61..cd8bc9e 100755 --- a/install-helper.sh +++ b/install-helper.sh @@ -264,7 +264,7 @@ install_my_app() if [ ! -d "./.git/" ]; then echo "'/srv/walnut/core/lib/walnut@daplie.com/setup' exists but is not a git repository... not sure what to do here..." fi - git checkout v1 + git checkout master git pull popd From 76193b382229c01564e675ecae1ff21678fa43ae Mon Sep 17 00:00:00 2001 From: richdex14 Date: Wed, 6 Sep 2017 18:51:09 -0600 Subject: [PATCH 08/20] Update install-helper.sh to export `NODE_PATH` --- install-helper.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install-helper.sh b/install-helper.sh index cd8bc9e..97ac627 100755 --- a/install-helper.sh +++ b/install-helper.sh @@ -269,6 +269,8 @@ install_my_app() popd pushd /srv/walnut/core + export NODE_PATH=/opt/walnut/lib/node_modules + export NPM_CONFIG_PREFIX=/opt/walnut /opt/walnut/bin/npm install popd } From 34621cf28872fb77b1c9c11bedd0b6458afda13f Mon Sep 17 00:00:00 2001 From: richdex14 Date: Thu, 7 Sep 2017 10:30:18 -0600 Subject: [PATCH 09/20] Update install.sh to temporarily edit the `PATH` to ensure correct `node` and `npm` versions are used during installation. --- install.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index be94f3b..fd906a1 100644 --- a/install.sh +++ b/install.sh @@ -77,19 +77,31 @@ install_walnut() # Now that the install is finished we need to set the owner to the user that will actually # be running the walnut server. $sudo_cmd chown -R www-data:www-data /srv/walnut || $sudo_cmd chown -R _www:_www /srv/walnut -} +} # Install node +echo "----Installing Nodejs and NPM----" echo "v8.2.1" > /tmp/NODEJS_VER daplie-install-node-dev npm install -g npm@4 # Install goldilocks +echo "----Installing goldilocks.js----" daplie-install-goldilocks +echo "----Installing walnut.js----" +#$sudo_cmd mkdir -p /opt/goldilocks/{lib,bin,etc} +#export NODE_PATH=/opt/walnut/lib/node_modules +#export NPM_CONFIG_PREFIX=/opt/walnut +old_PATH=$PATH +export PATH=/opt/walnut/bin:$PATH + # Install walnut install_walnut +# Restore PATH to original value +export PATH=$old_PATH + echo "" echo "You must have some set of domain set up to properly use goldilocks+walnut:" echo "" From dcdae5e0e62df26d1c0c3f7bb9d4d2a837d0a318 Mon Sep 17 00:00:00 2001 From: richdex14 Date: Thu, 7 Sep 2017 10:32:49 -0600 Subject: [PATCH 10/20] Update walnut.service to use the `node` version installed as part of the walnut installation. --- dist/etc/systemd/system/walnut.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/etc/systemd/system/walnut.service b/dist/etc/systemd/system/walnut.service index 5f20e71..517da9c 100644 --- a/dist/etc/systemd/system/walnut.service +++ b/dist/etc/systemd/system/walnut.service @@ -27,7 +27,7 @@ Group=www-data # Set a sane working directory, sane flags, and specify how to reload the config file WorkingDirectory=/srv/www -ExecStart=/usr/local/bin/node /srv/walnut/core/bin/walnut.js --config=/etc/walnut/walnut.yml +ExecStart=/opt/walnut/bin/node /srv/walnut/core/bin/walnut.js --config=/etc/walnut/walnut.yml ExecReload=/bin/kill -USR1 $MAINPID # Limit the number of file descriptors and processes; see `man systemd.exec` for more limit settings. From ec4751683871103bafcb1edfe1fec5a35ccc4a89 Mon Sep 17 00:00:00 2001 From: richdex14 Date: Fri, 8 Sep 2017 11:13:44 -0600 Subject: [PATCH 11/20] Update install.sh to install bower through NPM in case the system is missing it. --- install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install.sh b/install.sh index fd906a1..0b32a45 100644 --- a/install.sh +++ b/install.sh @@ -99,6 +99,9 @@ export PATH=/opt/walnut/bin:$PATH # Install walnut install_walnut +# Install bower, some systems may be missing it, and it is a dependency +/opt/walnut/bin/npm install -g bower + # Restore PATH to original value export PATH=$old_PATH From 3a6264939e238fe0b1afa69aa12f263f65b4f5a8 Mon Sep 17 00:00:00 2001 From: richdex14 Date: Fri, 8 Sep 2017 11:34:04 -0600 Subject: [PATCH 12/20] Update install.sh to configure `bower` to allow usage under the root account, such as on single user systems such as our own. --- install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install.sh b/install.sh index 0b32a45..aad12e6 100644 --- a/install.sh +++ b/install.sh @@ -101,6 +101,8 @@ install_walnut # Install bower, some systems may be missing it, and it is a dependency /opt/walnut/bin/npm install -g bower +touch /.bowerrc +echo '{ "allow_root": true }' > /.bowerrc # Restore PATH to original value export PATH=$old_PATH From ae1b21bfb23c3ed1652b4599c3b10003d5fad8b0 Mon Sep 17 00:00:00 2001 From: Drew Warren Date: Fri, 8 Sep 2017 14:55:33 -0600 Subject: [PATCH 13/20] Update INSTALL.md --- INSTALL.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 98b0cbf..7998c3a 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -23,14 +23,14 @@ Pre-requisites: Choose a domain --------------- -For the purpose of this instruction we'll assume that your domain is `example.com`, +For the purpose of this instruction we'll assume that your domain is `foo.com`, but you can use, say, `johndoe.daplie.me` for testing through Daplie Domains. Anyway, go ahead and set the bash variable `$my_domain` for the purposes of the rest of this tutorial: ``` -my_domain=example.com +my_domain=foo.com ``` You can purchase a domain with daplie tools @@ -47,17 +47,17 @@ Subdomains Auth will be loaded with the following domains ``` -provider.example.com -api.provider.example.com +provider.foo.com +api.provider.foo.com ``` The Hello World app will be loaded with the following domains ``` -example.com -www.example.com -api.example.com -assets.example.com +foo.com +www.foo.com +api.foo.com +assets.foo.com ``` The domains can be setup through the Daplie Desktop App or with daplie-tools @@ -101,16 +101,16 @@ daplie-install-goldilocks Example `/etc/goldilocks/goldilocks.yml`: ```yml tls: - email: domains@example.com + email: user@mailservice.com servernames: - - example.com - - www.example.com - - api.example.com - - assets.example.com - - cloud.example.com - - api.cloud.example.com - - provider.example.com - - api.provider.example.com + - foo.com + - www.foo.com + - api.foo.com + - assets.foo.com + - cloud.foo.com + - api.cloud.foo.com + - provider.foo.com + - api.provider.foo.com http: trust_proxy: true From ae9e6bc16dfd1568e8a52025b295595ff85d4bab Mon Sep 17 00:00:00 2001 From: Drew Warren Date: Fri, 8 Sep 2017 16:20:52 -0600 Subject: [PATCH 14/20] Update INSTALL.md --- INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 7998c3a..4b3ba4c 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -162,8 +162,8 @@ Resetting the Initialization Once you run the app the initialization files will appear in these locations ``` -/srv/walnut/var/com.daplie.walnut.config.sqlite3 -/srv/walnut/config//config.json +/srv/walnut/var/walnut+config@daplie.com.sqlite3 +/srv/walnut/config/foo.com.json ``` Deleting those files and restarting walnut will reset it to its bootstrap state. From 8ad87bd779ecdc761f8925a56261c52c9281c2c7 Mon Sep 17 00:00:00 2001 From: Drew Warren Date: Fri, 8 Sep 2017 16:43:10 -0600 Subject: [PATCH 15/20] Update INSTALL.md --- INSTALL.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 4b3ba4c..a410b0b 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -266,8 +266,9 @@ What it should look like: models.js rest.js -/srv/walnut/packages/client-api-grants/example.com +/srv/walnut/packages/client-api-grants/provider.foo.com ''' + issuer@oauth3.org hello@example.com ''' ``` From fc604813e34100fd6b4af1533a7c18e7657a2c45 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 11 Sep 2017 12:48:31 -0600 Subject: [PATCH 16/20] Update INSTALL.md --- INSTALL.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index a410b0b..ee0a5f3 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -69,6 +69,9 @@ Replace `foodevice` with whatever you like to call this device my_device=foodevice # curl https://api.oauth3.org/api/tunnel@oauth3.org/checkip +# READ THIS: localhost is being used as an example. +# Your IP address should be public facing (i.e. port-forwarding is enabled on your router). +# If it isn't, then you need something like goldilocks providing a tunnel. my_address=127.0.0.1 # set device address and attach primary domain From b221e5b5f2e2fe26e437486bef188f0f9b8e7464 Mon Sep 17 00:00:00 2001 From: Drew Warren Date: Tue, 12 Sep 2017 15:20:45 -0600 Subject: [PATCH 17/20] Update INSTALL.md --- INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index ee0a5f3..6b2c644 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -95,7 +95,7 @@ Walnut must sit behind a proxy that properly terminates https and sets the `X-Fo Goldilocks can do this, as well as manage daplie domains, tunneling, etc. ```bash -curl https://daplie.me/install-scripts | bash +curl https://git.daplie.com/Daplie/daplie-snippets/raw/master/install.sh | bash daplie-install-goldilocks ``` @@ -128,7 +128,7 @@ Basic Walnut Install -------------------- ```bash -curl https://daplie.me/install-scripts | bash +curl https://git.daplie.com/Daplie/daplie-snippets/raw/master/install.sh | bash daplie-install-walnut ``` From ba2ed84b7a3e5d6c161a415518ee3725f2792db5 Mon Sep 17 00:00:00 2001 From: Drew Warren Date: Fri, 6 Oct 2017 18:03:03 -0600 Subject: [PATCH 18/20] Update INSTALL.md --- INSTALL.md | 1 + 1 file changed, 1 insertion(+) diff --git a/INSTALL.md b/INSTALL.md index 6b2c644..0570c74 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -19,6 +19,7 @@ Pre-requisites: * You own a domain * through Daplie Domains * or you understand domains and DNS and all that stuff +* Install bower `npm install -g bower` Choose a domain --------------- From 82e1f10d04809e823b601fd720aee6b909efce3d Mon Sep 17 00:00:00 2001 From: tigerbot Date: Thu, 19 Oct 2017 17:21:20 -0600 Subject: [PATCH 19/20] updated with repo to clone for issuer@oauth3.org in the docs --- INSTALL.md | 2 +- install-helper.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 0570c74..c633d69 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -192,7 +192,7 @@ For the APIs for that we'll install the `issuer@oauth3.org` API package and enab ```bash # API packaged for walnut -git clone https://git.daplie.com/OAuth3/org.oauth3.provider.git /srv/walnut/packages/rest/issuer@oauth3.org +git clone https://git.daplie.com/OAuth3/issuer_oauth3.org.git /srv/walnut/packages/rest/issuer@oauth3.org pushd /srv/walnut/packages/rest/issuer@oauth3.org/ git checkout v1.2 npm install diff --git a/install-helper.sh b/install-helper.sh index 97ac627..3d64f46 100755 --- a/install-helper.sh +++ b/install-helper.sh @@ -249,7 +249,6 @@ install_my_app() ln -sf ../node_modules /srv/walnut/core/node_modules mkdir -p /srv/walnut/var/sites mkdir -p /srv/walnut/etc/org.oauth3.consumer - mkdir -p /srv/walnut/etc/org.oauth3.provider mkdir -p /srv/walnut/etc/client-api-grants mkdir -p /srv/walnut/packages/{rest,api,pages,services} @@ -270,7 +269,7 @@ install_my_app() pushd /srv/walnut/core export NODE_PATH=/opt/walnut/lib/node_modules - export NPM_CONFIG_PREFIX=/opt/walnut + export NPM_CONFIG_PREFIX=/opt/walnut /opt/walnut/bin/npm install popd } From 5ae6a374fe0ba35662931ab1d0a5b49f365f89c5 Mon Sep 17 00:00:00 2001 From: tigerbot Date: Mon, 23 Oct 2017 15:36:48 -0600 Subject: [PATCH 20/20] added some dependencies to package.json searched through the code with a `git grep` to try finding all non-relative requires in non-browser / non-test code --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 7f8f644..8cfb406 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "connect-cors": "0.5.x", "connect-recase": "^1.0.2", "connect-send-error": "1.x", + "cookie-parser": "^1.4.3", "escape-html": "^1.0.2", "escape-string-regexp": "1.x", "express": "4.x", @@ -62,7 +63,9 @@ "nodemailer": "^1.4.0", "nodemailer-mailgun-transport": "1.x", "oauth3.js": "git+https://git.daplie.com/OAuth3/oauth3.js.git", + "recase": "^1.0.4", "request": "^2.81.0", + "scmp": "^2.0.0", "serve-static": "1.x", "sqlite3-cluster": "git+https://git.daplie.com/coolaj86/sqlite3-cluster.git#v2", "stripe": "^4.22.0",