Error with WebDAV requiring http authentication

Bug #294560 reported by dmuir
4
Affects Status Importance Assigned to Milestone
Bazaar WebDAV plugin
Triaged
Medium
Unassigned

Bug Description

Related to: #72792

bzr 1.8
webdav 1.6.0
python 2.5
pycurl 7.16.4

bzr init-repo http+webdav://<urlToRepo>
gives me:
bzr: ERROR: Invalid http response for http://<urlToRepo>: Unable to handle http code 401: Authorization Required

bzr init-repo http+webdav://<user>:<pass>@<urlToRepo>
gives me:
bzr: ERROR: http://<urlToRepo> is permanently redirected to http://<urlToRepo/

I've tried supplying the authentication details in authentication.conf, but as far as I can tell, this file is being ignored.

Here's the debug for:
bzr init-repo http+webdav://bzr.tekika.com/edval

0.032 encoding stdout as sys.stdout encoding 'UTF-8'
0.033 bzr arguments: [u'init-repo', u'http+webdav://bzr.tekika.com/edval']
0.033 looking for plugins in /home/dmuir/.bazaar/plugins
0.036 looking for plugins in /usr/lib/python2.5/site-packages/bzrlib/plugins
0.036 Plugin name __init__ already loaded
0.037 Plugin name __init__ already loaded
0.084 encoding stdout as sys.stdout encoding 'UTF-8'
0.664 Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 849, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 795, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 495, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 1412, in run
    to_transport.ensure_base()
  File "/usr/lib/python2.5/site-packages/bzrlib/transport/__init__.py", line 341, in ensure_base
    self.mkdir('.')
  File "/home/dmuir/.bazaar/plugins/webdav/webdav.py", line 577, in mkdir
    response = self._perform(request)
  File "/usr/lib/python2.5/site-packages/bzrlib/transport/http/_urllib.py", line 78, in _perform
    response = self._opener.open(request)
  File "/usr/lib/python2.5/urllib2.py", line 387, in open
    response = meth(req, response)
  File "/usr/lib/python2.5/site-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 1332, in http_response
    code, msg, hdrs)
  File "/usr/lib/python2.5/urllib2.py", line 425, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.5/urllib2.py", line 360, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.5/site-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 1349, in http_error_default
    % (code, msg))
InvalidHttpResponse: Invalid http response for http://bzr.tekika.com/edval: Unable to handle http code 401: Authorization Required

0.664 return code 3

Here's the debug log for:
bzr init-repo http+webdav://<user>:<pass>@bzr.tekika.com/edval

0.016 encoding stdout as sys.stdout encoding 'UTF-8'
0.017 bzr arguments: [u'init-repo', u'-Dhttp', u'http+webdav://<user>:<pass>@bzr.tekika.com/edval']
0.017 looking for plugins in /home/dmuir/.bazaar/plugins
0.021 looking for plugins in /usr/lib/python2.5/site-packages/bzrlib/plugins
0.021 Plugin name __init__ already loaded
0.021 Plugin name __init__ already loaded
0.070 encoding stdout as sys.stdout encoding 'UTF-8'
0.095 * About to connect() to bzr.tekika.com:80
0.506 > MKCOL /edval
0.506 > Host: bzr.tekika.com
> Accept: */*
> User-Agent: bzr/1.8 (urllib)
> Connection: Keep-Alive
> Pragma: no-cache
> Cache-Control: max-age=0

0.757 < HTTP/1.1 401 Authorization Required
0.758 < Date: Thu, 06 Nov 2008 06:29:35 GMT
< Server: Apache/2.0.61 (Unix) PHP/4.4.7 mod_ssl/2.0.61 OpenSSL/0.9.7e mod_fastcgi/2.4.2 Phusion_Passenger/2.0.3 DAV/2
< WWW-Authenticate: Basic realm="Edval Area"
< Vary: Accept-Encoding
< Content-Length: 520
< Keep-Alive: timeout=2, max=100
< Connection: Keep-Alive
< Content-Type: text/html; charset=iso-8859-1

0.759 > MKCOL /edval
0.760 > Host: bzr.tekika.com
> Accept: */*
> User-Agent: bzr/1.8 (urllib)
> Connection: Keep-Alive
> Pragma: no-cache
> Cache-Control: max-age=0
> Authorization: Basic ZGF2aWQ6bXVpcg==

