Skip to content

Document about cross-site request #9999

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 2 commits into from
Feb 10, 2023
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
36 changes: 36 additions & 0 deletions docs/user/api/cross-site-requests.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Cross-site requests
===================

Cross site requests are allowed for the following endpoints:

- :ref:`/api/v2/footer_html/ <api/v2:Undocumented resources and endpoints>`
- :ref:`/api/v2/search/ <server-side-search/api:API V2 (deprecated)>`
- :ref:`/api/v2/embed/ <api/v2:Embed>`
- :ref:`/api/v2/sustainability/ <api/v2:Undocumented resources and endpoints>`
- :ref:`/api/v3/embed/ <api/v3:Embed>`

Except for the sustainability API, all of the above endpoints
don't allow you to pass credentials in cross-site requests.
In other words, these API endpoints allow you to access **public information only**.

On a technical level, this is achieved by implementing the CORS_ standard,
which is supported by all major browsers.
We implement it such way that it strictly match the intention of the API endpoint.

.. _CORS: https://en.wikipedia.org/wiki/Cross-origin_resource_sharing

Cookies
-------

On |org_brand|, our session cookies have the ``SameSite`` attribute set to ``None``,
this means they can be sent in cross site requests.
This is needed for our sustainability API only,
to not show ads if the current user is a :ref:`Gold User <advertising/ad-blocking:Going ad-free>`.
All resources in |org_brand| are public, you don't need to pass cookies to make use
of our allowed APIs from other sites.

On |com_brand|, our session cookies have the ``SameSite`` attribute set to ``Lax``.
This means that browsers will not include them in cross site requests.
If you need to have access to versions that the current user has permissions over,
you can make use of our proxied APIs, they can be accessed from docs domains with the `/_/` prefix.
For example, you can make use of our search API from `<your-docs-domain>/_/api/v2/search/`.
1 change: 1 addition & 0 deletions docs/user/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ from Read the Docs.

v3
v2
cross-site-requests
1 change: 0 additions & 1 deletion docs/user/api/v2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ There are some undocumented endpoints in the API.
These should not be used and could change at any time.
These include:

* The search API (``/api/v2/search/``)
Copy link
Member Author

Choose a reason for hiding this comment

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

This api is now documented :D

* Endpoints for returning footer and version data to be injected into docs.
(``/api/v2/footer_html``)
* Endpoints used for advertising (``/api/v2/sustainability/``)
Expand Down