1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 10:19:30 +02:00

Add auth middleware in api unit. Now only authorized user can access api unit

This commit is contained in:
Vishal Banthia 2015-12-02 21:14:42 +09:00
parent 41f306a7f0
commit e0a45391ab
5 changed files with 102 additions and 0 deletions

View file

@ -3,9 +3,12 @@ var path = require('path')
var express = require('express')
var SwaggerExpress = require('swagger-express-mw')
var cookieSession = require('cookie-session')
var logger = require('../../util/logger')
var auth = require('./middleware/auth')
module.exports = function(options) {
var log = logger.createLogger('api')
, app = express()
@ -22,6 +25,17 @@ module.exports = function(options) {
swaggerExpress.register(app);
})
// TODO: Remove this once frontend is stateless
app.use(cookieSession({
name: options.ssid
, keys: [options.secret]
}))
app.use(auth({
secret: options.secret
, authUrl: options.authUrl
}))
server.listen(options.port)
log.info('Listening on port %d', options.port)
}