avisi / grunt-webdav-sync

Synchronizes a local folder to a remote webdav folder as part of your Grunt build
https://npmjs.org/package/grunt-webdav-sync
MIT License
3 stars 9 forks source link

Support digest authentication #1

Closed jfix closed 10 years ago

jfix commented 11 years ago

Hi,

first of all thanks for the plugin. I'm attempting to use a WebDAV server using the digest authentication method. The current version of the grunt-webdav-sync task doesn't seem to support this method, because I got the following error message when attempting the creation of a directory:

Resource requires authorization or authorization was denied. For url: http://abc:abc@127.0.0.1:8887/test

File sync'ing didn't work even though there doesn't seem to be any useful message coming back from the server to indicate that there was a problem because the plugin returns:

Searching for files in: src/**
>> Found 1 files, Start uploading files to http://abc:abc@localhost:8887/

Done, without errors.
Completed in 0.786s at Sun Nov 03 2013 18:27:19 GMT+0100 (CET) - Waiting...
OK

When changing my WebDAV server's authentication method to basic, suddenly everything started working as expected.

I'm not an expert on how to add support for the digest authentication method, but it would be great if it existed. :-)

Thanks, Jakob.

mitchelkuijpers commented 11 years ago

I will investigate how to add support for digest authentication but it does not seem so hard. Thank you for your extensive Issue :+1:

mitchelkuijpers commented 10 years ago

I have replaced the basic http client for request.js which should include support for digest authentication: ffd8208798e90f14a4a2a8c77fe1b84b3bc8365b. I tried using jsDAV to test the authentication but the implementation does not seem to work correctly, so please try it out the new version 0.2.4 and let me know if the digest authentication works :)

jfix commented 10 years ago

Just upgraded to 0.2.4 to give this a spin. Unfortunately, there seems to be a problem with the handling of directories, with both the 'basic' and the 'digest' authentication schemes.

I have this directory structure that I'm 'watching' with Grunt:

src/
     test/
          ascript
     test.xqy
     test2.xqy

Here's what happens when I change the ascript file (or any other, for that matter):

>> File "src/test/ascript" changed.

Running "webdav_sync:default" (webdav_sync) task
starting webdav_sync
Searching for files in: src/**
>> Found 4 files, Start uploading files to http://admin:admin@127.0.0.1:8887/
>> Unknown error while deleting a dir gave statuscode: 207
>> Unknown error while deleting a dir gave statuscode: 207
Warning: Task "webdav_sync:default" failed. Use --force to continue.

Aborted due to warnings.
Completed in 0.785s at Sun Nov 24 2013 17:49:08 GMT+0100 (CET) - Waiting...

I don't really understand why it's attempting to delete a directory ... The status code 207 is a WebDAV-specific success response. But in any case the directory is not created and the file it should contain doesn't exist either in the WebDAV location. At least, the behaviour is the same for digest and basic. ;-)

mitchelkuijpers commented 10 years ago

I have added this in the last commit to get more of a "synchronisation" behaviour. Is this behaviour a problem for you? Maybe this should be a configuration property..

jfix commented 10 years ago

I don't understand what you mean :( -- Currently I cannot use this grunt plugin because it throws errors when (in my mind) it shouldn't. Thanks (and happy new year).

mitchelkuijpers commented 10 years ago

@jfix Does digest authentication work for you? If it does we can close this issue.

jfix commented 10 years ago

Yes, I've just tried the latest version 0.2.7, using both basic and digest, and they both work. Great work! Bedankt!

mitchelkuijpers commented 10 years ago

Alstublieft!

dviramontes commented 10 years ago

For basic auth: on the grunt task remote_path string

are you guys needing to do something like this ?:

remote_path: user + ":" + (new Buffer(pass).toString('base64')) + "@localhost:8080/blablah"

or can i just pass the password as a regular string ?

im hitting an authentication issue, just wondering if its something i'm doing wrong.

thanks guys

jfix commented 10 years ago

Hi,

my remote_path for testing looks like this:

remote_path: 'http://admin:admin@127.0.0.1:8888/'

no need to base64-encode the password.

dviramontes commented 10 years ago

Hey Thanks @jfix very helpful