Я использую edx-ironwood.2-6 в Ubuntu 18.08. Я также использую Keycloak 9.0.0. Чтобы включить сторонний вход в систему с помощью Keycloak, я использую библиотеку python -social-auth , предложенную в документации edx . Так как по умолчанию keycloak.py не был доступен в edx-ironwood, я скопировал этот файл keycloak. js в папку
edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/backends
Выполнил все шаги, написанные в комментариях, для настройки keycloak и добавил следующую информацию в keycloak.py
SECRET = 'client secret'
PUBLIC_KEY = 'publick key from keycloak'
AUTHORIZATION_URL = 'http://localhost:8080/auth/realms/myrealm/protocol/openid-connect/auth'
ACCESS_TOKEN_URL = 'http://localhost:8080/auth/realms/myrealm/protocol/openid-connect/token'
USER_DETAILS_URL = 'http://localhost:8080/auth/realms/myrealm/protocol/openid-connect/userinfo'
Добавлена следующая строка в lms.env. json
"THIRD_PARTY_AUTH_BACKENDS":[
"social_core.backends.keycloak.KeycloakOAuth2",
"social_core.backends.google.GoogleOAuth2",
"social_core.backends.linkedin.LinkedinOAuth2"
]
В приложении Django Admin добавлен провайдер
Name: Keycloak
slug: keycloak
site: localhost:81
backend: keycloak
client Id: 'mooc'
Client Secret: 'secret key'
Также добавлен секрет клиента в lms.auth. json
"SOCIAL_AUTH_OAUTH_SECRETS": {
"keycloak":"14f89ef1-02ff-48ad-825f-8160e515ec8e"
}
В настройках клиента Keycloak добавлен тип доступа 'конфиденциальный' и перенаправление uri 'http://localhost: 81 / auth / complete / keycloak / '
После перезапуска сервера, на странице входа edx, появляется кнопка входа для keycloak, но когда я нажимаю на нее в браузере, появляется сообщение Произошло Ошибка 500 на Open Edx Server
В файле журнала apache2 появляется следующая ошибка
[Sat Apr 18 17:09:21.212377 2020] [:error] [pid 8143] Traceback (most recent call last):
[Sat Apr 18 17:09:21.212419 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
[Sat Apr 18 17:09:21.212442 2020] [:error] [pid 8143] response = get_response(request)
[Sat Apr 18 17:09:21.212462 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
[Sat Apr 18 17:09:21.212485 2020] [:error] [pid 8143] response = self._get_response(request)
[Sat Apr 18 17:09:21.212506 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
[Sat Apr 18 17:09:21.212526 2020] [:error] [pid 8143] response = self.process_exception_by_middleware(e, request)
[Sat Apr 18 17:09:21.212548 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
[Sat Apr 18 17:09:21.212569 2020] [:error] [pid 8143] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Sat Apr 18 17:09:21.212589 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/utils/decorators.py", line 185, in inner
[Sat Apr 18 17:09:21.212610 2020] [:error] [pid 8143] return func(*args, **kwargs)
[Sat Apr 18 17:09:21.212630 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
[Sat Apr 18 17:09:21.212651 2020] [:error] [pid 8143] response = view_func(request, *args, **kwargs)
[Sat Apr 18 17:09:21.212671 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_django/utils.py", line 49, in wrapper
[Sat Apr 18 17:09:21.212697 2020] [:error] [pid 8143] return func(request, backend, *args, **kwargs)
[Sat Apr 18 17:09:21.212720 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_django/views.py", line 23, in auth
[Sat Apr 18 17:09:21.212742 2020] [:error] [pid 8143] return do_auth(request.backend, redirect_name=REDIRECT_FIELD_NAME)
[Sat Apr 18 17:09:21.212762 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/actions.py", line 29, in do_auth
[Sat Apr 18 17:09:21.212783 2020] [:error] [pid 8143] return backend.start()
[Sat Apr 18 17:09:21.212803 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/backends/base.py", line 35, in start
[Sat Apr 18 17:09:21.212823 2020] [:error] [pid 8143] return self.strategy.redirect(self.auth_url())
[Sat Apr 18 17:09:21.212844 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_django/strategy.py", line 88, in redirect
[Sat Apr 18 17:09:21.212864 2020] [:error] [pid 8143] return redirect(url)
[Sat Apr 18 17:09:21.212884 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/shortcuts.py", line 56, in redirect
[Sat Apr 18 17:09:21.212904 2020] [:error] [pid 8143] return redirect_class(resolve_url(to, *args, **kwargs))
[Sat Apr 18 17:09:21.212925 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/shortcuts.py", line 147, in resolve_url
[Sat Apr 18 17:09:21.212945 2020] [:error] [pid 8143] return reverse(to, args=args, kwargs=kwargs)
[Sat Apr 18 17:09:21.212965 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/src/django-wiki/wiki/models/__init__.py", line 90, in reverse
[Sat Apr 18 17:09:21.212986 2020] [:error] [pid 8143] url = original_django_reverse(*args, **kwargs)
[Sat Apr 18 17:09:21.213006 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/urls/base.py", line 91, in reverse
[Sat Apr 18 17:09:21.213026 2020] [:error] [pid 8143] return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
[Sat Apr 18 17:09:21.213047 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/urls/resolvers.py", line 497, in _reverse_with_prefix
[Sat Apr 18 17:09:21.213067 2020] [:error] [pid 8143] raise NoReverseMatch(msg)
[Sat Apr 18 17:09:21.213089 2020] [:error] [pid 8143] NoReverseMatch: Reverse for 'None?scope=profile+email&state=yst8UI8KZihrluHg9R0oUFexFIx0QYGM&redirect_uri=http%3A%2F%2Flocalhost%3A81%2Fauth%2Fcomplete%2Fkeycloak%2F%3Fredirect_state%3Dyst8UI8KZihrluHg9R0oUFexFIx0QYGM&response_type=code&client_id=mooc' not found. 'None?scope=profile+email&state=yst8UI8KZihrluHg9R0oUFexFIx0QYGM&redirect_uri=http%3A%2F%2Flocalhost%3A81%2Fauth%2Fcomplete%2Fkeycloak%2F%3Fredirect_state%3Dyst8UI8KZihrluHg9R0oUFexFIx0QYGM&response_type=code&client_id=mooc' is not a valid view function or pattern name.
Я пробовал такую же стороннюю интеграцию с тем же python -social-auth для LinkedIn и это работает.
Так как я просто новичок в Django, может кто-нибудь помочь мне определить проблему по вышеприведенным деталям.