Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to pure-python RSA failing (when Cryptography is not available) #1192

Open
JavaWiz1 opened this issue Nov 24, 2022 · 0 comments
Open

Comments

@JavaWiz1
Copy link

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

  • OS: Windows 11
  • Python version: 3.8
  • pip version: n/a
  • google-auth version: 2.14.1

Steps to reproduce

  1. Running in Kodi, no Cryptography package available

Fails on import of rsa module (see stacktrace below)

=======================
I believe there are 2 fixes necessary:

  1. google.auth.crypt.rsa.py - modify except statement to include ModuleNotFoundError
    from:
try: 
    # Prefer cryptograph-based RSA implementation.
    from google.auth.crypt import _cryptography_rsa

    RSASigner = _cryptography_rsa.RSASigner
    RSAVerifier = _cryptography_rsa.RSAVerifier
except ImportError:  # praga: NO COVER
    # Fallback to pure-python RSA implementation if cryptography is
...

to

try: 
    # Prefer cryptograph-based RSA implementation.
    from google.auth.crypt import _cryptography_rsa

    RSASigner = _cryptography_rsa.RSASigner
    RSAVerifier = _cryptography_rsa.RSAVerifier
except (ImportError, ModuleNotFoundError):  # praga: NO COVER
    # Fallback to pure-python RSA implementation if cryptography is
...
  1. in google.auth.crypt._python_rsa.py, fully qualify import for rsa module

from

import rsa  # type: ignore

to

import google.auth.crypt.rsa  # type: ignore

Stack Trace: of issue:

Error Type: <class 'ModuleNotFoundError'>
Error Contents: No module named 'rsa'
Traceback (most recent call last):
 File "C:\Users\a_dam\AppData\Roaming\Kodi\addons\script.module.google-auth-library\lib\google\auth\crypt\rsa.py", line 20, in <module>
   from google.auth.crypt import _cryptography_rsa
 File "C:\Users\a_dam\AppData\Roaming\Kodi\addons\script.module.google-auth-library\lib\google\auth\crypt\_cryptography_rsa.py", line 22, in <module>
   import cryptography.exceptions
ModuleNotFoundError: No module named 'cryptography'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "C:\Users\a_dam\AppData\Roaming\Kodi\addons\plugin.video.arloview\default.py", line 8, in <module>
   from resources.lib import arlo_stream
 File "C:\Users\a_dam\AppData\Roaming\Kodi\addons\plugin.video.arloview\resources\lib\arlo_stream.py", line 10, in <module>
   import arlo
 File "C:\Users\a_dam\AppData\Roaming\Kodi\addons\script.module.arlo\lib\arlo.py", line 48, in <module>
   from google_auth_oauthlib.flow import InstalledAppFlow
 File "C:\Users\a_dam\AppData\Roaming\Kodi\addons\script.module.google-auth-oauthlib\lib\google_auth_oauthlib\__init__.py", line 21, in <module>
   from .interactive import get_user_credentials
 File "C:\Users\a_dam\AppData\Roaming\Kodi\addons\script.module.google-auth-oauthlib\lib\google_auth_oauthlib\interactive.py", line 27, in <module>
   import google_auth_oauthlib.flow
 File "C:\Users\a_dam\AppData\Roaming\Kodi\addons\script.module.google-auth-oauthlib\lib\google_auth_oauthlib\flow.py", line 66, in <module>
   import google.auth.transport.requests
 File "C:\Users\a_dam\AppData\Roaming\Kodi\addons\script.module.google-auth-library\lib\google\auth\transport\requests.py", line 48, in <module>
   from google.oauth2 import service_account
 File "C:\Users\a_dam\AppData\Roaming\Kodi\addons\script.module.google-auth-library\lib\google\oauth2\service_account.py", line 77, in <module>
   from google.auth import _service_account_info
 File "C:\Users\a_dam\AppData\Roaming\Kodi\addons\script.module.google-auth-library\lib\google\auth\_service_account_info.py", line 22, in <module>
   from google.auth import crypt
 File "C:\Users\a_dam\AppData\Roaming\Kodi\addons\script.module.google-auth-library\lib\google\auth\crypt\__init__.py", line 43, in <module>
   from google.auth.crypt import rsa
 File "C:\Users\a_dam\AppData\Roaming\Kodi\addons\script.module.google-auth-library\lib\google\auth\crypt\rsa.py", line 27, in <module>
   from google.auth.crypt import _python_rsa
 File "C:\Users\a_dam\AppData\Roaming\Kodi\addons\script.module.google-auth-library\lib\google\auth\crypt\_python_rsa.py", line 28, in <module>
   import rsa  # type: ignore
ModuleNotFoundError: No module named 'rsa'

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant