Tor middleware #499

Merged
bones7242 merged 16 commits from tor-middleware into master 2018-06-29 02:59:56 +02:00
3 changed files with 12 additions and 2 deletions
Showing only changes of commit 67601ea97f - Show all commits

View file

@ -0,0 +1,9 @@
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
const logger = require('winston');
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
const torCheck = (req, res, next) => { // custom logging middleware to log all incoming http requests
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
const { ip } = req;
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
logger.debug(`tor check for ${ip}`);
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
next();
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
};
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
module.exports = torCheck;
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.

Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.

Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.

View file

@ -15,7 +15,8 @@ const fileAvailability = require('../../controllers/api/file/availability');
const userPassword = require('../../controllers/api/user/password'); const userPassword = require('../../controllers/api/user/password');
const publishingConfig = require('../../controllers/api/config/site/publishing'); const publishingConfig = require('../../controllers/api/config/site/publishing');
const multipartMiddleware = require('../utils/multipartMiddleware'); const multipartMiddleware = require('../../middleware/multipartMiddleware');
const torCheckMiddleware = require('../../middleware/torCheckMiddleware');
module.exports = (app) => { module.exports = (app) => {
// channel routes // channel routes
@ -30,7 +31,7 @@ module.exports = (app) => {
app.get('/api/claim/get/:name/:claimId', claimGet); app.get('/api/claim/get/:name/:claimId', claimGet);
app.get('/api/claim/list/:name', claimList); app.get('/api/claim/list/:name', claimList);
app.post('/api/claim/long-id', claimLongId); // should be a get app.post('/api/claim/long-id', claimLongId); // should be a get
app.post('/api/claim/publish', multipartMiddleware, claimPublish); app.post('/api/claim/publish', torCheckMiddleware, multipartMiddleware, claimPublish);
app.get('/api/claim/resolve/:name/:claimId', claimResolve); app.get('/api/claim/resolve/:name/:claimId', claimResolve);
app.get('/api/claim/short-id/:longId/:name', claimShortId); app.get('/api/claim/short-id/:longId/:name', claimShortId);
// file routes // file routes