-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding initial NTLM support (from https://github.com/vision10/node-soap) #887
Conversation
2087e05
to
9782794
Compare
@microchip is there a way to add a test? |
I'll take a look. Should be theoretically possible. |
I don't know how to make the test but i can provide anything needed for it |
@microchip thanks so much for helping merge these changes in! As far as testing, |
guys, are there news for this? |
@aijanai I've not had chance to do any more with this at work at the moment I'm afraid :( |
yes yes, it's perfectly ok, but can it just be merged as it is? Since this is not breaking anything, could we please just get over the 0.7% coverage drop and release it to the public? |
@aijanai For what it's worth, I'm using the fork I made above in production, and it seems to be working perfectly fine. Haven't tested the latest merges yet, but there's no good reason they wouldn't work. |
Uhm. Then there must be something I am seriously doing wrong because it keeps crashing with:
My dependencies are:
The code is just this simple 50 lines test script:
I took it from the GitHub website and NPM page. Is this how it is supposed to look like? |
@aijanai Wouldn't you need to change the dependency to be microchip/node-soap to use the NTLM merged code? As I said, current code is untested, but I can't see anything that'd immediately break it. (Please note my fork is entirely unsupported, I merged in code changes someone else had made and tidied up a bit, that's it.) |
you need to require var soap = require('soap-ntlm-2'), not the original soap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add tests for the new features 👍
lib/http.js
Outdated
return callback(err); | ||
} | ||
// if result is stream | ||
if( typeof res.body != 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use !==
for strict checl
lib/security/NTLMSecurity.js
Outdated
var _ = require('lodash'); | ||
|
||
function NTLMSecurity(username, password, domain, workstation) { | ||
if (typeof username == "object") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use ===
package.json
Outdated
@@ -14,6 +14,8 @@ | |||
"ejs": "~2.5.5", | |||
"finalhandler": "^1.0.3", | |||
"lodash": "^3.10.1", | |||
"optional": "^0.1.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where do we need this dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea, it came with the original modification. Happy to remove it if it's not used.
lib/security/NTLMSecurity.js
Outdated
} | ||
|
||
NTLMSecurity.prototype.addHeaders = function (headers) { | ||
headers.Connection = 'keep-alive'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, is it intentional, that the method addHeaders
does not add headers
anywhere but sets a Connection
property on the (hopefully available) headers
param (Object)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks that way, it's in the original code. It works the same way as in BearerSecurity, which I'd guess is what this code is based on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I see.... hmmm.....
lib/security/NTLMSecurity.js
Outdated
}; | ||
|
||
NTLMSecurity.prototype.addOptions = function (options) { | ||
_.merge(options, this.defaults); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you call it this way, only options
will be mutated, but this.defaults
will stay "like it is" - is this really the behaviour you/we want?
I'm happy to clean up the code where mentioned, but to be honest, it should probably be refactored in order to be properly testable. I currently don't have the time to do it (or the knowledge of this setup, I'm just fixing up what's already here!) If I get chance to at some point, I'll happily do it, but in the meantime, if anyone can refactor it, I welcome pull requests. |
Any idea when this could get merged? |
We need at least a few tests for the new features in order to merge the PR (see our guidelines on Submitting a Pull Request). As @insanityinside said in his previous comment
A PR over at his fork in order to get things cleaned up and tested is very much appreciated 😺 |
Just opened a PR at the @insanityinside fork to fix linting issues and added a handful of tests. |
@benthepoet I'll take a look at merging it this evening, then see if I can bring the codebase up to date and merge up. I've not tested it in a bit, but I've got test apps I can run with the updated code. |
Fixed linting issues and added unit tests for NTLMSecurity Haven't had chance to test this yet or rebase it on the live branch, but pulling it in is probably a good start!
Pulling in changes from @vision10 https://github.com/vision10/node-soap (via @r24y https://github.com/r24y/node-soap/ who did some cleanup) into one clean package for a pull request.
This is a revised version of pull #885.
Cleaned up version of #776 and #741, syntax altered to match project. I've tested it against a live NTLM SOAP server, and it seems to work perfectly. Added basic instructions to the README with respect to syntax usage with the other security types, and regenerated TOC.
There is currently a check in http.js in HttpClient.prototype.request which has an if/else for the ntlm property. I suspect there's a better way to do this, but it's how it was done in the original code. Suggestions and pointers welcome, or move code around as appropriate. The code may need refactoring, but it seems reasonable enough to work with for now, and does seem to be functioning correctly.
Also requires tests implementing.