我们有一个正在运行的代理,它为互联网提供 HTTPS 页面。因此,它将请求重定向到我们的 DMZ,其中页面作为 HTTP 页面提供。
我们将 WireCloud 设置为在子域中运行:wirecloud.example.com。Horizon 在 Horizon.example.com 上运行。
在 Horizon 中,回调 URL 设置为:http : //wirecloud.example.com/complete/fiware/ 并在 Wirecloud 的 settings.py 中FIWARE_IDM_SERVER = 'http://horizon.example.com'
设置。
现在,当wirecloud.example.com/login
被调用时,它被我们的代理重定向到 https ,然后被wireclound重定向到horizon ,然后被我们的代理重定向到https://horizon.example.com/oauth2/authorize/?state=STATE_KEY&redirect_uri=http://wirecloud.example.com/complete/fiware/&response_type=code&client_id=CLIENT_ID
. 如果用户未登录并且现在这样做了,则 redirect_uri 将转换为:http%253A%252F%252Fwirecloud.example.com%252Fcomplete%252Ffiware%252F
导致此错误的原因:{"state": "STATE_KEY", "error": "invalid_redirect_uri"} (HTTP 400)
。如果用户已经登录并尝试授权应用程序 (WireCloud),则会引发 405 错误:
Environment:
Request Method: GET
Request URL: http://wirecloud.example.com/complete/fiware/?state=STATE_KEY&code=CODE
Django Version: 1.9.6
Python Version: 2.7.9
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'wirecloud.commons',
'compressor',
'wirecloud.catalogue',
'wirecloud.platform',
'wirecloud.oauth2provider',
'wirecloud.fiware',
'social.apps.django_app.default')
Installed Middleware:
('wirecloud.commons.middleware.URLMiddleware',)
Traceback:
File "/opt/wc/venv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
149. response = self.process_exception_by_middleware(e, request)
File "/opt/wc/venv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
147. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/wc/venv/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/opt/wc/venv/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
58. return view_func(*args, **kwargs)
File "/opt/wc/venv/lib/python2.7/site-packages/social/apps/django_app/utils.py" in wrapper
51. return func(request, backend, *args, **kwargs)
File "/opt/wc/venv/lib/python2.7/site-packages/social/apps/django_app/views.py" in complete
28. redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs)
File "/opt/wc/venv/lib/python2.7/site-packages/social/actions.py" in do_complete
43. user = backend.complete(user=user, *args, **kwargs)
File "/opt/wc/venv/lib/python2.7/site-packages/social/backends/base.py" in complete
41. return self.auth_complete(*args, **kwargs)
File "/opt/wc/venv/lib/python2.7/site-packages/social/utils.py" in wrapper
229. return func(*args, **kwargs)
File "/opt/wc/venv/lib/python2.7/site-packages/social/backends/oauth.py" in auth_complete
383. method=self.ACCESS_TOKEN_METHOD
File "/opt/wc/venv/lib/python2.7/site-packages/social/backends/oauth.py" in request_access_token
361. return self.get_json(*args, **kwargs)
File "/opt/wc/venv/lib/python2.7/site-packages/social/backends/base.py" in get_json
229. return self.request(url, *args, **kwargs).json()
File "/opt/wc/venv/lib/python2.7/site-packages/social/backends/base.py" in request
225. response.raise_for_status()
File "/opt/wc/venv/lib/python2.7/site-packages/requests/models.py" in raise_for_status
844. raise HTTPError(http_error_msg, response=self)
Exception Type: HTTPError at /complete/fiware/
Exception Value: 405 Client Error: METHOD NOT ALLOWED for url: https://horizon.example.com/oauth2/token
那么我们需要如何配置 WireCloud 和/或 Horizon 和/或我们的代理才能使其正常工作呢?