duplicati / duplicati

Store securely encrypted backups in the cloud!
Other
10.61k stars 881 forks source link

http-send-url doesn't appear to work with Basic Auth URLs #3711

Open davidearl opened 5 years ago

davidearl commented 5 years ago

Environment info

Description

I am trying to use http-send-url to post logs to a URL of the form https://USER:PASSWORD@domain:PORT/... i.e. with Basic Auth. PORT seems OK (the server responds), but I get a 401 Unauthorized response from the server, Exactly the same URL works fine directly in Chrome or cURL. It appears Duplicati isn't handling URLs of that form correctly.

Steps to reproduce

  1. Add http-send-url as advanced setting to backup, to post to a site which requires basic authentication
  2. Run backup

Screenshots

Debug log

2019-04-03 21:34:58 +01 - [Warning-Duplicati.Library.Modules.Builtin.SendHttpMessage-HttpResponseError]: HTTP Response: 401 - Unauthorized: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Unauthorized</title>
</head><body>
<h1>Unauthorized</h1>
<p>This server could not verify that you
are authorized to access the document
requested.  Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
<hr>
<address>Apache/2.4.25 (Raspbian) Server at [REDACTED] Port [REDACTED]</address>
</body></html>

System.Net.WebException: The remote server returned an error: (401) Unauthorized.
   at System.Net.HttpWebRequest.GetResponse()
   at Duplicati.Library.Modules.Builtin.SendHttpMessage.SendMessage(String subject, String body)
2019-04-03 21:34:58 +01 - [Warning-Duplicati.Library.Modules.Builtin.ReportHelper-ReportSubmitError]: Failed to send message: System.Net.WebException: The remote server returned an error: (401) Unauthorized.

System.Net.WebException: The remote server returned an error: (401) Unauthorized.
   at Duplicati.Library.Modules.Builtin.SendHttpMessage.SendMessage(String subject, String body)
   at Duplicati.Library.Modules.Builtin.ReportHelper.OnFinish(Object result)
ts678 commented 5 months ago

Assuming that http-send-url really means send-http-url:

https://github.com/duplicati/duplicati/blob/e7c191389cdb3fdb9500d83ebd06e0ae99634fd1/Duplicati/Library/Modules/Builtin/SendHttpMessage.cs#L198-L224

is probably the setup code, but I don't see it trying to set up HttpWebRequest.Credentials Property, so this is likely a feature gap. There are many ways to authenticate, so this enhancement could go on and on, but it's arguably missing code, not broken code.

Exactly the same URL works fine directly in Chrome or cURL

Both focus on URLs, so that's not very surprising. For a workaround, perhaps use run-script-after and curl. See Example Scripts.

davidearl commented 5 months ago

missing code, not broken code

A bug by any other name would smell as sweet

WebRequest.Create(m_url)

Why would WebRequest censor a URL like that?

For a workaround...

Well, it was five years ago, so I rather think the moment has passed! IIRC I used email instead. But thank you anyway.