Skip to content

Commit

Permalink
Allow the user to override the default signature method
Browse files Browse the repository at this point in the history
PR pycontribs#1643 changed the default signature_method from SIGNATURE_RSA to SIGNATURE_HMAC_SHA1. This was done to keep compatibility with RHEL.

The problem is that some Jira servers don't accept SIGNATURE_HMAC_SHA1 and there's currently no way for the user to choose which method to use.

This PR adds a new, optional, field that can be passed to the oauth parameter and allows the user to choose which signature_method they want.
  • Loading branch information
Governa authored Jun 1, 2023
1 parent 0a804f7 commit fb580f0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ def __init__(
* access_token_secret -- OAuth access token secret to sign with the key
* consumer_key -- key of the OAuth application link defined in Jira
* key_cert -- private key file to sign requests with (should be the pair of the public key supplied to Jira in the OAuth application link)
* signature_method (Optional) -- The signature method to use with OAuth. Defaults to oauthlib.oauth1.SIGNATURE_HMAC_SHA1
kerberos (bool): True to enable Kerberos authentication. (Default: ``False``)
kerberos_options (Optional[Dict[str,str]]): A dict of properties for Kerberos authentication.
Expand Down Expand Up @@ -3694,7 +3695,7 @@ def _create_oauth_session(self, oauth: dict[str, Any]):
oauth_instance = OAuth1(
oauth["consumer_key"],
rsa_key=oauth["key_cert"],
signature_method=SIGNATURE_HMAC_SHA1,
signature_method=oauth.get("signature_method", SIGNATURE_HMAC_SHA1),
resource_owner_key=oauth["access_token"],
resource_owner_secret=oauth["access_token_secret"],
)
Expand Down

0 comments on commit fb580f0

Please sign in to comment.