Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=34964 Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/urlmon/http.c | 10 ++++++++++ dlls/urlmon/protocol.c | 38 ++++++++++++++++++++++++++++++++++++++ dlls/urlmon/urlmon_main.h | 1 + 3 files changed, 49 insertions(+)
diff --git a/dlls/urlmon/http.c b/dlls/urlmon/http.c index bee226bd474..241e630c338 100644 --- a/dlls/urlmon/http.c +++ b/dlls/urlmon/http.c @@ -231,6 +231,9 @@ static HRESULT handle_http_error(HttpProtocol *This, DWORD error) if(This->base.bindf & BINDF_NO_UI) dlg_flags |= FLAGS_ERROR_UI_FLAGS_NO_UI;
+ if(!error) + dlg_flags |= FLAGS_ERROR_UI_FILTER_FOR_ERRORS; + res = InternetErrorDlg(hwnd, This->base.request, error, dlg_flags, NULL); hres = res == ERROR_INTERNET_FORCE_RETRY || res == ERROR_SUCCESS ? RPC_E_RETRY : internet_error_to_hres(error); } @@ -989,3 +992,10 @@ HRESULT HttpSProtocol_Construct(IUnknown *outer, void **ppv)
return create_http_protocol(TRUE, outer, ppv); } + +void handle_basic_auth_error(Protocol *prot) +{ + HttpProtocol *This = impl_from_Protocol(prot); + + handle_http_error(This, ERROR_SUCCESS); +} diff --git a/dlls/urlmon/protocol.c b/dlls/urlmon/protocol.c index 2acffdc1ffe..4600a6ccb75 100644 --- a/dlls/urlmon/protocol.c +++ b/dlls/urlmon/protocol.c @@ -220,6 +220,44 @@ static void WINAPI internet_status_callback(HINTERNET internet, DWORD_PTR contex IInternetProtocol_Release(protocol->protocol); break;
+ case INTERNET_STATUS_RESPONSE_RECEIVED: + { + DWORD status, size; + + TRACE("%p INTERNET_STATUS_RESPONSE_RECEIVED (%u bytes)\n", protocol, *(const DWORD *)status_info); + + size = sizeof(status); + if (HttpQueryInfoW(protocol->request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, 0)) + { + TRACE("request status: %u\n", status); + if (status == HTTP_STATUS_DENIED) + { + WCHAR auth[2048]; + DWORD idx; + BOOL is_basic = FALSE; + + TRACE("=> HTTP_STATUS_DENIED\n"); + + size = ARRAY_SIZE(auth); + idx = 0; + while (HttpQueryInfoW(protocol->request, HTTP_QUERY_WWW_AUTHENTICATE, auth, &size, &idx)) + { + static const WCHAR basicW[] = {'B','a','s','i','c'}; /* Note: not nul-terminated */ + + TRACE("WWW_AUTHENTICATE: %s\n", debugstr_w(auth)); + + is_basic = !wcsnicmp(auth, basicW, ARRAY_SIZE(basicW)); + + size = ARRAY_SIZE(auth); + } + + if (is_basic) + handle_basic_auth_error(protocol); + } + } + break; + } + default: WARN("Unhandled Internet status callback %d\n", internet_status); } diff --git a/dlls/urlmon/urlmon_main.h b/dlls/urlmon/urlmon_main.h index 691c63e3b42..77c506db66d 100644 --- a/dlls/urlmon/urlmon_main.h +++ b/dlls/urlmon/urlmon_main.h @@ -228,6 +228,7 @@ tls_data_t *get_tls_data(void) DECLSPEC_HIDDEN; void unregister_notif_wnd_class(void) DECLSPEC_HIDDEN; HWND get_notif_hwnd(void) DECLSPEC_HIDDEN; void release_notif_hwnd(HWND) DECLSPEC_HIDDEN; +void handle_basic_auth_error(Protocol*) DECLSPEC_HIDDEN;
const char *debugstr_bindstatus(ULONG) DECLSPEC_HIDDEN;
Hi Dmitry,
On 6/7/21 6:39 PM, Dmitry Timoshkov wrote:
+void handle_basic_auth_error(Protocol *prot) +{
- HttpProtocol *This = impl_from_Protocol(prot);
- handle_http_error(This, ERROR_SUCCESS);
+}
Shouldn't we use IAuthenticate from bind status callback in this case?
Thanks,
Jacek
Hi Jacek,
Jacek Caban jacek@codeweavers.com wrote:
On 6/7/21 6:39 PM, Dmitry Timoshkov wrote:
+void handle_basic_auth_error(Protocol *prot) +{
- HttpProtocol *This = impl_from_Protocol(prot);
- handle_http_error(This, ERROR_SUCCESS);
+}
Shouldn't we use IAuthenticate from bind status callback in this case?
I'd appreciate some pointers how to implement this using BSC interface.
On 6/8/21 9:02 PM, Dmitry Timoshkov wrote:
Hi Jacek,
Jacek Caban jacek@codeweavers.com wrote:
On 6/7/21 6:39 PM, Dmitry Timoshkov wrote:
+void handle_basic_auth_error(Protocol *prot) +{
- HttpProtocol *This = impl_from_Protocol(prot);
- handle_http_error(This, ERROR_SUCCESS);
+}
Shouldn't we use IAuthenticate from bind status callback in this case?
I'd appreciate some pointers how to implement this using BSC interface.
My understanding is that we should ask for IAuthenticate interface on BSC and let it handle the authentication. GUI asking for credentials is likely something that urlmon needs to do in response to some return values from Authenticate, but I don't know that without testing it myself. Then there is a question if MSHTML should implement IAuthenticate, but it may not matter in your case (depending on the answer to above).
If you didn't already, I would suggest to write a test and experiment. I know that tests involving GUI may not be something for the tree (well, unless in interactive mode), but maybe with testing IAuthenticate it would be possible to test the rest of the stack.
Thanks,
Jacek
Jacek Caban jacek@codeweavers.com wrote:
My understanding is that we should ask for IAuthenticate interface on BSC and let it handle the authentication. GUI asking for credentials is likely something that urlmon needs to do in response to some return values from Authenticate, but I don't know that without testing it myself. Then there is a question if MSHTML should implement IAuthenticate, but it may not matter in your case (depending on the answer to above).
If you didn't already, I would suggest to write a test and experiment. I know that tests involving GUI may not be something for the tree (well, unless in interactive mode), but maybe with testing IAuthenticate it would be possible to test the rest of the stack.
I'm testing with wine's iexplore and pointing it to an internal site with Basic authentification. httpbin.org provides similar functionality for testing purposes: $> wine iexplore http://httpbin.org/basic-auth/foo/bar user: foo, password: bar. Does this qualify as a test, or you mean something more specific? If something more specific, how that should look like?
Hi Jacek,
Jacek Caban jacek@codeweavers.com wrote:
My understanding is that we should ask for IAuthenticate interface on BSC and let it handle the authentication. GUI asking for credentials is likely something that urlmon needs to do in response to some return values from Authenticate, but I don't know that without testing it myself. Then there is a question if MSHTML should implement IAuthenticate, but it may not matter in your case (depending on the answer to above).
If you didn't already, I would suggest to write a test and experiment. I know that tests involving GUI may not be something for the tree (well, unless in interactive mode), but maybe with testing IAuthenticate it would be possible to test the rest of the stack.
My current WIP patch with both interactive and non-interactive tests is attached, non-interactive tests pass, interactive ones - not yet. I'd appreciate any comments and suggestions.
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=92634
Your paranoid android.
=== w8adm (32 bit report) ===
urlmon: url.c:1914: Test failed: binding failed: 800c0005, expected 00000000 url.c:1925: Test failed: res = 00002ee7, expected 00000000 url.c:3259: Test failed: IMoniker_BindToStorage failed: 800c0005 url.c:3260: Test failed: unk == NULL url.c:1914: Test failed: binding failed: 800c0005, expected 80070005 url.c:1925: Test failed: res = 00002ee7, expected 80070005 url.c:3532: Test failed: BindToObject failed: 800c0005, expected 80070005 url.c:3594: Test failed: expected QueryInterface_IAuthenticate url.c:3596: Test failed: expected QueryService_IAuthenticate
On 6/16/21 5:53 PM, Dmitry Timoshkov wrote:
Hi Jacek,
Jacek Caban jacek@codeweavers.com wrote:
My understanding is that we should ask for IAuthenticate interface on BSC and let it handle the authentication. GUI asking for credentials is likely something that urlmon needs to do in response to some return values from Authenticate, but I don't know that without testing it myself. Then there is a question if MSHTML should implement IAuthenticate, but it may not matter in your case (depending on the answer to above).
If you didn't already, I would suggest to write a test and experiment. I know that tests involving GUI may not be something for the tree (well, unless in interactive mode), but maybe with testing IAuthenticate it would be possible to test the rest of the stack.
My current WIP patch with both interactive and non-interactive tests is attached, non-interactive tests pass, interactive ones - not yet. I'd appreciate any comments and suggestions.
The general approach seems reasonable to me. I would suggest to use test_BindToStorage() in tests, it's generally an easier code path (and parts that are present only in BindToObject() and not very interesting in this context).
Thanks,
Jacek