1.006 < HTTP/1.1 301 Moved Permanently
1.006 < Date: Thu, 06 Nov 2008 06:29:35 GMT
< Server: Apache/2.0.61 (Unix) PHP/4.4.7 mod_ssl/2.0.61 OpenSSL/0.9.7e mod_fastcgi/2.4.2 Phusion_Passenger/2.0.3 DAV/2
< Location: http://bzr.tekika.com/edval/
< Vary: Accept-Encoding
< Content-Length: 236
< Keep-Alive: timeout=2, max=99
< Connection: Keep-Alive
< Content-Type: text/html; charset=iso-8859-1

1.015 Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 849, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 795, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 495, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 1412, in run
    to_transport.ensure_base()
  File "/usr/lib/python2.5/site-packages/bzrlib/transport/__init__.py", line 341, in ensure_base
    self.mkdir('.')
  File "/home/dmuir/.bazaar/plugins/webdav/webdav.py", line 577, in mkdir
    response = self._perform(request)
  File "/usr/lib/python2.5/site-packages/bzrlib/transport/http/_urllib.py", line 94, in _perform
    qual_proto=self._scheme)
RedirectRequested: http://bzr.tekika.com/edval is permanently redirected to http://bzr.tekika.com/edval/

1.015 return code 3

Revision history for this message
Vincent Ladeuil (vila) wrote : Re: [Bug 294560] [NEW] Error with WebDAV requiring http authentication
Download full text (3.3 KiB)

>>>>> "david" == dmuir writes:

    david> Public bug reported:

Thanks a lot ! I'll to clarify a couple of points below.

    david> Related to: #72792

No, it's a different kind of problem.

    david> bzr 1.8
    david> webdav 1.6.0
    david> python 2.5
    david> pycurl 7.16.4

bzr-webdav doesn't make use of pycurl if you see pycurl involved,
we have a bug :)

    david> bzr init-repo http+webdav://<urlToRepo>
    david> gives me:
    david> bzr: ERROR: Invalid http response for http://<urlToRepo>: Unable to handle http code 401: Authorization Required

