Add authentication guard to fs. and stream. routes

master
Garrett Mills 3 years ago
parent 8a5d0edc0d
commit 86608545e2
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246

@ -59,18 +59,26 @@ class Socket extends Injectable {
this.messages = this.messages.filter(x => !x.has_response)
} else {
if ( this.needs_auth(message.route()) && !this.session.is_auth ) {
return this.send(response.error(Errors.NodePermissionFail))
}
let handler;
try {
handler = require(`./routes/${message.route()}`)
} catch (e) {}
if ( !handler ) {
return this.send(socket, response.error(Errors.InvalidMessageRoute))
return this.send(response.error(Errors.InvalidMessageRoute))
}
await handler(message, this.app.di().container.proxy())
}
}
needs_auth(route) {
return route.startsWith('fs.') || route.startsWith('stream.')
}
}
module.exports = exports = Socket

Loading…
Cancel
Save