Updated the secret key logic

pull/63/head v0.2.11
ShahanaFarooqui 5 years ago
parent a6f022cad2
commit 5cb3795739

@ -8,5 +8,5 @@
<link rel="stylesheet" href="styles.7e944f30e4357f41ed14.css"></head> <link rel="stylesheet" href="styles.7e944f30e4357f41ed14.css"></head>
<body> <body>
<rtl-app></rtl-app> <rtl-app></rtl-app>
<script type="text/javascript" src="runtime.ec2944dd8b20ec099bf3.js"></script><script type="text/javascript" src="polyfills.418928a701f2040ada02.js"></script><script type="text/javascript" src="main.efff2a0803223cb3565a.js"></script></body> <script type="text/javascript" src="runtime.ec2944dd8b20ec099bf3.js"></script><script type="text/javascript" src="polyfills.418928a701f2040ada02.js"></script><script type="text/javascript" src="main.dc5615cdea2d3a3a2e6c.js"></script></body>
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -24,7 +24,7 @@ const switchRoutes = require("./routes/switch");
const baseHref = '/rtl/'; const baseHref = '/rtl/';
const apiRoot = baseHref + 'api/'; const apiRoot = baseHref + 'api/';
app.use(cookieParser(common.cookieParserSecret)); app.use(cookieParser(common.secret_key));
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.urlencoded({ extended: false }));
app.use(baseHref, express.static(path.join(__dirname, "angular"))); app.use(baseHref, express.static(path.join(__dirname, "angular")));

@ -16,7 +16,7 @@ common.rtl_sso = 0;
common.rtl_cookie_path = ''; common.rtl_cookie_path = '';
common.logout_redirect_link = '/login'; common.logout_redirect_link = '/login';
common.cookie = ''; common.cookie = '';
common.cookieParserSecret = crypto.randomBytes(64).toString('hex'); common.secret_key = crypto.randomBytes(64).toString('hex');
common.convertToBTC = (num) => { common.convertToBTC = (num) => {
return (num / 100000000).toFixed(6); return (num / 100000000).toFixed(6);
@ -49,4 +49,4 @@ common.newestOnTop = (array, key, value) => {
return array; return array;
} }
module.exports = common; module.exports = common;

@ -282,4 +282,4 @@ const configFileExists = () => {
} }
} }
configFileExists(); configFileExists();
module.exports = options; module.exports = options;

@ -32,7 +32,7 @@ exports.authenticateUser = (req, res, next) => {
if (common.cookie === access_key) { if (common.cookie === access_key) {
const token = jwt.sign( const token = jwt.sign(
{ user: 'Custom_User', lndConfigPath: common.lnd_config_path, macaroonPath: common.macaroon_path }, { user: 'Custom_User', lndConfigPath: common.lnd_config_path, macaroonPath: common.macaroon_path },
'default_secret_key' common.secret_key
); );
res.status(200).json({ token: token }); res.status(200).json({ token: token });
} else { } else {
@ -48,7 +48,7 @@ exports.authenticateUser = (req, res, next) => {
var rpcUser = 'Custom_User'; var rpcUser = 'Custom_User';
const token = jwt.sign( const token = jwt.sign(
{ user: rpcUser, lndConfigPath: common.lnd_config_path, macaroonPath: common.macaroon_path }, { user: rpcUser, lndConfigPath: common.lnd_config_path, macaroonPath: common.macaroon_path },
'default_secret_key' common.secret_key
); );
res.status(200).json({ token: token }); res.status(200).json({ token: token });
} else { } else {
@ -72,7 +72,7 @@ exports.authenticateUser = (req, res, next) => {
var rpcUser = (undefined !== jsonLNDConfig.Bitcoind['bitcoind.rpcuser']) ? jsonLNDConfig.Bitcoind['bitcoind.rpcuser'] : ''; var rpcUser = (undefined !== jsonLNDConfig.Bitcoind['bitcoind.rpcuser']) ? jsonLNDConfig.Bitcoind['bitcoind.rpcuser'] : '';
const token = jwt.sign( const token = jwt.sign(
{ user: rpcUser, lndConfigPath: common.lnd_config_path, macaroonPath: common.macaroon_path }, { user: rpcUser, lndConfigPath: common.lnd_config_path, macaroonPath: common.macaroon_path },
'default_secret_key' common.secret_key
); );
res.status(200).json({ token: token }); res.status(200).json({ token: token });
} else { } else {

2
package-lock.json generated

@ -1,6 +1,6 @@
{ {
"name": "rtl", "name": "rtl",
"version": "0.2.9-beta", "version": "0.2.11-beta",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

@ -1,6 +1,6 @@
{ {
"name": "rtl", "name": "rtl",
"version": "0.2.9-beta", "version": "0.2.11-beta",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
@ -33,8 +33,8 @@
"@swimlane/ngx-charts": "^10.0.0", "@swimlane/ngx-charts": "^10.0.0",
"angular-user-idle": "^2.0.0", "angular-user-idle": "^2.0.0",
"angularx-qrcode": "^1.5.3", "angularx-qrcode": "^1.5.3",
"atob": "^2.1.2",
"cookie-parser": "^1.4.4", "cookie-parser": "^1.4.4",
"atob": "^2.1.2",
"core-js": "^2.5.4", "core-js": "^2.5.4",
"express": "^4.16.4", "express": "^4.16.4",
"hammerjs": "^2.0.8", "hammerjs": "^2.0.8",

@ -1,9 +1,10 @@
const jwt = require("jsonwebtoken"); const jwt = require("jsonwebtoken");
var common = require('../common');
module.exports = (req, res, next) => { module.exports = (req, res, next) => {
try { try {
const token = req.headers.authorization.split(" ")[1]; const token = req.headers.authorization.split(" ")[1];
jwt.verify(token, "default_secret_key"); jwt.verify(token, common.secret_key);
next(); next();
} catch (error) { } catch (error) {
res.status(401).json({ res.status(401).json({

Loading…
Cancel
Save