Basically either the credentials were not provided or they were
wrong (this doesn't imply a user error but it may be the case).

    david> bzr init-repo http+webdav://<user>:<pass>@<urlToRepo>
    david> gives me:
    david> bzr: ERROR: http://<urlToRepo> is permanently redirected to http://<urlToRepo/

As mentioned in the NOTES file in plugin directory:

 # DirectorySlash tells apache to reply with redirections if
 # directories miss their final '/'. It does not play well with
 # bzr (to they the least) and provide no benefits in our
 # case. So just turn it off.
 DirectorySlash Off

I think this is the root cause. Can you try that option on your
server ?

    david> I've tried supplying the authentication details in authentication.conf,
    david> but as far as I can tell, this file is being ignored.

Can you join your authentication.conf to this bug so we can debug
it may be ?

You may also want to use -Dauth to see what section is taken into
account (or not).

<snip/>

    david> Here's the debug log for:
    david> bzr init-repo http+webdav://<user>:<pass>@bzr.tekika.com/edval

    david> 0.016 encoding stdout as sys.stdout encoding 'UTF-8'
    david> 0.017 bzr arguments: [u'init-repo', u'-Dhttp', u'http+webdav://<user>:<pass>@bzr.tekika.com/edval']
    david> 0.017 looking for plugins in /home/dmuir/.bazaar/plugins
    david> 0.021 looking for plugins in /usr/lib/python2.5/site-packages/bzrlib/plugins
    david> 0.021 Plugin name __init__ already loaded
    david> 0.021 Plugin name __init__ already loaded
    david> 0.070 encoding stdout as sys.stdout encoding 'UTF-8'
    david> 0.095 * About to connect() to bzr.tekika.com:80
    david> 0.506 > MKCOL /edval
    david> 0.506 > Host: bzr.tekika.com
    >> Accept: */*
    >> User-Agent: bzr/1.8 (urllib)
    >> Connection: Keep-Alive
    >> Pragma: no-cache
    >> Cache-Control: max-age=0

    david> 0.757 < HTTP/1.1 401 Authorization Required
    david> 0.758 < Date: Thu, 06 Nov 2008 06:29:35 GMT
    david> < Server: Apache/2.0.61 (Unix) PHP/4.4.7 mod_ssl/2.0.61 OpenSSL/0.9.7e mod_fastcgi/2.4.2 Phusion_Passenger/2.0.3 DAV/2
    david> < WWW-Authenticate: Basic realm="Edval Area"
    david> < Vary: Accept-Encoding
    david> < Content-Length: 520
    david> < Keep-Alive: timeout=2, max=100
    david> < Connection: Keep-Alive
    david> < Content-Type: text/html; charset=iso-8859-1

    david> 0.759 > MKCOL /edval
    david> 0.760 > Host: bzr.tekika.com
    >> Accept: */*
    >> User-Agent: bzr/1.8 (urllib)
    >> Connection: Keep-Alive
    >> Pragma: no-cache
    >> Cache-Control: max-age=0

    >> Authorization: Basic
...

Read more...

Revision history for this message
dmuir (dmuir) wrote :

I only mentioned pyCurl because the other report mentioned that it'll be used instead if available... or maybe I misread it...

As for changing the WebDAV setup... I can't since I don't own the config files. (Shared hosting) I can ask support to change it for me though. Wouldn't be surprised if this is the problem though, since the redirect shows a directory with a trailing slash. Including the trailing slash in the urlToRepo doesn't make a difference though. Ubuntu's "Connect to Server" fails in the same way though.

The username/password I'm entering is correct (am able to access it through Nautilus by entering dav://urlToRepo directly in address bar)

-Dauth give me:

0.012 encoding stdout as sys.stdout encoding 'UTF-8'
0.012 bzr arguments: [u'init-repo', u'-Dauth', u'http+webdav://bzr.tekika.com/edval']
0.013 looking for plugins in /home/dmuir/.bazaar/plugins
0.016 looking for plugins in /usr/lib/python2.5/site-packages/bzrlib/plugins
0.016 Plugin name __init__ already loaded
0.016 Plugin name __init__ already loaded
0.066 encoding stdout as sys.stdout encoding 'UTF-8'
0.663 Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 849, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 795, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 495, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 1412, in run
    to_transport.ensure_base()
  File "/usr/lib/python2.5/site-packages/bzrlib/transport/__init__.py", line 341, in ensure_base
    self.mkdir('.')
  File "/home/dmuir/.bazaar/plugins/webdav/webdav.py", line 577, in mkdir
    response = self._perform(request)
  File "/usr/lib/python2.5/site-packages/bzrlib/transport/http/_urllib.py", line 78, in _perform
    response = self._opener.open(request)
  File "/usr/lib/python2.5/urllib2.py", line 387, in open
    response = meth(req, response)
  File "/usr/lib/python2.5/site-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 1332, in http_response
    code, msg, hdrs)
  File "/usr/lib/python2.5/urllib2.py", line 425, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.5/urllib2.py", line 360, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.5/site-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 1349, in http_error_default
    % (code, msg))
InvalidHttpResponse: Invalid http response for http://bzr.tekika.com/edval: Unable to handle http code 401: Authorization Required

0.664 return code 3

my auth file is:
~/.bazaar/authentication.conf

[bzr.tekika.com]
scheme=http
host=bzr.tekika.com
user=<username>
password=<password>

Also, regarding Basic Authentication, my webhost doesn't give me an option there, so it's all I've got :-(
And the password is just temporary until I get things working.

Revision history for this message
Vincent Ladeuil (vila) wrote :

Your auth file is correct.

I looked into how work around the problem from the plugin but this is really ugly and roughly requires that each time apache says: "You want to work with that directory, it's indeed a directory, ask me to do the same thing but put a slash at the end of the path" we have one more round-trip to the server.

