aboutsummaryrefslogtreecommitdiff
path: root/src/app.ts
diff options
context:
space:
mode:
authorTom Harley2018-03-02 18:03:31 +0000
committerTom Harley2018-03-02 18:03:31 +0000
commit84b8b5323654cf43ef549d2151bd3206c666d9d8 (patch)
tree1ddcff5f713d7cca2c14f94ee97808cc7f4a354b /src/app.ts
parentadded middleware to check if admin (diff)
downloadmedicine-84b8b5323654cf43ef549d2151bd3206c666d9d8.tar.gz
medicine-84b8b5323654cf43ef549d2151bd3206c666d9d8.zip

Plug in authentication support - WIP

Diffstat (limited to 'src/app.ts')
-rw-r--r--src/app.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/app.ts b/src/app.ts
index a843179..c6527c8 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -1,6 +1,10 @@
import * as bodyParser from 'body-parser';
import * as ex from 'express';
+import * as expressJwt from 'express-jwt';
import * as logger from 'morgan';
+import * as passport from 'passport';
+
+import { default as authRouter } from './auth';
import { errorHandler } from './errors/errorware';
import FileRouter from './FileRouter';
@@ -18,6 +22,8 @@ class App {
// Configure Express middleware.
private middleware(): void {
+ this.express.use(expressJwt({secret: 'Mr Secret'}).unless({path: ['/cs3099group-be-4/login', '/cs3099group-be-4/_supported_protocols_'] }));
+ this.express.use(passport.initialize());
if (this.logEnabled) {
this.express.use(logger('combined'));
}
@@ -36,9 +42,11 @@ class App {
});
this.express.use('/', defRouter);
this.express.use('/cs3099group-be-4', FileRouter);
+ this.express.use('/cs3099group-be-4', authRouter);
}
private errorware(): void {
+ //this.express.use(authRouter.unauthorisedErr);
this.express.use(errorHandler);
}
}