Mozilla-django-oidc не аутентифицирует пользователей

Я использую mozilla-django-oidc для аутентификации пользователей keycloak, но это не работает. это settings.py:

AUTHENTICATION_BACKENDS = (
    'mozilla_django_oidc.auth.OIDCAuthenticationBackend',
)
OIDC_RP_CLIENT_ID = 'HoubanCrm'
OIDC_RP_CLIENT_SECRET = '7n9Kw7FgVYEkr1NKUDUA9KDBlMBiFjMS'

OIDC_OP_AUTHORIZATION_ENDPOINT = 'http://localhost:8080/realms/HoubanCrm/protocol/openid-connect/auth'
OIDC_OP_TOKEN_ENDPOINT = 'http://localhost:8080/realms/HoubanCrm/protocol/openid-connect/token'
OIDC_OP_USER_ENDPOINT = 'http://localhost:8080/realms/HoubanCrm/protocol/openid-connect/userinfo'

и когда я хочу войти в систему, он правильно перенаправляет на keycloak, но я получаю эту ошибку, когда я пытаюсь войти в систему:

JWS token verification failed.
Traceback (most recent call last):
  File "/home/gmtii/PycharmProjects/djangoProject6/.venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/gmtii/PycharmProjects/djangoProject6/.venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/gmtii/PycharmProjects/djangoProject6/.venv/lib/python3.10/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/gmtii/PycharmProjects/djangoProject6/.venv/lib/python3.10/site-packages/django/views/generic/base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/gmtii/PycharmProjects/djangoProject6/.venv/lib/python3.10/site-packages/mozilla_django_oidc/views.py", line 124, in get
    self.user = auth.authenticate(**kwargs)
  File "/home/gmtii/PycharmProjects/djangoProject6/.venv/lib/python3.10/site-packages/django/views/decorators/debug.py", line 73, in sensitive_variables_wrapper
    return func(*func_args, **func_kwargs)
  File "/home/gmtii/PycharmProjects/djangoProject6/.venv/lib/python3.10/site-packages/django/contrib/auth/__init__.py", line 79, in authenticate
    user = backend.authenticate(request, **credentials)
  File "/home/gmtii/PycharmProjects/djangoProject6/.venv/lib/python3.10/site-packages/mozilla_django_oidc/auth.py", line 324, in authenticate
    payload = self.verify_token(id_token, nonce=nonce)
  File "/home/gmtii/PycharmProjects/djangoProject6/.venv/lib/python3.10/site-packages/mozilla_django_oidc/auth.py", line 218, in verify_token
    payload_data = self.get_payload_data(token, key)
  File "/home/gmtii/PycharmProjects/djangoProject6/.venv/lib/python3.10/site-packages/mozilla_django_oidc/auth.py", line 201, in get_payload_data
    return self._verify_jws(token, key)
  File "/home/gmtii/PycharmProjects/djangoProject6/.venv/lib/python3.10/site-packages/mozilla_django_oidc/auth.py", line 157, in _verify_jws
    raise SuspiciousOperation(msg)
django.core.exceptions.SuspiciousOperation: JWS token verification failed.
Bad Request: /oidc/callback/
[01/Feb/2024 06:48:28] "GET /oidc/callback/?state=R3r6Dg2XcLCWUIVlEUOOkqra0aU1Ta7t&session_state=068dc2c3-1b4f-447f-b31f-56f14a3adb5c&iss=http%3A%2F%2Flocalhost%3A8080%2Frealms%2FHoubanCrm&code=d65bdaef-0c4b-4231-a341-217e51966c7a.068dc2c3-1b4f-447f-b31f-56f14a3adb5c.e38b37dd-6828-4bb9-a457-babc25eb4e01 HTTP/1.1" 400 126592

Я распечатал токен jws, кажется, все в порядке

Вернуться на верх