Python 3.7 Authlib UnsupportedAlgorithmError

标签 python authlib

我在 Docker 中的 Ubuntu 18.04 上遇到了这个问题。当我在 macOS 上开发这个应用程序时,没有这样的错误。

我用这个 Dockerfile 构建镜像:https://pastebin.com/rG32a0dv

要求.txt:

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

代码中的用法:

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

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

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

整个 Flask 应用:https://pastebin.com/9vVJQL1w

我有错误:

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

详情:https://pastebin.com/MjFRce1F

为什么会出现这个错误?我该怎么做才能修复它?

最佳答案

密码学没有用于 CPython 3.7 的 manylinux 轮子。在这种情况下,您需要自己在 linux 上构建密码学。遵循文档:

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

您可以尝试导入一些密码学模块来验证:

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

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

关于Python 3.7 Authlib UnsupportedAlgorithmError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53029595/

相关文章:

python - 使用Python自动处理dymola模拟结果

python - 我应该使用 Pylons 还是 Pyramid?

生产中的 Flask-oauthlib 或 authlib?

python - 如何使用 Authlib 和 Gspread 刷新身份验证 token ?

python - Authlib token 未保存在数据库中

python - PySpark:如何判断数据框的列类型

python - 获得范围内频率平均值的最快方法

Python - 根据两列组合删除数据框中的重复项?

python - 带有自签名证书的 Authlib SSLError