jazzband / django-oauth-toolkit

OAuth2 goodies for the Djangonauts!
https://django-oauth-toolkit.readthedocs.io
Other
3.13k stars 792 forks source link

ValueError in jwks.json #1427

Closed coleedwards closed 4 months ago

coleedwards commented 4 months ago

Hi there, I'm getting a very strange error.

When accessing /o/.well-known/jwks.json I get the following: ValueError at /o/.well-known/jwks.json ('Could not deserialize key data. The data may be in an incorrect format, it may be encrypted with an unsupported algorithm, or it may be an unsupported key type (e.g. EC curves with explicit parameters).', [<OpenSSLError(code=503841036, lib=60, reason=524556, reason_text=unsupported)>])

Traceback: image

My settings.py is:

OAUTH2_PROVIDER = {
    "OIDC_ENABLED": True,
    "OIDC_RSA_PRIVATE_KEY": base64.urlsafe_b64decode(os.environ['OIDC_RSA_PRIVATE_KEY']).decode(),
    "OAUTH2_VALIDATOR_CLASS": "panel.oauth_validators.CustomOAuth2Validator",
    "SCOPES": {
        "openid": "OpenID Connect Scope",
        "profile": "Profile",
        "email": "Email",
        "is_staff": "Staff Status",
        "user_id": "ID",
        "user_name": "Name"
    }
}

My environment variable is stored in base64 and I have confirmed that it is decoding correctly pointing to my private key file.

I have searched around a lot and am unable to find an answer, would you have any ideas?

Thanks

coleedwards commented 4 months ago

Manage to fix through this:

key_file = open("/home/panel/oidc.key", "r")
key_contents = key_file.read()
key_file.close()

OAUTH2_PROVIDER = {
    "OIDC_ENABLED": True,
    "OIDC_RSA_PRIVATE_KEY": key_contents,