Skip to content

Commit 9d2d1a2

Browse files
authored
Merge pull request #8540 from readthedocs/humitos/proxy-embed-v3-urls
2 parents 9575a28 + d1edf51 commit 9d2d1a2

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

readthedocs/api/v3/proxied_urls.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Proxied API URLs.
3+
4+
Served from the same domain docs are served,
5+
so they can make use of features that require to have access to their cookies.
6+
"""
7+
8+
from django.conf.urls import url
9+
10+
from readthedocs.api.v3.proxied_views import ProxiedEmbedAPI
11+
12+
api_proxied_urls = [
13+
url(r'embed/', ProxiedEmbedAPI.as_view(), name='embed_api_v3'),
14+
]
15+
16+
urlpatterns = api_proxied_urls

readthedocs/api/v3/proxied_views.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from readthedocs.core.utils.extend import SettingsOverrideObject
2+
from readthedocs.embed.v3.views import EmbedAPIBase
3+
4+
5+
class ProxiedEmbedAPIBase(EmbedAPIBase):
6+
7+
# DRF has BasicAuthentication and SessionAuthentication as default classes.
8+
# We don't support neither in the community site.
9+
authentication_classes = []
10+
11+
12+
class ProxiedEmbedAPI(SettingsOverrideObject):
13+
14+
_default_class = ProxiedEmbedAPIBase

readthedocs/proxito/urls.py

+8
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@
9797
),
9898
include('readthedocs.api.v2.proxied_urls'),
9999
),
100+
101+
# /_/api/v3/
102+
url(
103+
r'^{DOC_PATH_PREFIX}api/v3/'.format(
104+
DOC_PATH_PREFIX=DOC_PATH_PREFIX,
105+
),
106+
include('readthedocs.api.v3.proxied_urls'),
107+
),
100108
]
101109

102110
core_urls = [

0 commit comments

Comments
 (0)