pis #12
14
app.js
14
app.js
@ -23,9 +23,9 @@ const listRtr = require('./src/routes/list.routes'); // /list endpoints
|
||||
const ldbRtr = require('./src/routes/ldb.routes'); // /ldb endpoints
|
||||
const kubeRtr = require('./src/routes/kube.routes'); // /kube endpoints
|
||||
const findRtr = require('./src/routes/find.routes'); // /find endpoints
|
||||
const issueRtr = require('./src/routes/issue.routes') // /issue endpoints
|
||||
const issueRtr = require('./src/routes/issue.routes'); // /issue endpoints
|
||||
const statRtr = require('./src/routes/stats.routes'); // /stat endpoints
|
||||
const regRtr = require('./src/routes/registration.routes'); // /auth endpoints
|
||||
const regRtr = require('./src/routes/registration.routes'); // /registration endpoints
|
||||
|
||||
// Set Server Configurations
|
||||
const srvListen = process.env.OWL_SRV_LISTEN || "0.0.0.0"
|
||||
@ -70,17 +70,17 @@ app.use('/api/v1/ldb', ldbRtr);
|
||||
app.use('/api/v1/kube', kubeRtr);
|
||||
app.use('/api/v1/find', findRtr);
|
||||
app.use('/api/v1/issue', issueRtr);
|
||||
app.use('/api/v1/stats', statRtr)
|
||||
app.use('/api/v1/register', regRtr)
|
||||
app.use('/api/v1/stats', statRtr);
|
||||
app.use('/api/v1/register', regRtr);
|
||||
|
||||
// Authented Routes
|
||||
app.use('/api/v1/ldbs', authenticate)
|
||||
app.use('/api/v1/auth/test', authenticate) // Returns 401 if auth failed, 404 if successful.
|
||||
app.use('/api/v1/auth/test', authenticate, (req, res) => res.status(200)) // Returns 401 if auth failed, 200 if successful.
|
||||
|
||||
// Number of proxies:
|
||||
app.set('trust proxy', 3)
|
||||
app.set('trust proxy', 4)
|
||||
mode === "development"
|
||||
? app.get('/api/v1/ip', (request, response) => response.send(request.ip))
|
||||
? app.get('/api/v1/ip', (req, res) => res.send(req.ip))
|
||||
: null
|
||||
|
||||
// Start Express
|
||||
|
@ -6,7 +6,7 @@ module.exports = async function authCheck(req, res, next) {
|
||||
try {
|
||||
var uuid = req.headers.uuid
|
||||
} catch(err) {
|
||||
log.out(`authMiddlewares: No authentication attempted`, "INFO")
|
||||
log.out(`authMiddlewares: No authentication attempted`, "info")
|
||||
err.status = 401
|
||||
return next(err)
|
||||
}
|
||||
@ -15,8 +15,10 @@ module.exports = async function authCheck(req, res, next) {
|
||||
if (!result) {
|
||||
const err = new Error("Unauthorised");
|
||||
err.status = 401
|
||||
log.out(`authMiddlewares: Authentication attempted with incorrect key`, "warn")
|
||||
return next(err)
|
||||
} else {
|
||||
log.out(`authMiddlewares: User authenticated`, "info")
|
||||
return next()
|
||||
}
|
||||
} catch(err) {
|
||||
|
Loading…
Reference in New Issue
Block a user