Skip to content

Commit db531da

Browse files
authored
Document about cross-site request (#9999)
* Document about cross-site request * Updates from review
1 parent ff3b2a7 commit db531da

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

docs/user/api/cross-site-requests.rst

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Cross-site requests
2+
===================
3+
4+
Cross site requests are allowed for the following endpoints:
5+
6+
- :ref:`/api/v2/footer_html/ <api/v2:Undocumented resources and endpoints>`
7+
- :ref:`/api/v2/search/ <server-side-search/api:API V2 (deprecated)>`
8+
- :ref:`/api/v2/embed/ <api/v2:Embed>`
9+
- :ref:`/api/v2/sustainability/ <api/v2:Undocumented resources and endpoints>`
10+
- :ref:`/api/v3/embed/ <api/v3:Embed>`
11+
12+
Except for the sustainability API, all of the above endpoints
13+
don't allow you to pass credentials in cross-site requests.
14+
In other words, these API endpoints allow you to access **public information only**.
15+
16+
On a technical level, this is achieved by implementing the CORS_ standard,
17+
which is supported by all major browsers.
18+
We implement it such way that it strictly match the intention of the API endpoint.
19+
20+
.. _CORS: https://en.wikipedia.org/wiki/Cross-origin_resource_sharing
21+
22+
Cookies
23+
-------
24+
25+
On |org_brand|, our session cookies have the ``SameSite`` attribute set to ``None``,
26+
this means they can be sent in cross site requests.
27+
This is needed for our sustainability API only,
28+
to not show ads if the current user is a :ref:`Gold User <advertising/ad-blocking:Going ad-free>`.
29+
All resources in |org_brand| are public, you don't need to pass cookies to make use
30+
of our allowed APIs from other sites.
31+
32+
On |com_brand|, our session cookies have the ``SameSite`` attribute set to ``Lax``.
33+
This means that browsers will not include them in cross site requests.
34+
If you need to have access to versions that the current user has permissions over,
35+
you can make use of our proxied APIs, they can be accessed from docs domains with the `/_/` prefix.
36+
For example, you can make use of our search API from `<your-docs-domain>/_/api/v2/search/`.

docs/user/api/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ from Read the Docs.
1212

1313
v3
1414
v2
15+
cross-site-requests

docs/user/api/v2.rst

-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ There are some undocumented endpoints in the API.
408408
These should not be used and could change at any time.
409409
These include:
410410

411-
* The search API (``/api/v2/search/``)
412411
* Endpoints for returning footer and version data to be injected into docs.
413412
(``/api/v2/footer_html``)
414413
* Endpoints used for advertising (``/api/v2/sustainability/``)

0 commit comments

Comments
 (0)