Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cc6b7bd7b4 | |||
| 9bdf3925a3 |
@@ -26,6 +26,8 @@ Content-Type: application/json
|
||||
//DOCS: Used for validating the email address specified above
|
||||
GET /auth/validation?username=example&token=12345678
|
||||
|
||||
//DOCS: If the environment variable HOOK_POST_VALIDATION is set to a URL, then the server will send a GET message to that URL with the newly created account's index
|
||||
GET https://{HOOK_POST_VALIDATION}?accountIndex={index}
|
||||
|
||||
###
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ const question = (prompt, def = null) => {
|
||||
//project configuration
|
||||
const appName = await question('App Name', 'auth');
|
||||
const appWebAddress = await question('Web Addr', `${appName}.example.com`);
|
||||
const postValidationHook = await question('Post Validation Hook', '');
|
||||
const resetAddress = await question('Reset Addr', `example.com/reset`);
|
||||
const appPort = await question('App Port', '3200');
|
||||
|
||||
@@ -70,6 +71,7 @@ services:
|
||||
environment:
|
||||
- WEB_PROTOCOL=https
|
||||
- WEB_ADDRESS=${appWebAddress}
|
||||
- HOOK_POST_VALIDATION=${postValidationHook}
|
||||
- WEB_RESET_ADDRESS=${resetAddress}
|
||||
- WEB_PORT=${appPort}
|
||||
- DB_HOSTNAME=database
|
||||
|
||||
Generated
+60
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "auth-server",
|
||||
"version": "1.4.5",
|
||||
"version": "1.4.7",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "auth-server",
|
||||
"version": "1.4.5",
|
||||
"version": "1.4.7",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"bcryptjs": "^2.4.3",
|
||||
@@ -16,6 +16,7 @@
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"mariadb": "^2.5.4",
|
||||
"node-cron": "^2.0.3",
|
||||
"node-fetch": "^2.6.6",
|
||||
"nodemailer": "^6.6.3",
|
||||
"sequelize": "^6.6.5"
|
||||
},
|
||||
@@ -1280,6 +1281,17 @@
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.6.6",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.6.tgz",
|
||||
"integrity": "sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/nodemailer": {
|
||||
"version": "6.6.3",
|
||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.6.3.tgz",
|
||||
@@ -1910,6 +1922,11 @@
|
||||
"nodetouch": "bin/nodetouch.js"
|
||||
}
|
||||
},
|
||||
"node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
|
||||
},
|
||||
"node_modules/type-fest": {
|
||||
"version": "0.8.1",
|
||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
|
||||
@@ -2045,6 +2062,20 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
|
||||
},
|
||||
"node_modules/whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
|
||||
"dependencies": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/widest-line": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/widest-line/-/widest-line-3.1.0.tgz",
|
||||
@@ -3092,6 +3123,14 @@
|
||||
"tz-offset": "0.0.1"
|
||||
}
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "2.6.6",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.6.tgz",
|
||||
"integrity": "sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==",
|
||||
"requires": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"nodemailer": {
|
||||
"version": "6.6.3",
|
||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.6.3.tgz",
|
||||
@@ -3561,6 +3600,11 @@
|
||||
"nopt": "~1.0.10"
|
||||
}
|
||||
},
|
||||
"tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
|
||||
},
|
||||
"type-fest": {
|
||||
"version": "0.8.1",
|
||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
|
||||
@@ -3663,6 +3707,20 @@
|
||||
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
|
||||
},
|
||||
"webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
|
||||
},
|
||||
"whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
|
||||
"requires": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"widest-line": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/widest-line/-/widest-line-3.1.0.tgz",
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "auth-server",
|
||||
"version": "1.4.5",
|
||||
"version": "1.4.7",
|
||||
"description": "An API centric auth server. Uses Sequelize and mariaDB by default.",
|
||||
"main": "server/server.js",
|
||||
"scripts": {
|
||||
@@ -26,6 +26,7 @@
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"mariadb": "^2.5.4",
|
||||
"node-cron": "^2.0.3",
|
||||
"node-fetch": "^2.6.6",
|
||||
"nodemailer": "^6.6.3",
|
||||
"sequelize": "^6.6.5"
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { pendingSignups, accounts } = require('../database/models');
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
//auth/validation
|
||||
const route = async (req, res) => {
|
||||
@@ -19,7 +20,7 @@ const route = async (req, res) => {
|
||||
}
|
||||
|
||||
//move data to the accounts table
|
||||
accounts.create({
|
||||
const [account] = await accounts.upsert({
|
||||
email: info.email,
|
||||
username: info.username,
|
||||
hash: info.hash,
|
||||
@@ -35,6 +36,21 @@ const route = async (req, res) => {
|
||||
|
||||
//finally
|
||||
res.status(200).send('Validation succeeded!');
|
||||
|
||||
//post-validation hook
|
||||
if (process.env.HOOK_POST_VALIDATION) {
|
||||
const probe = await fetch(`https://${process.env.HOOK_POST_VALIDATION}?accountIndex=${account.index}`);
|
||||
|
||||
if (!probe.ok) {
|
||||
console.error('Could not probe the post validation hook');
|
||||
} else {
|
||||
console.log('Validation hook probe successful'); //TODO: remove this
|
||||
}
|
||||
|
||||
//discard the result
|
||||
} else {
|
||||
console.log('No validation hook'); //TODO: remove this
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = route;
|
||||
Reference in New Issue
Block a user