Search code examples
pythonauthlib

Python 3.7 Authlib UnsupportedAlgorithmError


I have this issue on Ubuntu 18.04 in the Docker. When I develop this app on macOS there is no such error.

I build image with this Dockerfile: https://pastebin.com/rG32a0dv

requirements.txt:

Flask==1.0.2
uWSGI==2.0.17.1
Authlib==0.10
cryptography==2.3.1

Usage in code:

header = {'alg': 'RS256'}
payload = {'login': login}

auth_token = jwt.encode(header, payload, private_key)

and

try:
    claims = jwt.decode(auth_token, public_key)
except BadSignatureError:
    return False

Whole the Flask app: https://pastebin.com/9vVJQL1w

And I have the error:

authlib.specs.rfc7515.errors.UnsupportedAlgorithmError: unsupported_algorithm:

Details: https://pastebin.com/MjFRce1F

Why this error appears? What can I do to fix it?


Solution

  • cryptography has no manylinux wheels for CPython 3.7. In this case, you need to build cryptography on linux yourself. Follow the documentation:

    https://cryptography.io/en/latest/installation/#building-cryptography-on-linux

    You can try import some cryptography modules to verify:

    from cryptography.hazmat.primitives import hashes
    from cryptography.hazmat.primitives.asymmetric.utils import (
        decode_dss_signature, encode_dss_signature
    )
    from cryptography.hazmat.primitives.asymmetric.ec import ECDSA
    from cryptography.hazmat.primitives.asymmetric import padding
    

    via https://github.com/lepture/authlib/blob/v0.10/authlib/specs/rfc7518/_backends/_jws_cryptography.py