Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
403f4881
Commit
403f4881
authored
Oct 07, 2014
by
Iiro Uusitalo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enables 'basic auth force' -feature globally
parent
a9712bb0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletions
+10
-1
lib/ansible/module_utils/urls.py
+10
-1
No files found.
lib/ansible/module_utils/urls.py
View file @
403f4881
...
@@ -229,6 +229,7 @@ import sys
...
@@ -229,6 +229,7 @@ import sys
import
socket
import
socket
import
platform
import
platform
import
tempfile
import
tempfile
import
base64
# This is a dummy cacert provided for Mac OS since you need at least 1
# This is a dummy cacert provided for Mac OS since you need at least 1
...
@@ -523,6 +524,7 @@ class SSLValidationHandler(urllib2.BaseHandler):
...
@@ -523,6 +524,7 @@ class SSLValidationHandler(urllib2.BaseHandler):
def
open_url
(
url
,
data
=
None
,
headers
=
None
,
method
=
None
,
use_proxy
=
True
,
def
open_url
(
url
,
data
=
None
,
headers
=
None
,
method
=
None
,
use_proxy
=
True
,
force
=
False
,
last_mod_time
=
None
,
timeout
=
10
,
validate_certs
=
True
,
force
=
False
,
last_mod_time
=
None
,
timeout
=
10
,
validate_certs
=
True
,
url_username
=
None
,
url_password
=
None
,
http_agent
=
None
):
url_username
=
None
,
url_password
=
None
,
http_agent
=
None
):
force_basic_auth
=
dict
(
required
=
False
,
type
=
'bool'
)
'''
'''
Fetches a file from an HTTP/FTP server using urllib2
Fetches a file from an HTTP/FTP server using urllib2
'''
'''
...
@@ -554,6 +556,7 @@ def open_url(url, data=None, headers=None, method=None, use_proxy=True,
...
@@ -554,6 +556,7 @@ def open_url(url, data=None, headers=None, method=None, use_proxy=True,
if
parsed
[
0
]
!=
'ftp'
:
if
parsed
[
0
]
!=
'ftp'
:
username
=
url_username
username
=
url_username
force_basic_auth
=
module
.
params
.
get
(
'force_basic_auth'
,
False
)
if
username
:
if
username
:
password
=
url_password
password
=
url_password
...
@@ -572,7 +575,7 @@ def open_url(url, data=None, headers=None, method=None, use_proxy=True,
...
@@ -572,7 +575,7 @@ def open_url(url, data=None, headers=None, method=None, use_proxy=True,
# reconstruct url without credentials
# reconstruct url without credentials
url
=
urlparse
.
urlunparse
(
parsed
)
url
=
urlparse
.
urlunparse
(
parsed
)
if
username
:
if
username
and
not
force_basic_auth
:
passman
=
urllib2
.
HTTPPasswordMgrWithDefaultRealm
()
passman
=
urllib2
.
HTTPPasswordMgrWithDefaultRealm
()
# this creates a password manager
# this creates a password manager
...
@@ -586,6 +589,12 @@ def open_url(url, data=None, headers=None, method=None, use_proxy=True,
...
@@ -586,6 +589,12 @@ def open_url(url, data=None, headers=None, method=None, use_proxy=True,
# create the AuthHandler
# create the AuthHandler
handlers
.
append
(
authhandler
)
handlers
.
append
(
authhandler
)
elif
username
and
force_basic_auth
:
if
headers
is
None
:
headers
=
{}
headers
[
"Authorization"
]
=
"Basic {0}"
.
format
(
base64
.
b64encode
(
"{0}:{1}"
.
format
(
username
,
password
)))
if
not
use_proxy
:
if
not
use_proxy
:
proxyhandler
=
urllib2
.
ProxyHandler
({})
proxyhandler
=
urllib2
.
ProxyHandler
({})
handlers
.
append
(
proxyhandler
)
handlers
.
append
(
proxyhandler
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment