Authentication and Bug fixes
parent
3452a8f4ff
commit
f4e3a8dd67
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,25 +1,101 @@
|
|||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var common = require('./common');
|
|
||||||
var clArgs = require('optimist').argv;
|
var clArgs = require('optimist').argv;
|
||||||
|
var ini = require('ini');
|
||||||
|
var file_path = './RTL.conf';
|
||||||
|
var common = require('./common');
|
||||||
|
var upperCase = require('upper-case');
|
||||||
|
var macaroonPath = '';
|
||||||
|
var options = {};
|
||||||
|
|
||||||
|
var defaultConfig = {
|
||||||
|
authentication: {
|
||||||
|
lndServerUrl:'https://localhost:8080/v1',
|
||||||
|
macroonPath:'',
|
||||||
|
nodeAuthType:'DEFAULT',
|
||||||
|
lndConfigPath:'',
|
||||||
|
rtlPass:''
|
||||||
|
},
|
||||||
|
settings: {
|
||||||
|
flgSidenavOpened:true,
|
||||||
|
flgSidenavPinned:true,
|
||||||
|
menu:'Vertical',
|
||||||
|
menuType:'Regular',
|
||||||
|
theme:'dark-blue',
|
||||||
|
satsToBTC:false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if(undefined !== clArgs.lndir) {
|
var setMacaroonPath = (clArgs, config) => {
|
||||||
common.lnd_dir = clArgs.lndir;
|
if(undefined !== clArgs.lndir) {
|
||||||
} else {
|
macaroonPath = clArgs.lndir;
|
||||||
if(common.lnd_dir === '') {
|
} else {
|
||||||
common.lnd_dir = __dirname;
|
if(config.Authentication.macroonPath !== '') {
|
||||||
|
macaroonPath = config.Authentication.macroonPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var macaroon = fs.readFileSync(common.lnd_dir + '/admin.macaroon').toString('hex');
|
var validateConfigFile = (macaroonPath, config) => {
|
||||||
var options = {
|
if(macaroonPath === '' || undefined === macaroonPath) {
|
||||||
url: '',
|
errMsg = 'Please set macaroon path in RTL.conf';
|
||||||
rejectUnauthorized: false,
|
}
|
||||||
// resolveWithFullResponse: true,
|
|
||||||
json: true,
|
if(config.Authentication.lndServerUrl === '' || undefined === config.Authentication.lndServerUrl) {
|
||||||
headers: {
|
errMsg = errMsg + '\nPlease set LND Server URL in RTL.conf';
|
||||||
'Grpc-Metadata-macaroon': macaroon,
|
} else {
|
||||||
},
|
common.lnd_server_url = config.Authentication.lndServerUrl;
|
||||||
form: ''
|
}
|
||||||
};
|
|
||||||
|
if(config.Authentication.nodeAuthType === '' || undefined === config.Authentication.nodeAuthType) {
|
||||||
|
errMsg = errMsg + '\nPlease set Node Auth Type in RTL.conf';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(upperCase(config.Authentication.nodeAuthType) === 'DEFAULT' && (config.Authentication.lndConfigPath === '' || undefined === config.Authentication.lndConfigPath)) {
|
||||||
|
errMsg = errMsg + '\nDefault Node Authentication can be set with LND Config Path only. Please set LND Config Path in RTL.conf';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(upperCase(config.Authentication.nodeAuthType) === 'CUSTOM' && (config.Authentication.rtlPass === '' || undefined === config.Authentication.rtlPass)) {
|
||||||
|
errMsg = errMsg + '\nCustom Node Authentication can be set with RTL password only. Please set RTL Password in RTL.conf';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(errMsg !== '') {
|
||||||
|
throw new Error(errMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var setOptions = (macaroonPath) => {
|
||||||
|
var macaroon = fs.readFileSync(macaroonPath + '/admin.macaroon').toString('hex');
|
||||||
|
options = {
|
||||||
|
url: '',
|
||||||
|
rejectUnauthorized: false,
|
||||||
|
json: true,
|
||||||
|
headers: {
|
||||||
|
'Grpc-Metadata-macaroon': macaroon,
|
||||||
|
},
|
||||||
|
form: ''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = options;
|
var errMsg = '';
|
||||||
|
var configFileExists = () => {
|
||||||
|
let exists = fs.existsSync(file_path);
|
||||||
|
if (exists) {
|
||||||
|
var config = ini.parse(fs.readFileSync(file_path, 'utf-8'));
|
||||||
|
setMacaroonPath(clArgs, config)
|
||||||
|
validateConfigFile(macaroonPath, config);
|
||||||
|
setOptions(macaroonPath);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
fs.writeFileSync(file_path, ini.stringify(defaultConfig));
|
||||||
|
var config = ini.parse(fs.readFileSync(file_path, 'utf-8'));
|
||||||
|
setMacaroonPath(clArgs, config)
|
||||||
|
validateConfigFile(macaroonPath, config);
|
||||||
|
setOptions(macaroonPath);
|
||||||
|
}
|
||||||
|
catch(err) {
|
||||||
|
console.error('Something went wrong, unable to create config file!' + err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
configFileExists();
|
||||||
|
module.exports = options;
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
var ini = require('ini');
|
||||||
|
var path = require('path');
|
||||||
|
var fs = require('fs');
|
||||||
|
var file_path = path.normalize(__dirname + '/..') + '/RTL.conf';
|
||||||
|
|
||||||
|
exports.getUISettings = (req, res, next) => {
|
||||||
|
console.log('Getting UI Settings!');
|
||||||
|
fs.readFile(file_path, 'utf8', function(err, data) {
|
||||||
|
if (err) {
|
||||||
|
console.log('Reading UI Settings Failed!');
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Reading UI Settings Failed!",
|
||||||
|
error: err
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const jsonConfig = ini.parse(data);
|
||||||
|
console.log('UI settings read successfully');
|
||||||
|
res.status(200).json({settings: jsonConfig.Settings});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.updateUISettings = (req, res, next) => {
|
||||||
|
var config = ini.parse(fs.readFileSync(file_path, 'utf-8'));
|
||||||
|
delete config.Settings;
|
||||||
|
fs.writeFileSync(file_path, ini.stringify(config));
|
||||||
|
fs.appendFile(file_path, ini.stringify(req.body.updatedSettings, { section: 'Settings' }), function(err) {
|
||||||
|
if (err) {
|
||||||
|
console.log('Updating UI Settings Failed!');
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Updating UI Settings Failed!",
|
||||||
|
error: 'Updating UI Settings Failed!'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log('UI Settings Updated Successfully');
|
||||||
|
res.status(201).json({message: 'UI Settings Updated Successfully'});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.getLNDConfig = (req, res, next) => {
|
||||||
|
console.log('Getting LND Conf Settings!');
|
||||||
|
fs.readFile(req.headers.filepath, 'utf8', function(err, data) {
|
||||||
|
if (err) {
|
||||||
|
console.log('Reading Config File Failed!');
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Reading Config File Failed!",
|
||||||
|
error: err
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const jsonConfig = ini.parse(data);
|
||||||
|
console.log('LND Conf read successfully');
|
||||||
|
if (undefined !== jsonConfig.Bitcoind && undefined !== jsonConfig.Bitcoind['bitcoind.rpcpass']) {
|
||||||
|
jsonConfig.Bitcoind['bitcoind.rpcpass'] = jsonConfig.Bitcoind['bitcoind.rpcpass'].replace(/./g, '*');
|
||||||
|
}
|
||||||
|
res.status(200).json(ini.stringify(jsonConfig));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
@ -0,0 +1,81 @@
|
|||||||
|
var ini = require('ini');
|
||||||
|
var path = require('path');
|
||||||
|
var fs = require('fs');
|
||||||
|
var rtl_config_path = path.normalize(__dirname + '/..') + '/RTL.conf';
|
||||||
|
const jwt = require("jsonwebtoken");
|
||||||
|
var upperCase = require('upper-case');
|
||||||
|
var atob = require('atob');
|
||||||
|
|
||||||
|
exports.authenticateUser = (req, res, next) => {
|
||||||
|
password = atob(req.body.password);
|
||||||
|
fs.readFile(rtl_config_path, 'utf8', function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
console.log('RTL Config Reading Failed!');
|
||||||
|
res.status(500).json({
|
||||||
|
message: "RTL Config Reading Failed!",
|
||||||
|
error: err
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
var jsonRTLConfig = ini.parse(data);
|
||||||
|
const nodeAuthType = jsonRTLConfig.Authentication.nodeAuthType;
|
||||||
|
const macaroonPath = jsonRTLConfig.Authentication.macroonPath;
|
||||||
|
const lndConfigPath = (undefined !== jsonRTLConfig.Authentication.lndConfigPath) ? jsonRTLConfig.Authentication.lndConfigPath : '';
|
||||||
|
if(upperCase(nodeAuthType) === 'CUSTOM') {
|
||||||
|
const rtlPass = jsonRTLConfig.Authentication.rtlPass;
|
||||||
|
if (rtlPass === password) {
|
||||||
|
var rpcUser = 'Custom_User';
|
||||||
|
const token = jwt.sign(
|
||||||
|
{ user: rpcUser, lndConfigPath: lndConfigPath, macaroonPath: macaroonPath },
|
||||||
|
'RTL_default_secret_it_can_be_changed_by_user',
|
||||||
|
{ expiresIn: "1h" }
|
||||||
|
);
|
||||||
|
res.status(200).json({
|
||||||
|
token: token,
|
||||||
|
expiresIn: 3600
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.status(401).json({
|
||||||
|
message: "Authentication Failed!",
|
||||||
|
error: "Password Validation Failed!"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fs.readFile(lndConfigPath, 'utf8', function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
console.log('LND Config Reading Failed!');
|
||||||
|
res.status(500).json({
|
||||||
|
message: "LND Config Reading Failed!",
|
||||||
|
error: err
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const jsonLNDConfig = ini.parse(data);
|
||||||
|
if (undefined !== jsonLNDConfig.Bitcoind && undefined !== jsonLNDConfig.Bitcoind['bitcoind.rpcpass']) {
|
||||||
|
if (jsonLNDConfig.Bitcoind['bitcoind.rpcpass'] === password) {
|
||||||
|
var rpcUser = (undefined !== jsonLNDConfig.Bitcoind['bitcoind.rpcuser']) ? jsonLNDConfig.Bitcoind['bitcoind.rpcuser'] : '';
|
||||||
|
const token = jwt.sign(
|
||||||
|
{ user: rpcUser, lndConfigPath: lndConfigPath, macaroonPath: macaroonPath },
|
||||||
|
'RTL_default_secret_it_can_be_changed_by_user',
|
||||||
|
{ expiresIn: "1h" }
|
||||||
|
);
|
||||||
|
res.status(200).json({
|
||||||
|
token: token,
|
||||||
|
expiresIn: 3600
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.status(401).json({
|
||||||
|
message: "Authentication Failed!",
|
||||||
|
error: "Password Validation Failed!"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res.status(401).json({
|
||||||
|
message: "Authentication Failed!",
|
||||||
|
error: "Password Not Found In LND Config!"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
@ -1,28 +1,24 @@
|
|||||||
var request = require('request');
|
var request = require('request-promise');
|
||||||
var options = require("../connect");
|
var options = require("../connect");
|
||||||
var common = require('../common');
|
var common = require('../common');
|
||||||
|
|
||||||
exports.getBalance = (req, res, next) => {
|
exports.getBalance = (req, res, next) => {
|
||||||
// setTimeout(()=>{res.status(201).json({"balance":{"total_balance":"15305209","confirmed_balance":"15305209"}});}, 5000);
|
|
||||||
// setTimeout(()=>{res.status(201).json({"balance":{"balance":"5983797"}});}, 5000);
|
|
||||||
options.url = common.lnd_server_url + '/balance/' + req.params.source;
|
options.url = common.lnd_server_url + '/balance/' + req.params.source;
|
||||||
options.qs = req.query;
|
options.qs = req.query;
|
||||||
request.get(options, (error, response, body) => {
|
request(options).then((body) => {
|
||||||
console.log('Request params: ' + JSON.stringify(req.params) + '\nRequest Query: ' + JSON.stringify(req.query) + ' \nBalance Received: ' + JSON.stringify(body));
|
console.log('Request params: ' + JSON.stringify(req.params) + '\nRequest Query: ' + JSON.stringify(req.query) + ' \nBalance Received: ' + JSON.stringify(body));
|
||||||
const body_str = (undefined === body) ? '' : JSON.stringify(body);
|
if(undefined !== body) {
|
||||||
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
|
|
||||||
console.log('Balance Information Received: ' + body_str);
|
|
||||||
if(undefined === body || search_idx > -1 || body.error) {
|
|
||||||
res.status(500).json({
|
|
||||||
message: "Fetching balance failed!",
|
|
||||||
error: (undefined === body || search_idx > -1) ? 'Error From Server!' : body.error
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
body.btc_balance = (undefined === body.balance) ? 0 : common.convertToBTC(body.balance);
|
body.btc_balance = (undefined === body.balance) ? 0 : common.convertToBTC(body.balance);
|
||||||
body.btc_total_balance = (undefined === body.total_balance) ? 0 : common.convertToBTC(body.total_balance);
|
body.btc_total_balance = (undefined === body.total_balance) ? 0 : common.convertToBTC(body.total_balance);
|
||||||
body.btc_confirmed_balance = (undefined === body.confirmed_balance) ? 0 : common.convertToBTC(body.confirmed_balance);
|
body.btc_confirmed_balance = (undefined === body.confirmed_balance) ? 0 : common.convertToBTC(body.confirmed_balance);
|
||||||
body.btc_unconfirmed_balance = (undefined === body.unconfirmed_balance) ? 0 : common.convertToBTC(body.unconfirmed_balance);
|
body.btc_unconfirmed_balance = (undefined === body.unconfirmed_balance) ? 0 : common.convertToBTC(body.unconfirmed_balance);
|
||||||
res.status(200).json(body);
|
res.status(200).json(body);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
return res.status(500).json({
|
||||||
|
message: "Fetching balance failed!",
|
||||||
|
error: err.error
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,10 @@
|
|||||||
|
const RTLConfController = require("../controllers/RTLConf");
|
||||||
|
const express = require("express");
|
||||||
|
const router = express.Router();
|
||||||
|
const authCheck = require("./authCheck");
|
||||||
|
|
||||||
|
router.get("/lndconfig", authCheck, RTLConfController.getLNDConfig);
|
||||||
|
router.get("/uisettings", RTLConfController.getUISettings);
|
||||||
|
router.post("/", authCheck, RTLConfController.updateUISettings);
|
||||||
|
|
||||||
|
module.exports = router;
|
@ -0,0 +1,14 @@
|
|||||||
|
const jwt = require("jsonwebtoken");
|
||||||
|
|
||||||
|
module.exports = (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const token = req.headers.authorization.split(" ")[1];
|
||||||
|
jwt.verify(token, "RTL_default_secret_it_can_be_changed_by_user");
|
||||||
|
next();
|
||||||
|
} catch (error) {
|
||||||
|
res.status(401).json({
|
||||||
|
message: "Authentication Failed!",
|
||||||
|
error: "Authentication Failed! Please Login First!"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,7 @@
|
|||||||
|
const AuthenticateController = require("../controllers/authenticate");
|
||||||
|
const express = require("express");
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
router.post("/", AuthenticateController.authenticateUser);
|
||||||
|
|
||||||
|
module.exports = router;
|
@ -1,8 +1,8 @@
|
|||||||
const BalanceController = require("../controllers/balance");
|
const BalanceController = require("../controllers/balance");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const authCheck = require("./authCheck");
|
||||||
|
|
||||||
router.get("/", BalanceController.getBalance);
|
router.get("/:source", authCheck, BalanceController.getBalance);
|
||||||
router.get("/:source", BalanceController.getBalance);
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
const ChannelsController = require("../controllers/channels");
|
const ChannelsController = require("../controllers/channels");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const authCheck = require("./authCheck");
|
||||||
|
|
||||||
router.get("/", ChannelsController.getChannels);
|
router.get("/", authCheck, ChannelsController.getChannels);
|
||||||
router.get("/:channelType", ChannelsController.getChannels);
|
router.get("/:channelType", authCheck, ChannelsController.getChannels);
|
||||||
router.post("/", ChannelsController.postChannel);
|
router.post("/", authCheck, ChannelsController.postChannel);
|
||||||
router.post("/transactions", ChannelsController.postTransactions);
|
router.post("/transactions", authCheck, ChannelsController.postTransactions);
|
||||||
router.delete("/:channelPoint", ChannelsController.closeChannel);
|
router.delete("/:channelPoint", authCheck, ChannelsController.closeChannel);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
const FeesController = require("../controllers/fees");
|
const FeesController = require("../controllers/fees");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const authCheck = require("./authCheck");
|
||||||
|
|
||||||
router.get("/", FeesController.getFees);
|
router.get("/", authCheck, FeesController.getFees);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
const infoController = require("../controllers/getInfo");
|
const infoController = require("../controllers/getInfo");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const authCheck = require("./authCheck");
|
||||||
|
|
||||||
router.get("/", infoController.getInfo);
|
router.get("/", authCheck, infoController.getInfo);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
const graphController = require("../controllers/graph");
|
const graphController = require("../controllers/graph");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const authCheck = require("./authCheck");
|
||||||
|
|
||||||
router.get("/", graphController.getDescribeGraph);
|
router.get("/", authCheck, graphController.getDescribeGraph);
|
||||||
router.get("/info", graphController.getGraphInfo);
|
router.get("/info", authCheck, graphController.getGraphInfo);
|
||||||
router.get("/node/:pubKey", graphController.getGraphNode);
|
router.get("/node/:pubKey", authCheck, graphController.getGraphNode);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
const invoicesController = require("../controllers/invoices");
|
const invoicesController = require("../controllers/invoices");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const authCheck = require("./authCheck");
|
||||||
|
|
||||||
router.get("/", invoicesController.listInvoices);
|
router.get("/", authCheck, invoicesController.listInvoices);
|
||||||
router.post("/", invoicesController.addInvoice);
|
router.post("/", authCheck, invoicesController.addInvoice);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
@ -1,7 +1,8 @@
|
|||||||
const NewAddressController = require("../controllers/newAddress");
|
const NewAddressController = require("../controllers/newAddress");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const authCheck = require("./authCheck");
|
||||||
|
|
||||||
router.get("/", NewAddressController.getNewAddress);
|
router.get("/", authCheck, NewAddressController.getNewAddress);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
const PayRequestController = require("../controllers/payReq");
|
const PayRequestController = require("../controllers/payReq");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const authCheck = require("./authCheck");
|
||||||
|
|
||||||
router.get("/:payRequest", PayRequestController.decodePayment);
|
router.get("/:payRequest", authCheck, PayRequestController.decodePayment);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
const PaymentsController = require("../controllers/payments");
|
const PaymentsController = require("../controllers/payments");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const authCheck = require("./authCheck");
|
||||||
|
|
||||||
router.get("/", PaymentsController.getPayments);
|
router.get("/", authCheck, PaymentsController.getPayments);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
const PeersController = require("../controllers/peers");
|
const PeersController = require("../controllers/peers");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const authCheck = require("./authCheck");
|
||||||
|
|
||||||
router.get("/", PeersController.getPeers);
|
router.get("/", authCheck, PeersController.getPeers);
|
||||||
router.post("/", PeersController.postPeer);
|
router.post("/", authCheck, PeersController.postPeer);
|
||||||
router.delete("/:peerPubKey", PeersController.deletePeer);
|
router.delete("/:peerPubKey", authCheck, PeersController.deletePeer);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
const TransactionsController = require("../controllers/transactions");
|
const TransactionsController = require("../controllers/transactions");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const authCheck = require("./authCheck");
|
||||||
|
|
||||||
router.post("/", TransactionsController.postTransactions);
|
router.post("/", authCheck, TransactionsController.postTransactions);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
const WalletController = require("../controllers/wallet");
|
const WalletController = require("../controllers/wallet");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const authCheck = require("./authCheck");
|
||||||
|
|
||||||
router.post("/:operation", WalletController.operateWallet);
|
router.post("/:operation", authCheck, WalletController.operateWallet);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
Loading…
Reference in New Issue