renamed authentication to gatekeeper. Added config templates and entry in docker-compose template

This commit is contained in:
jash
2018-10-24 00:46:06 +02:00
committed by kexkey
parent abd7cfb714
commit 71c7aa7170
11 changed files with 121 additions and 162 deletions

View File

@@ -1,4 +1,3 @@
'use strict';
const Generator = require('yeoman-generator');
const chalk = require('chalk');
const wrap = require('wrap-ansi');
@@ -191,8 +190,8 @@ module.exports = class extends Generator {
return;
}
// save auth key password to check if it changed
this.auth_clientkeyspassword = this.props.auth_clientkeyspassword;
// save gatekeeper key password to check if it changed
this.gatekeeper_clientkeyspassword = this.props.gatekeeper_clientkeyspassword;
let r = await this.prompt([{
type: 'confirm',
@@ -219,9 +218,9 @@ module.exports = class extends Generator {
async configuring() {
if( this.props.auth_recreatekeys ||
this.props.auth_keys.configEntries.length===0 ) {
delete this.props.auth_recreatekeys;
if( this.props.gatekeeper_recreatekeys ||
this.props.gatekeeper_keys.configEntries.length===0 ) {
delete this.props.gatekeeper_recreatekeys;
const apikey = new ApiKey();
let configEntries = [];
@@ -245,7 +244,7 @@ module.exports = class extends Generator {
configEntries.push(apikey.getConfigEntry());
clientInformation.push(apikey.getClientInformation());
this.props.auth_keys = {
this.props.gatekeeper_keys = {
configEntries: configEntries,
clientInformation: clientInformation
}
@@ -272,15 +271,15 @@ module.exports = class extends Generator {
}
}
if( this.props.auth_keys && this.props.auth_keys.clientInformation ) {
if( this.props.gatekeeper_keys && this.props.gatekeeper_keys.clientInformation ) {
if( this.auth_clientkeyspassword !== this.props.auth_clientkeyspassword ) {
if( this.gatekeeper_clientkeyspassword !== this.props.gatekeeper_clientkeyspassword ) {
fs.unlinkSync( this.destinationPath('clientKeys.7z') );
}
const archive = new Archive( this.destinationPath('clientKeys.7z'), this.props.auth_clientkeyspassword );
if( !await archive.writeEntry( 'keys.txt', this.props.auth_keys.clientInformation.join('\n') ) ) {
console.log(chalk.bold.red( 'error! Client auth key archive was not written' ));
const archive = new Archive( this.destinationPath('clientKeys.7z'), this.props.gatekeeper_clientkeyspassword );
if( !await archive.writeEntry( 'keys.txt', this.props.gatekeeper_keys.clientInformation.join('\n') ) ) {
console.log(chalk.bold.red( 'error! Client gatekeeper key archive was not written' ));
}
}
@@ -293,9 +292,9 @@ module.exports = class extends Generator {
_hasAuthKeys() {
return this.props &&
this.props.auth_keys &&
this.props.auth_keys.configEntries &&
this.props.auth_keys.configEntries.length > 0;
this.props.gatekeeper_keys &&
this.props.gatekeeper_keys.configEntries &&
this.props.gatekeeper_keys.configEntries.length > 0;
}
_assignConfigDefaults() {
@@ -318,9 +317,9 @@ module.exports = class extends Generator {
bitcoin_node_ip: '',
bitcoin_mode: 'internal',
bitcoin_expose: false,
auth_apiproperties: defaultAPIProperties,
auth_ipwhitelist: '',
auth_keys: { configEntries: [], clientInformation: [] },
gatekeeper_apiproperties: defaultAPIProperties,
gatekeeper_ipwhitelist: '',
gatekeeper_keys: { configEntries: [], clientInformation: [] },
proxy_datapath: '',
lightning_implementation: 'c-lightning',
lightning_datapath: '',

View File

@@ -1,69 +0,0 @@
const chalk = require('chalk');
const wrap = require('wrap-ansi');
module.exports = {
text: function( topic ) {
let r=wrap('Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam', 82);
switch( topic ) {
case 'features':
break;
case 'net':
break;
case 'username':
break;
case 'xpub':
break;
case 'derivation_path':
break;
case 'auth_clientkeyspassword':
break;
case 'auth_recreatekeys':
break;
case 'auth_edit_ipwhitelist':
break;
case 'auth_ipwhitelist':
break;
case 'auth_edit_apiproperties':
break;
case 'auth_apiproperties':
break;
case 'bitcoin_mode':
break;
case 'bitcoin_node_ip':
break;
case 'bitcoin_rpcuser':
break;
case 'bitcoin_rpcpassword':
break;
case 'bitcoin_prune':
break;
case 'bitcoin_uacomment':
break;
case 'lightning_implementation':
break;
case 'lightning_external_ip':
break;
case 'lightning_nodename':
break;
case 'lightning_nodecolor':
break;
case 'electrum_implementation':
break;
case 'proxy_datapath':
break;
case 'bitcoin_datapath':
break;
case 'lightning_datapath':
break;
case 'bitcoin_expose':
break;
case 'docker_mode':
break;
}
return r;
}
}

View File

@@ -1,72 +0,0 @@
const chalk = require('chalk');
const name = 'authentication';
const capitalise = function( txt ) {
return txt.charAt(0).toUpperCase() + txt.substr(1);
};
const prefix = function() {
return chalk.bold.red(capitalise(name)+': ');
};
module.exports = {
name: function() {
return name;
},
prompts: function( utils ) {
// TODO: delete clientKeys archive when password chnages
return [{
type: 'password',
name: 'auth_clientkeyspassword',
default: utils._getDefault( 'auth_clientkeyspassword' ),
message: prefix()+'Enter a password to protect your client keys with'+utils._getHelp('auth_clientkeyspassword'),
filter: utils._trimFilter,
validate: utils._notEmptyValidator
},
{
when: utils._hasAuthKeys,
type: 'confirm',
name: 'auth_recreatekeys',
default: false,
message: prefix()+'Recreate auth keys?'+utils._getHelp('auth_recreatekeys')
},
{
type: 'confirm',
name: 'auth_edit_ipwhitelist',
default: false,
message: prefix()+'Edit IP whitelist?'+utils._getHelp('auth_edit_ipwhitelist')
},
{
when: function( props ) {
const r = props.auth_edit_ipwhitelist;
delete props.auth_edit_ipwhitelist;
return r;
},
type: 'editor',
name: 'auth_ipwhitelist',
message: prefix()+'IP whitelist'+utils._getHelp('auth_ipwhitelist'),
default: utils._getDefault( 'auth_ipwhitelist' )
},
{
type: 'confirm',
name: 'auth_edit_apiproperties',
default: false,
message: prefix()+'Edit API properties?'+utils._getHelp('auth_edit_apiproperties')
},
{
when: function( props ) {
const r = props.auth_edit_apiproperties;
delete props.auth_edit_apiproperties;
return r;
},
type: 'editor',
name: 'auth_apiproperties',
message: prefix()+'API properties'+utils._getHelp('auth_apiproperties'),
default: utils._getDefault( 'auth_apiproperties' )
}];
},
templates: function( props ) {
return [ 'keys.properties', 'api.properties', 'ip-whitelist.conf' ];
}
};

View File

@@ -0,0 +1,72 @@
const chalk = require('chalk');
const name = 'gatekeeper';
const capitalise = function( txt ) {
return txt.charAt(0).toUpperCase() + txt.substr(1);
};
const prefix = function() {
return chalk.bold.red(capitalise(name)+': ');
};
module.exports = {
name: function() {
return name;
},
prompts: function( utils ) {
// TODO: delete clientKeys archive when password chnages
return [{
type: 'password',
name: 'gatekeeper_clientkeyspassword',
default: utils._getDefault( 'gatekeeper_clientkeyspassword' ),
message: prefix()+'Enter a password to protect your client keys with'+utils._getHelp('gatekeeper_clientkeyspassword'),
filter: utils._trimFilter,
validate: utils._notEmptyValidator
},
{
when: utils._hasAuthKeys,
type: 'confirm',
name: 'gatekeeper_recreatekeys',
default: false,
message: prefix()+'Recreate gatekeeper keys?'+utils._getHelp('gatekeeper_recreatekeys')
},
{
type: 'confirm',
name: 'gatekeeper_edit_ipwhitelist',
default: false,
message: prefix()+'Edit IP whitelist?'+utils._getHelp('gatekeeper_edit_ipwhitelist')
},
{
when: function( props ) {
const r = props.gatekeeper_edit_ipwhitelist;
delete props.gatekeeper_edit_ipwhitelist;
return r;
},
type: 'editor',
name: 'gatekeeper_ipwhitelist',
message: utils._getHelp('gatekeeper_ipwhitelist')||' ',
default: utils._getDefault( 'gatekeeper_ipwhitelist' )
},
{
type: 'confirm',
name: 'gatekeeper_edit_apiproperties',
default: false,
message: prefix()+'Edit API properties?'+utils._getHelp('gatekeeper_edit_apiproperties')
},
{
when: function( props ) {
const r = props.gatekeeper_edit_apiproperties;
delete props.gatekeeper_edit_apiproperties;
return r;
},
type: 'editor',
name: 'gatekeeper_apiproperties',
message: utils._getHelp('gatekeeper_apiproperties')||' ',
default: utils._getDefault( 'gatekeeper_apiproperties' )
}];
},
templates: function( props ) {
return [ 'keys.properties', 'api.properties', 'ip-whitelist.conf' ];
}
};

View File

@@ -40,6 +40,15 @@ module.exports = {
}*/
]
},
{
when: installerDocker,
type: 'input',
name: 'gatekeeper_datapath',
default: utils._getDefault( 'gatekeeper_datapath' ),
filter: utils._trimFilter,
validate: utils._pathValidator,
message: prefix()+'Where to store your gatekeeper data?'+utils._getHelp('gatekeeper_datapath'),
},
{
when: installerDocker,
type: 'input',

View File

@@ -1 +0,0 @@
<%- auth_keys.configEntries.join('\n') %>

View File

@@ -3,4 +3,4 @@
# Spender can do what the watcher can do plus more stuff
# Admin can do what the spender can do plus even more stuff
<%- auth_apiproperties %>
<%- gatekeeper_apiproperties %>

View File

@@ -7,4 +7,4 @@
#allow 45.56.67.78;
#deny all;
<%- auth_ipwhitelist %>
<%- gatekeeper_ipwhitelist %>

View File

@@ -0,0 +1 @@
<%- gatekeeper_keys.configEntries.join('\n') %>

View File

@@ -7,5 +7,6 @@ LIGHTNING_IMPLEMENTATION=<%= lightning_implementation %>
BITCOIN_DATAPATH=<%= bitcoin_datapath %>
LIGHTNING_DATAPATH=<%= lightning_datapath %>
PROXY_DATAPATH=<%= proxy_datapath %>
GATEKEEPER_DATAPATH=<%= gatekeeper_datapath %>
DOCKER_MODE=<%= docker_mode %>
USERNAME=<%= username %>

View File

@@ -1,6 +1,25 @@
version: "3"
services:
gatekeeper:
# HTTP authentication API gate
environment:
- "TRACING=1"
image: cyphernode/gatekeeper
ports:
- "443:443"
volumes:
- "<%= gatekeeper_datapath %>/certs:/etc/ssl/certs"
- "<%= gatekeeper_datapath %>/private:/etc/ssl/private"
- "<%= gatekeeper_datapath %>/keys.properties:/etc/nginx/conf.d/keys.properties"
- "<%= gatekeeper_datapath %>/api.properties:/etc/nginx/conf.d/api.properties"
# deploy:
# placement:
# constraints: [node.hostname==dev]
networks:
- cyphernodenet
restart: always
proxy:
command: $USER ./startproxy.sh
# Bitcoin Mini Proxy