Bkprt py3 jira (#37800)
* make jira authentication Python3 compatible (#33862)
* make jira authentication Python3 compatible
(cherry picked from commit a51a699314
)
* Add changelog fragment for py3 jira fix
This commit is contained in:
parent
8d008d00ed
commit
64cdeba7a2
2 changed files with 6 additions and 1 deletions
3
changelogs/fragments/py3-jira.yaml
Normal file
3
changelogs/fragments/py3-jira.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
bugfixes:
|
||||
- jira module - Fix bytes/text handling for base64 encoding authentication tokens
|
||||
https://github.com/ansible/ansible/pull/33862
|
|
@ -233,6 +233,7 @@ EXAMPLES = """
|
|||
import base64
|
||||
import json
|
||||
import sys
|
||||
from ansible.module_utils._text import to_text, to_bytes
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
|
@ -249,7 +250,8 @@ def request(url, user, passwd, timeout, data=None, method=None):
|
|||
# resulting in unexpected results. To work around this we manually
|
||||
# inject the basic-auth header up-front to ensure that JIRA treats
|
||||
# the requests as authorized for this user.
|
||||
auth = base64.encodestring('%s:%s' % (user, passwd)).replace('\n', '')
|
||||
auth = to_text(base64.b64encode(to_bytes('{0}:{1}'.format(user, passwd), errors='surrogate_or_strict')))
|
||||
|
||||
response, info = fetch_url(module, url, data=data, method=method, timeout=timeout,
|
||||
headers={'Content-Type': 'application/json',
|
||||
'Authorization': "Basic %s" % auth})
|
||||
|
|
Loading…
Reference in a new issue