From fa7876bb406cbba9a4cd937a0e8c6d8ada3e5e24 Mon Sep 17 00:00:00 2001 From: Dominik <47948163+weristdominik@users.noreply.github.com> Date: Sun, 16 Feb 2025 21:24:46 +0100 Subject: [PATCH] Jira: add SSL client certificate support for authentication (#9753) * jira: add ssl client certificate support for authentification * fix code bugs from first CI run * fix fstring not compatible with older python and chhange urlopen module call * removed duplicated post,put,get method * fix urllib module detection Python2/ Python3 * edit HTTP Request back to fetch_url * add changelog fragment * fix python line spacing * Update plugins/modules/jira.py Co-authored-by: Felix Fontein * Update plugins/modules/jira.py Co-authored-by: Felix Fontein * edit documentation certificate auth not mutually exclusive * Update changelogs/fragments/9753-jira-add-client-certificate-auth.yml Co-authored-by: Felix Fontein * edit documentation for client certificate auth and token * add no_log for client_cert and client_key * removed no_log for client_cert and client_key --------- Co-authored-by: domin Co-authored-by: Felix Fontein --- .../9753-jira-add-client-certificate-auth.yml | 2 ++ plugins/modules/jira.py | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 changelogs/fragments/9753-jira-add-client-certificate-auth.yml diff --git a/changelogs/fragments/9753-jira-add-client-certificate-auth.yml b/changelogs/fragments/9753-jira-add-client-certificate-auth.yml new file mode 100644 index 0000000000..8eeb5d01d7 --- /dev/null +++ b/changelogs/fragments/9753-jira-add-client-certificate-auth.yml @@ -0,0 +1,2 @@ +minor_changes: + - jira - adds ``client_cert`` and ``client_key`` parameters for supporting client certificate authentification when connecting to Jira (https://github.com/ansible-collections/community.general/pull/9753). \ No newline at end of file diff --git a/plugins/modules/jira.py b/plugins/modules/jira.py index dcedc47928..93d988e38b 100644 --- a/plugins/modules/jira.py +++ b/plugins/modules/jira.py @@ -59,6 +59,18 @@ options: - The personal access token to log-in with. - Mutually exclusive with O(username) and O(password). version_added: 4.2.0 + client_cert: + type: path + description: + - Client certificate if required. + - In addition to O(username) and O(password) or O(token). Not mutually exclusive. + version_added: 10.4.0 + client_key: + type: path + description: + - Client certificate key if required. + - In addition to O(username) and O(password) or O(token). Not mutually exclusive. + version_added: 10.4.0 project: type: str @@ -446,6 +458,23 @@ EXAMPLES = r""" operation: attach attachment: filename: topsecretreport.xlsx + +# Use username, password and client certificate authentification +- name: Create an issue + community.general.jira: + uri: '{{ server }}' + username: '{{ user }}' + password: '{{ pass }}' + client_cert: '{{ path/to/client-cert }}' + client_key: '{{ path/to/client-key }}' + +# Use token and client certificate authentification +- name: Create an issue + community.general.jira: + uri: '{{ server }}' + token: '{{ token }}' + client_cert: '{{ path/to/client-cert }}' + client_key: '{{ path/to/client-key }}' """ import base64 @@ -480,6 +509,8 @@ class JIRA(StateModuleHelper): username=dict(type='str'), password=dict(type='str', no_log=True), token=dict(type='str', no_log=True), + client_cert=dict(type='path'), + client_key=dict(type='path'), project=dict(type='str', ), summary=dict(type='str', ), description=dict(type='str', ), @@ -511,6 +542,7 @@ class JIRA(StateModuleHelper): ], required_together=[ ['username', 'password'], + ['client_cert', 'client_key'] ], required_one_of=[ ['username', 'token'],