Skip to content

Commit

Permalink
Switch from SIGNATURE_RSA to SIGNATURE_HMAC_SHA1 (pycontribs#1643)
Browse files Browse the repository at this point in the history
Switch from SIGNATURE_RSA to SIGNATURE_RSA_HMAC_SHA1

RHEL 9 has a policy of deprecating SHA1 and has removed it from
python-oauthlib via the addition of locally added patch.

Switching to SIGNATURE_RSA_HMAC_SHA1 allows this module to be used
on RHEL9 when the system package python3-oauthlib-3.1.1-2.el9.noarch.rpm
is used.
  • Loading branch information
traylenator authored May 15, 2023
1 parent 2e15c82 commit 3550edd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3702,13 +3702,13 @@ def _create_http_basic_session(
def _create_oauth_session(
self, oauth, timeout: float | int | tuple[float, float] | None
):
from oauthlib.oauth1 import SIGNATURE_RSA
from oauthlib.oauth1 import SIGNATURE_HMAC_SHA1
from requests_oauthlib import OAuth1

oauth_instance = OAuth1(
oauth["consumer_key"],
rsa_key=oauth["key_cert"],
signature_method=SIGNATURE_RSA,
signature_method=SIGNATURE_HMAC_SHA1,
resource_owner_key=oauth["access_token"],
resource_owner_secret=oauth["access_token_secret"],
)
Expand Down
8 changes: 5 additions & 3 deletions jira/jirashell.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import keyring
import requests
from oauthlib.oauth1 import SIGNATURE_RSA
from oauthlib.oauth1 import SIGNATURE_HMAC_SHA1
from requests_oauthlib import OAuth1

from jira import JIRA, __version__
Expand All @@ -29,7 +29,9 @@ def oauth_dance(server, consumer_key, key_cert_data, print_tokens=False, verify=
verify = server.startswith("https")

# step 1: get request tokens
oauth = OAuth1(consumer_key, signature_method=SIGNATURE_RSA, rsa_key=key_cert_data)
oauth = OAuth1(
consumer_key, signature_method=SIGNATURE_HMAC_SHA1, rsa_key=key_cert_data
)
r = requests.post(
server + "/plugins/servlet/oauth/request-token", verify=verify, auth=oauth
)
Expand Down Expand Up @@ -71,7 +73,7 @@ def oauth_dance(server, consumer_key, key_cert_data, print_tokens=False, verify=
# step 3: get access tokens for validated user
oauth = OAuth1(
consumer_key,
signature_method=SIGNATURE_RSA,
signature_method=SIGNATURE_HMAC_SHA1,
rsa_key=key_cert_data,
resource_owner_key=request_token,
resource_owner_secret=request_token_secret,
Expand Down

0 comments on commit 3550edd

Please sign in to comment.