From cdb35f4ce2fe51efd5a60a5df62e510533c38f24 Mon Sep 17 00:00:00 2001 From: bart2 Date: Thu, 22 Dec 2016 03:11:42 +0100 Subject: [PATCH] Fixes #16936 - Digest authentication not working in uri module (#18736) --- lib/ansible/module_utils/urls.py | 2 ++ test/integration/targets/uri/tasks/main.yml | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/lib/ansible/module_utils/urls.py b/lib/ansible/module_utils/urls.py index 1fd67bd564..68f78c0b8e 100644 --- a/lib/ansible/module_utils/urls.py +++ b/lib/ansible/module_utils/urls.py @@ -825,9 +825,11 @@ def open_url(url, data=None, headers=None, method=None, use_proxy=True, # use this username/password combination for urls # for which `theurl` is a super-url authhandler = urllib_request.HTTPBasicAuthHandler(passman) + digest_authhandler = urllib_request.HTTPDigestAuthHandler(passman) # create the AuthHandler handlers.append(authhandler) + handlers.append(digest_authhandler) elif username and force_basic_auth: headers["Authorization"] = basic_auth_header(username, password) diff --git a/test/integration/targets/uri/tasks/main.yml b/test/integration/targets/uri/tasks/main.yml index 4e7ce0c90d..68757c0f82 100644 --- a/test/integration/targets/uri/tasks/main.yml +++ b/test/integration/targets/uri/tasks/main.yml @@ -175,6 +175,13 @@ user: user password: passwd +- name: test digest auth + uri: + url: 'http://{{ httpbin_host }}/digest-auth/auth/user/passwd' + user: user + password: passwd + HEADER_Cookie: "fake=fake_value" + - name: test PUT uri: url: 'http://{{ httpbin_host }}/put'