Pectojin / duplicati-client

A command line client for controlling the Duplicati Server
GNU Lesser General Public License v2.1
75 stars 20 forks source link

Support HTTP Basic authentication #4

Closed jesjimher closed 6 years ago

jesjimher commented 6 years ago

Hi

I have my Duplicati server behind a Apache server, protected with HTTP Basic authentication. I think that's the cause that duc doesn't work and always returns error 401. As fas as I've seen, the --password parameter refers to Duplicati's internal password, so it doesn't work in my case.

Would it be possible to add some extra parameter to provide HTTP Basic username and password? I think having Duplicati behind a Apache proxy is a pretty typical configuration.

Thanks and congratulations, duc is a very nice and useful program!

Pectojin commented 6 years ago

Good idea!

I hadn't really thought about it, but I took at look at it and wasn't too complex.

I added support for a --basic-user and --basic-pass to the login method.

duc login https://duplicati.host.local --basic-user=rune --basic-pass=password

It's a layer on top of the regular authentication, so you can have both:

duc login https://duplicati.host.local --basic-user=rune --basic-pass=password --password=password

or interactively

duc login https://duplicati.host.local --basic-user=rune
Basic auth:
Password:
Login successful

It supports parameter files as usual and of course only prompts for the 2nd password if Duplicati asks.

There is one thing worth mentioning, though. When using basic auth it requires a base64 encoded string 'username:password'. This is stored in the config file, and of course sent over the network to the server. It's a good deal less secure than the regular login method because it's easier to figure out the password. If your apache host provides SSL then it's more secure, but anyone with access to your config file can easily figure out the password.

Pectojin commented 6 years ago

I added it to a the new release, 0.3.8, feel free to give it a try. duplicati_client/releases/tag/0.3.8_beta