diff --git a/bin/casimir.js b/bin/casimir.js index c109764..243bc8b 100644 --- a/bin/casimir.js +++ b/bin/casimir.js @@ -32,13 +32,13 @@ var Storage = require(path.join(__dirname, '/../app/modules/storage.js')) var storage = new Storage(properties) var verifyCallback = function (jwtToken, req, res, next) { - if (!properties.JWT.jwtTokenSecret) { + if (!properties.JWT.user || !properties.JWT.jwtTokenSecret) { return next() } try { var decoded = jwt.decode(jwtToken, properties.JWT.jwtTokenSecret) var expiration = Date.parse(decoded.exp) - if (expiration > Date.now()) { + if (expiration > Date.now() && properties.JWT.user === decoded.iss) { req.user = decoded.iss } } catch (e) { @@ -48,7 +48,7 @@ var verifyCallback = function (jwtToken, req, res, next) { } var accessCallback = function (req, res, next) { - if (!properties.JWT.jwtTokenSecret) { + if (!properties.JWT.user || !properties.JWT.jwtTokenSecret) { return next() // if no JWT secret is provided, consider this a public end-point } next(['Unauthorized', 401]) diff --git a/config/properties_QA.conf b/config/properties_QA.conf index 84c1472..e8ec531 100644 --- a/config/properties_QA.conf +++ b/config/properties_QA.conf @@ -1,5 +1,6 @@ #The most basic HTTP server settings, must at least contain the port value [server] +hostname=localhost https_port=8181 http_port=8180 #cookies_secret= @@ -21,6 +22,7 @@ type=QA #JWT runs the authentication for the private API. Decomment the next lines to use it [JWT] +#user= #jwtTokenSecret= [AWS] @@ -29,6 +31,9 @@ type=QA #S3bucket= [torrent] +torrentPort=13231 +dhtPort=20000 +#seed=false seedBulkSize=20 seedBulkIntervalInMs=60000 diff --git a/config/properties_development.conf b/config/properties_development.conf index c0be2eb..d19e1d1 100644 --- a/config/properties_development.conf +++ b/config/properties_development.conf @@ -1,5 +1,6 @@ #The most basic HTTP server settings, must at least contain the port value [server] +hostname=localhost https_port=8181 http_port=8180 #cookies_secret= @@ -21,6 +22,7 @@ type=development #JWT runs the authentication for the private API. Decomment the next lines to use it [JWT] +#user= #jwtTokenSecret= [AWS] @@ -29,6 +31,9 @@ type=development #S3bucket= [torrent] +torrentPort=13231 +dhtPort=20000 +#seed=false #fromTorrentHash= seedBulkSize=20 seedBulkIntervalInMs=60000 diff --git a/config/properties_production.conf b/config/properties_production.conf index c2a081e..e01f8a8 100644 --- a/config/properties_production.conf +++ b/config/properties_production.conf @@ -1,5 +1,6 @@ #The most basic HTTP server settings, must at least contain the port value [server] +hostname=localhost https_port=8181 http_port=8180 #cookies_secret= @@ -21,6 +22,7 @@ type=production #JWT runs the authentication for the private API. Decomment the next lines to use it [JWT] +#user= #jwtTokenSecret= [AWS] @@ -29,6 +31,9 @@ type=production #S3bucket= [torrent] +torrentPort=13231 +dhtPort=20000 +#seed=false seedBulkSize=100 seedBulkIntervalInMs=60000 diff --git a/startup.js b/startup.js index 9d22c24..2acbe40 100644 --- a/startup.js +++ b/startup.js @@ -8,8 +8,8 @@ var fs = require('graceful-fs') var torrentProperties = { client: { - // torrentPort: 13231, - // dhtPort: 20000, + torrentPort: properties.torrent.torrentPort, + dhtPort: properties.torrent.dhtPort, // Enable DHT (default=true), or options object for DHT dht: true, // Max number of peers to connect to per torrent (default=100) @@ -53,7 +53,7 @@ folders.forEach(function (dir) { } }) -server.http_server.listen(server.port, function (err) { +server.http_server.listen(server.port, properties.server.hostname, function (err) { if (err) { logger.info('Critical Error so killing server - ' + err) casimir.running = false