mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 08:03:30 +02:00
Add auth middleware in api unit. Now only authorized user can access api unit
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user