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

[Bug] joserfc.errors.InvalidKeyTypeError: invalid_key_type: Algorithm "RS256" requires "RSA" key #981

Closed
MoSattler opened this issue Jul 6, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@MoSattler
Copy link

MoSattler commented Jul 6, 2024

RomM version
3.2.0 in docker (unraid)

Describe the bug
Romm crashes

[2024-07-06 11:15:43 -0700] [24] [ERROR] Exception in ASGI application
Traceback (most recent call last):
  File "/backend/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/backend/lib/python3.11/site-packages/starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/backend/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/backend/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/backend/handler/auth/middleware.py", line 137, in __call__
    await self.app(scope, receive, send_wrapper)
  File "/backend/lib/python3.11/site-packages/starlette/middleware/authentication.py", line 36, in __call__
    auth_result = await self.backend.authenticate(conn)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/handler/auth/hybrid_auth.py", line 41, in authenticate
    ) = await oauth_handler.get_current_active_user_from_bearer_token(token)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/handler/auth/base_handler.py", line 137, in get_current_active_user_from_bearer_token
    payload = jwt.decode(token, ROMM_AUTH_SECRET_KEY)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/lib/python3.11/site-packages/joserfc/jwt.py", line 97, in decode
    header, payload = _decode_jws(_value, key, algorithms, registry)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/lib/python3.11/site-packages/joserfc/jwt.py", line 128, in _decode_jws
    jws_obj = deserialize_compact(value, key, algorithms, registry)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/lib/python3.11/site-packages/joserfc/jws.py", line 171, in deserialize_compact
    if not validate_compact(obj, public_key, algorithms, registry):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/lib/python3.11/site-packages/joserfc/jws.py", line 142, in validate_compact
    alg.check_key_type(key)
  File "/backend/lib/python3.11/site-packages/joserfc/rfc7515/model.py", line 99, in check_key_type
    raise InvalidKeyTypeError(f'Algorithm "{self.name}" requires "{self.key_type}" key')
joserfc.errors.InvalidKeyTypeError: invalid_key_type: Algorithm "RS256" requires "RSA" key
[2024-07-06 11:15:46 -0700] [24] [ERROR] Exception in ASGI application
Traceback (most recent call last):
  File "/backend/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/backend/lib/python3.11/site-packages/starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/backend/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/backend/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/backend/handler/auth/middleware.py", line 137, in __call__
    await self.app(scope, receive, send_wrapper)
  File "/backend/lib/python3.11/site-packages/starlette/middleware/authentication.py", line 36, in __call__
    auth_result = await self.backend.authenticate(conn)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/handler/auth/hybrid_auth.py", line 41, in authenticate
    ) = await oauth_handler.get_current_active_user_from_bearer_token(token)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/handler/auth/base_handler.py", line 137, in get_current_active_user_from_bearer_token
    payload = jwt.decode(token, ROMM_AUTH_SECRET_KEY)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/lib/python3.11/site-packages/joserfc/jwt.py", line 97, in decode
    header, payload = _decode_jws(_value, key, algorithms, registry)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/lib/python3.11/site-packages/joserfc/jwt.py", line 128, in _decode_jws
    jws_obj = deserialize_compact(value, key, algorithms, registry)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/lib/python3.11/site-packages/joserfc/jws.py", line 171, in deserialize_compact
    if not validate_compact(obj, public_key, algorithms, registry):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/backend/lib/python3.11/site-packages/joserfc/jws.py", line 142, in validate_compact
    alg.check_key_type(key)
  File "/backend/lib/python3.11/site-packages/joserfc/rfc7515/model.py", line 99, in check_key_type
    raise InvalidKeyTypeError(f'Algorithm "{self.name}" requires "{self.key_type}" key')
joserfc.errors.InvalidKeyTypeError: invalid_key_type: Algorithm "RS256" requires "RSA" key

To Reproduce
It happens anytime when I open the web ui in Chrome. Safari works fine.

@MoSattler MoSattler added the bug Something isn't working label Jul 6, 2024
@gantoine
Copy link
Member

gantoine commented Jul 8, 2024

Can you check that ROMM_AUTH_SECRET_KEY is set correctly in your .env file/environment variables?

@gantoine gantoine self-assigned this Jul 8, 2024
@MoSattler
Copy link
Author

It wasn't. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants