Skip to content

Commit

Permalink
fixing PyOpenSSL dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
karen-avetisyan-mc committed Feb 21, 2024
1 parent c75d709 commit 06405a9
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 20 deletions.
3 changes: 1 addition & 2 deletions oauth1/authenticationutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
# SUCH DAMAGE.
#

from cryptography.hazmat.primitives.serialization import pkcs12
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.serialization import pkcs12


def load_signing_key(pkcs12_filename, password):
Expand Down
5 changes: 2 additions & 3 deletions oauth1/coreutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
"""
Utility file having common functions
"""
import hashlib
import base64
import urllib
import hashlib
import time
import urllib
from random import SystemRandom

from urllib.parse import urlparse, parse_qsl


Expand Down
11 changes: 6 additions & 5 deletions oauth1/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
# SUCH DAMAGE.
#
import json
import oauth1.coreutils as util
from OpenSSL import crypto

from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding

import oauth1.coreutils as util


class OAuth:
EMPTY_STRING = ""
Expand Down Expand Up @@ -87,9 +88,9 @@ def get_base_string(url, method, oauth_parameters):
def sign_message(message, signing_key):
# Signs the message using the private signing key
signature = signing_key.sign(message.encode("utf-8"),
padding.PKCS1v15(),
hashes.SHA256())
padding.PKCS1v15(),
hashes.SHA256())

return util.base64_encode(signature)


Expand Down
3 changes: 1 addition & 2 deletions oauth1/oauth_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
from OpenSSL.crypto import PKey
from requests import PreparedRequest
from requests.auth import AuthBase

Expand All @@ -44,7 +43,7 @@ class OAuth1RSA(AuthBase):
>>> requests.post('https://endpoint.com/the/route', data={'foo': 'bar'}, auth=oauth)
"""

def __init__(self, consumer_key: str, signing_key: PKey):
def __init__(self, consumer_key: str, signing_key: bytes):
self.consumer_key = consumer_key
self.signing_key = signing_key

Expand Down
6 changes: 4 additions & 2 deletions oauth1/signer_interceptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
# SUCH DAMAGE.
#
from functools import wraps
from oauth1.oauth import OAuth
from oauth1 import authenticationutils
from urllib.parse import urlencode

from deprecated import deprecated

from oauth1 import authenticationutils
from oauth1.oauth import OAuth


class SignerInterceptor(object):

Expand Down
2 changes: 1 addition & 1 deletion oauth1/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = '1.8.0'
__version__ = '1.9.0'
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
requests==2.27.1
Deprecated==1.2.5
cryptography>=42.0.0
pyOpenSSL>=23.3.0
cryptography>=42.0.0
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2019-2021 Mastercard
# Copyright 2019-2024 Mastercard
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
Expand Down Expand Up @@ -46,5 +46,5 @@
'Topic :: Software Development :: Libraries :: Python Modules'
],
tests_require=['coverage'],
install_requires=['requests','pyOpenSSL>=22.1.0,<=23.2.0','urllib3', 'Deprecated']
install_requires=['requests','cryptography>=42.0.0','urllib3', 'Deprecated']
)
1 change: 0 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#
import unittest
import oauth1.authenticationutils as authenticationutils
from OpenSSL import crypto
from cryptography.hazmat.primitives import serialization


Expand Down

0 comments on commit 06405a9

Please sign in to comment.