So the performance really suffers (and if I was able to reproduce the bug and partly fixed it, this really doesn't play nice with bzr and will require a lot of rewriting).

Does your webhost allows .htaccess files ? That may be the best option here.

Changed in bzr.webdav:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
dmuir (dmuir) wrote :

Yes, it does, but I can't edit them myself. The file is owned by a special webdav user. I can ask support to modify it for me though. I'm assuming I should just ask them to add:
DirectorySlash Off
to the .htaccess file?

Revision history for this message
Vincent Ladeuil (vila) wrote :

Sothing like that, yes. Show them the NOTES file as this is a concrete working exmaple but note that it is used in the server configuration files and may need tweaks to be used in a .htaccess file.

I didn't test using that option in an .htaccess file so any feedback will be greatly welcomed.

Revision history for this message
dmuir (dmuir) wrote :
Download full text (3.7 KiB)

Trying to see if I can fix this issue myself by using a .htaccess file elsewhere and applying rewrite rules.

I've added a folder called repos/ which has the following .htaccess file:

RewriteEngine on

RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule ^(.+[^/])$ /$1/ [L]

RewriteRule ^(.*)$ /$1

in short:
rewrites everything to point to a webdav folder, but automatically adds the trailing slash to directories.
http://<host>/repos/project/.bzr => http://<host>/project/.bzr/

Everything seems to work up until it tries to acquire a lock.
At this point, It seems to lose the connection and then instead of checking to see if the previous command was completed, it attempts to run the previous command. A timeout issue? Is there a way to increase the timeout?

Tried to sanitize as much as possible...

....

2.493 > MKCOL /repos/project/.bzr/branch-lock/l3nm0wabky.tmp
2.493 > Host: bzr.tekika.com
> Accept: */*
> User-Agent: bzr/1.9 (urllib)
> Connection: Keep-Alive
> Pragma: no-cache
> Cache-Control: max-age=0
> Authorization: Basic

2.658 < HTTP/1.1 201 Created
2.658 < Date: Tue, 11 Nov 2008 06:59:25 GMT
< Server: Apache/2.0.61 (Unix) PHP/4.4.7 mod_ssl/2.0.61 OpenSSL/0.9.7e mod_fastcgi/2.4.2 Phusion_Passenger/2.0.3 DAV/2
< Location: http://bzr.tekika.com/project/.bzr/branch-lock/l3nm0wabky.tmp
< MS-Author-Via: DAV
< Vary: Accept-Encoding
< Content-Length: 212
< Keep-Alive: timeout=2, max=94
< Connection: Keep-Alive
< Content-Type: text/html

2.661 > PUT /repos/project/.bzr/branch-lock/l3nm0wabky.tmp/info
2.661 > Content-Length: 112
> Connection: Keep-Alive
> Accept: */*
> User-Agent: bzr/1.9 (urllib)
> Host: bzr.tekika.com
> Pragma: no-cache
> Cache-Control: max-age=0
> Content-Type: application/octet-stream
> Authorization: Basic

3.071 < HTTP/1.1 201 Created
3.071 < Date: Tue, 11 Nov 2008 06:59:25 GMT
< Server: Apache/2.0.61 (Unix) PHP/4.4.7 mod_ssl/2.0.61 OpenSSL/0.9.7e mod_fastcgi/2.4.2 Phusion_Passenger/2.0.3 DAV/2
< Location: http://bzr.tekika.com/project/.bzr/branch-lock/l3nm0wabky.tmp/info
< MS-Author-Via: DAV
< Vary: Accept-Encoding
< Content-Length: 215
< Keep-Alive: timeout=2, max=93
< Connection: Keep-Alive
< Content-Type: text/html

3.072 > MOVE /repos/project/.bzr/branch-lock/l3nm0wabky.tmp
3.072 > Destination: http://bzr.tekika.com/repos/project/.bzr/branch-lock/held
> Connection: Keep-Alive
> Accept: */*
> User-Agent: bzr/1.9 (urllib)
> Host: bzr.tekika.com
> Overwrite: F
> Pragma: no-cache
> Cache-Control: max-age=0
> Authorization: Basic

3.323 * About to connect() to bzr.tekika.com:80
3.665 > MOVE /repos/project/.bzr/branch-lock/l3nm0wabky.tmp
3.665 > Destination: http://bzr.tekika.com/repos/project/.bzr/branch-lock/held
> Connection: Keep-Alive
> Accept: */*
> User-Agent: bzr/1.9 (urllib)
> Host: bzr.tekika.com
> Overwrite: F
> Pragma: no-cache
> Cache-Control: max-age=0
> Authorization: Basic

4.199 > DELETE /repos/project/.bzr/branch-lock/l3nm0wabky.tmp/info
4.199 > Host: bzr.tekika.com
> Accept: */*
> User-Agent: bzr/1.9 (urllib)
> Connection: Keep-Alive
> Pragma: no-cache
> Cache-Control: max-age=0
> Authorization: Basic

4.199 * About to connect() to bzr.tekika.com:80
4.569 > DELETE /repos/project/.bzr/branch-...

Read more...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.