Skip to content

EmbedAPIv3: proxy URLs to be available under /_/ #8540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions readthedocs/api/v3/proxied_urls.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions readthedocs/api/v3/proxied_views.py
Original file line number Diff line number Diff line change
@@ -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 = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably makes sense to make this a Mixin if we're using it on all proxied API's.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I opened an issue to track this #8542



class ProxiedEmbedAPI(SettingsOverrideObject):

_default_class = ProxiedEmbedAPIBase
8 changes: 8 additions & 0 deletions readthedocs/proxito/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down