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

Authentication not working #7

Closed mjmayer closed 6 years ago

mjmayer commented 6 years ago

I've been fighting authentication issues with the latest version of duplicati_client. I getting the error "Error getting salt from server", because the response from the requests.post is a 404. I'm not using basic auth. I've tried changing my password on duplicati to 1234, just in case one of special characters in my password were not getting escaped correctly. The problem has persisted.

        r = requests.post(baseurl, headers=headers, data=payload, verify=verify)
        if r.status_code != 200:
            common.log_output("Error getting salt from server", True, r.status_code)
            sys.exit(2)

Checking out out 1ef764669ee5e21e5d3b333d7c5b7477399c0625 resolves the issue.

HEAD is now at 1ef7646... added 'processed data' field to the get command to better display progress both in terms of number of processed files and in terms of how much data was actually processed
/duplicati_client # ./duplicati_client.py login
Loaded 2 parameters from file
Connecting to http://duplicati:8200...
Getting nonce and salt...
Hashing password...
Authenticating...
Connected
Code: 200
Login successful
/duplicati_client # git checkout master
Previous HEAD position was 1ef7646... added 'processed data' field to the get command to better display progress both in terms of number of processed files and in terms of how much data was actually processed
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
/duplicati_client # ./duplicati_client.py login
Loaded 2 parameters from file
Connecting to http://duplicati:8200...
Getting nonce and salt...
Error getting salt from server
Code: 404
Pectojin commented 6 years ago

What system is this running on, Python version, and the parameters provided?

I'm thinking it could be something related to the introduction of basic auth support right after 1ef764669ee5e21e5d3b333d7c5b7477399c0625, but I can't seem to replicate this on my system.

Are you able to reach http://duplicati:8200/login.cgi using for example cURL to make a post request?

# curl 'http://localhost:8200/login.cgi' --data 'get-nonce=1'
mjmayer commented 6 years ago

I'm running alpine linux 3.7.0 and python 3.6.3 .The only parameters I'm providing are in the parameters.yml file

password: secret-password
url: duplicati
verbose: True

Contents of config.yml

/ # cat ~/.config/duplicati-client/config.yml
authorization: ''
last_login: null
parameters_file: /root/.config/duplicati-client/parameters.yml
server:
  port: '8200'
  protocol: http
  url: duplicati
  verify: true
token: null
token_expires: 2018-05-18 19:33:20.212126
verbose: true
/ # duc version
Duplicati client version 0.3.9
/ # curl 'http://duplicati:8200/login.cgi' --data 'get-nonce=1'
{
  "Status": "OK",
  "Nonce": "2XVybvEdC1JDUvE+3/8BlIRdjQC+IlUt21nhu8CCHaA=",
  "Salt": "mwtVqXW0mHHUr7Tgy4Elz1t9x3JwwCtAmA5+oNHi8Qc="
/ # duc login
Loaded 3 parameters from file
Connecting to http://duplicati:8200...
Getting nonce and salt...
Error getting salt from server
Code: 404
Pectojin commented 6 years ago

Hmm, I have this replicated in a docker container running same alpine/python versions. Pretty odd it doesn't happen on Ubuntu 16.04/Python 3.6.3 or MacOS/Python 3.6.4. I'd expect Alpine to be more similar to Ubuntu than MacOS.

It's something I committed in 5b98a1cad56e36c5d7734c721f31fd06c2d018c4 that's to blame, but I'll need to sit down tonight to figure out exactly what.

Pectojin commented 6 years ago

Now I understand nothing. I came back to troubleshoot the issue now and I can no longer replicate it.

Still running Alpine 3.7.0 + Python 3.6.3 in a docker container against my 2.0.3.6_canary Duplicati server.

It would fail every time, when I tested 8 hours ago, but now it works every time. Regardless of what version I use and regardless of whether I connect directly or through Apache.

Edit: It's worth noting that the 404 error comes directly from the Duplicati server so maybe it's external from the client?? My first assumption was that the client was somehow sending a GET instead of POST to SERVER/login.cgi, which only works if it's a POST request, but if that was the issue then it would be consistent...

mjmayer commented 6 years ago

I had the same behavior. It wasn't working, I came back a day later then it worked. I figured it was just a fluke or maybe I messed up my test environment, not remembering what state I left it in. But when I redeployed the docker duplicati client, it stopped working.