diff --git a/readthedocs/api/v3/proxied_urls.py b/readthedocs/api/v3/proxied_urls.py new file mode 100644 index 00000000000..e63d3af72fc --- /dev/null +++ b/readthedocs/api/v3/proxied_urls.py @@ -0,0 +1,16 @@ +""" +Proxied API URLs. + +Served from the same domain docs are served, +so they can make use of features that require to have access to their cookies. +""" + +from django.conf.urls import url + +from readthedocs.api.v3.proxied_views import ProxiedEmbedAPI + +api_proxied_urls = [ + url(r'embed/', ProxiedEmbedAPI.as_view(), name='embed_api_v3'), +] + +urlpatterns = api_proxied_urls diff --git a/readthedocs/api/v3/proxied_views.py b/readthedocs/api/v3/proxied_views.py new file mode 100644 index 00000000000..46bb55ab59a --- /dev/null +++ b/readthedocs/api/v3/proxied_views.py @@ -0,0 +1,14 @@ +from readthedocs.core.utils.extend import SettingsOverrideObject +from readthedocs.embed.v3.views import EmbedAPIBase + + +class ProxiedEmbedAPIBase(EmbedAPIBase): + + # DRF has BasicAuthentication and SessionAuthentication as default classes. + # We don't support neither in the community site. + authentication_classes = [] + + +class ProxiedEmbedAPI(SettingsOverrideObject): + + _default_class = ProxiedEmbedAPIBase diff --git a/readthedocs/proxito/urls.py b/readthedocs/proxito/urls.py index 906813d1387..4e209e1cc8f 100644 --- a/readthedocs/proxito/urls.py +++ b/readthedocs/proxito/urls.py @@ -97,6 +97,14 @@ ), include('readthedocs.api.v2.proxied_urls'), ), + + # /_/api/v3/ + url( + r'^{DOC_PATH_PREFIX}api/v3/'.format( + DOC_PATH_PREFIX=DOC_PATH_PREFIX, + ), + include('readthedocs.api.v3.proxied_urls'), + ), ] core_urls = [