1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

httpNodeAuth should not block http options requests

Fixes #793#793#793
This commit is contained in:
Nick O'Leary 2016-02-10 21:57:46 +00:00
parent 3ec8ecd4de
commit 4fe7ea00b0

5
red.js
View File

@ -1,6 +1,6 @@
#!/usr/bin/env node #!/usr/bin/env node
/** /**
* Copyright 2013, 2015 IBM Corp. * Copyright 2013, 2016 IBM Corp.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -194,6 +194,9 @@ function basicAuthMiddleware(user,pass) {
} }
return function(req,res,next) { return function(req,res,next) {
if (req.method === 'OPTIONS') {
return next();
}
var requestUser = basicAuth(req); var requestUser = basicAuth(req);
if (!requestUser || requestUser.name !== user || !checkPassword(requestUser.pass)) { if (!requestUser || requestUser.name !== user || !checkPassword(requestUser.pass)) {
res.set('WWW-Authenticate', 'Basic realm=Authorization Required'); res.set('WWW-Authenticate', 'Basic realm=Authorization Required');