Expose supervisor API to app by allowing all requests from 127.0.0.1 and passing address and port as env vars

This commit is contained in:
Pablo Carranza Vélez 2015-10-01 23:28:30 +00:00
parent 7f7a550363
commit 0fd03054e8
3 changed files with 4 additions and 1 deletions

View File

@ -1,3 +1,4 @@
* Expose supervisor API to app by allowing all requests from 127.0.0.1 and passing address and port as env vars [Pablo]
* Only apply special actions / boot config on change, and always persist to DB [Pablo]
# v0.0.18

View File

@ -12,7 +12,7 @@ module.exports = (secret, application) ->
api = express()
api.use(bodyParser())
api.use (req, res, next) ->
if req.query.apikey is secret
if req.ip is '127.0.0.1' or req.query.apikey is secret
next()
else
res.sendStatus(401)

View File

@ -100,6 +100,8 @@ exports.connectivityCheck = _.once ->
exports.extendEnvVars = (env, uuid) ->
newEnv =
RESIN_DEVICE_UUID: uuid
RESIN_SUPERVISOR_ADDRESS: 'http://127.0.0.1:' + config.listenPort
RESIN_SUPERVISOR_PORT: config.listenPort
RESIN: '1'
USER: 'root'
if env?