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:
parent
41f306a7f0
commit
e0a45391ab
5 changed files with 102 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue