server: fix rpc auth.
This commit is contained in:
parent
0a217e7be2
commit
ac774fbe3a
@ -137,6 +137,7 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
|
|
||||||
if (req.method === 'POST'
|
if (req.method === 'POST'
|
||||||
&& req.pathname === '/') {
|
&& req.pathname === '/') {
|
||||||
|
req.options = {};
|
||||||
if (self.apiKey) {
|
if (self.apiKey) {
|
||||||
assert(utils.isHex(req.password), 'API key must be a hex string.');
|
assert(utils.isHex(req.password), 'API key must be a hex string.');
|
||||||
assert(req.password.length === 64, 'API key must be 32 bytes.');
|
assert(req.password.length === 64, 'API key must be 32 bytes.');
|
||||||
@ -262,6 +263,11 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.use(function(req, res, next, send) {
|
this.use(function(req, res, next, send) {
|
||||||
|
if (req.method === 'POST'
|
||||||
|
&& req.pathname === '/') {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
if (self.apiKey) {
|
if (self.apiKey) {
|
||||||
if (!utils.ccmp(req.options.apiKey, self.apiKey)) {
|
if (!utils.ccmp(req.options.apiKey, self.apiKey)) {
|
||||||
send(403, { error: 'Forbidden.' });
|
send(403, { error: 'Forbidden.' });
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user