Bug 45943 - CORS: Cross-domain PROPFIND XHR request for servers with authentication does not work in Safari.
Summary: CORS: Cross-domain PROPFIND XHR request for servers with authentication does ...
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: XML (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows Vista
: P2 Major
Assignee: Nobody
URL: http://www.ajaxfilebrowser.com/?Cross...
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-16 20:10 PDT by Vladimir Lichman
Modified: 2010-10-01 10:40 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Lichman 2010-09-16 20:10:43 PDT
When you submit cross-domain PROPFIND request in Safari using XmlHttpRequest to a server that is using Basic, Digest or Windows authentication the request silently fails. No login dialog is displayed.

For servers with anonymous authentication the request works with no problem.

Steps to Reproduce:
1. Go to http://www.ajaxfilebrowser.com/?CrossDomainDemo
2. Enter url of the WebDAV server that is using authentication in 'WebDAV Server Url' field. For example this one that is using Basic: http://www.ithit.com:8044/
 Login: User1
 Password: pwd
3. Click "Connect" button.

Using a debugging proxy you can find that preflight OPTIONS request is being sent but no login dialog is displayed and no PROPFIND request is sent. 

Chrome browser work with Basic, Digest and Integrated windows with no problem.
Comment 1 Alexey Proskuryakov 2010-09-17 15:26:33 PDT
This sounds like a serious issue in Chrome loading code, CC'ing Darin Fisher.

Users are never supposed to get an authentication dialog for a cross origin XHR - if they did, that would be an extremely confusing UI. So, the spec forbids it, and the users should be already logged in to the remote site in order for authenticated cross origin requests to work. And even then, the requests only work if "withCredentials" attribute is set on XMLHttpRequest object.

Closing as INVALID, since this is not a bug as reported, but this should be filed in Chrome bug tracker.
Comment 2 Vladimir Lichman 2010-09-17 22:26:40 PDT
Thank you for explanation Alexey. Does this mean that before sending PROPFIND to server with Basic auth we have to send GET request somehow (for example include a hidden iframe on a page)? The GET request will trigger the login dialog, and after that we can send PROPFIND with withCredentials=true ?

By the way cross-origin XHR request for PROPFIND works in Firefox with Digest auth. But OPTIONS are allowed to be unauthenticated on our Digest test server.
Comment 3 Alexey Proskuryakov 2010-09-20 10:55:54 PDT
This doesn't depend on the method. Here is what XMLHttpRequest 2 draft spec says:

-------------
If authentication fails, XMLHttpRequest origin and the request URL are same origin, Authorization is not in the list of author request headers, request username is null, and request password is null, user agents should prompt the end user for their username and password.

Otherwise, if authentication fails, user agents must not prompt the end user for their username and password.
-------------

Note that for requests that are not same origin, we must not prompt the user.

> Does this mean that before sending PROPFIND to server with Basic auth we have to send GET request somehow (for example include a hidden iframe on a page)?

This may work, but it really shouldn't - it makes no sense to display an authorization dialog for a site other than the one the user has navigated to. If this works, perhaps we should prevent it in the future.

A much better UI would be to let the user know what they doing by prominently displaying the other site's UI for authentication.

> By the way cross-origin XHR request for PROPFIND works in Firefox with Digest auth.

If Firefox asks for credentials when making cross origin XMLHttpRequests, then it's a Firefox bug.
Comment 4 Vladimir Lichman 2010-09-20 21:47:33 PDT
Alexey, what we are trying to implement a Ajax interface for WebDAV server. WebDAV server does not have any user interface and no UI for authentication as well. Most WebDAV servers use Basic, Digest or Integrated Windows authentication. What would be the correct approach in this case? 

Our customers request a cross domain support as it is inconvenient for them (and often not possible) to deploy JavaScript files, HTML pages and images to existing WebDAV server. It looks like this is the only blocking issue left.


(In reply to comment #3)
> This doesn't depend on the method. Here is what XMLHttpRequest 2 draft spec says:
> 
> -------------
> If authentication fails, XMLHttpRequest origin and the request URL are same origin, Authorization is not in the list of author request headers, request username is null, and request password is null, user agents should prompt the end user for their username and password.
> 
> Otherwise, if authentication fails, user agents must not prompt the end user for their username and password.
> -------------
> 
> Note that for requests that are not same origin, we must not prompt the user.
> 
> > Does this mean that before sending PROPFIND to server with Basic auth we have to send GET request somehow (for example include a hidden iframe on a page)?
> 
> This may work, but it really shouldn't - it makes no sense to display an authorization dialog for a site other than the one the user has navigated to. If this works, perhaps we should prevent it in the future.
> 
> A much better UI would be to let the user know what they doing by prominently displaying the other site's UI for authentication.
> 
> > By the way cross-origin XHR request for PROPFIND works in Firefox with Digest auth.
> 
> If Firefox asks for credentials when making cross origin XMLHttpRequests, then it's a Firefox bug.
Comment 5 Anne van Kesteren 2010-09-21 05:55:43 PDT
You can generate and set the Authorization header yourself. It will not be included in the preflight request, but will be part of the actual request. The preflight request is just a server capability check, to see whether it understands CORS at all, so does not need to be authenticated.
Comment 6 Alexey Proskuryakov 2010-09-21 08:43:05 PDT
> You can generate and set the Authorization header yourself.

Will it work for cross origin requests? That would enable distributed password search, wouldn't it?
Comment 7 Anne van Kesteren 2010-09-23 03:12:13 PDT
The resource has to opt in to allowing that header in cross-origin requests.
Comment 8 Julian Reschke 2010-10-01 01:56:20 PDT
As far as I understand, the CORS spec requires the server to handle OPTIONS without authentication. That's a serious problem for protocols that already use OPTIONS, and require authentication. In many frameworks, authentication happens before the request (headers + body) can be expected, so this will be very hard to deploy.
Comment 9 Alexey Proskuryakov 2010-10-01 10:40:23 PDT
Unless I'm missing something, the OPTIONS issue is tangentially related to this at best. Either way, cross origin XMLHttpRequest isn't going to show an authentication dialog.