diff options
| author | Tom Harley | 2018-03-02 18:03:31 +0000 |
|---|---|---|
| committer | Tom Harley | 2018-03-02 18:03:31 +0000 |
| commit | 84b8b5323654cf43ef549d2151bd3206c666d9d8 (patch) | |
| tree | 1ddcff5f713d7cca2c14f94ee97808cc7f4a354b /src/app.ts | |
| parent | added middleware to check if admin (diff) | |
| download | medicine-84b8b5323654cf43ef549d2151bd3206c666d9d8.tar.gz medicine-84b8b5323654cf43ef549d2151bd3206c666d9d8.zip | |
Plug in authentication support - WIP
Diffstat (limited to 'src/app.ts')
| -rw-r--r-- | src/app.ts | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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); } } |
