-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Docs: document CORS policies #10853
Merged
Merged
Docs: document CORS policies #10853
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
Understanding the security implications of documentation pages | ||
============================================================== | ||
|
||
This article explains the security implications of documentation pages, | ||
this doesn't apply to the main dashboard (readthedocs.org/readthedocs.com), | ||
only to documentation pages (readthedocs.io, readthedocs-hosted.com, and custom domains). | ||
|
||
.. seealso:: | ||
|
||
:doc:`/api/cross-site-requests` | ||
Learn about cross-origin requests in our public APIs. | ||
|
||
Cross-origin requests | ||
--------------------- | ||
|
||
Read the Docs allows `cross-origin requests`_ for documentation resources it serves. | ||
However, internal and proxied APIs, typically found under the ``/_/`` path don't allow cross-origin requests. | ||
|
||
To facilitate this, the following headers are added to all responses from documentation pages: | ||
|
||
- ``Access-Control-Allow-Origin: *`` | ||
- ``Access-Control-Allow-Methods: GET, HEAD, OPTIONS`` | ||
|
||
These headers allow cross-origin requests from any origin | ||
and only allow the GET, HEAD and OPTIONS methods. | ||
It's important to note that passing credentials (such as cookies or HTTP authentication) | ||
in cross-origin requests is not allowed, | ||
ensuring access to public resources only. | ||
|
||
Having cross-origin requests enabled allows third-party websites to make use of files from your documentation (as long as they are public), | ||
which allows various third-party integrations to work. | ||
|
||
If needed, the ``Access-Control`` headers can be changed for your documentation pages by :doc:`contacting support </support>`. | ||
**You are responsible for providing the correct values for these headers, and making sure they don't break your documentation pages.** | ||
|
||
.. _cross-origin requests: https://en.wikipedia.org/wiki/Cross-origin_resource_sharing | ||
|
||
Cookies | ||
------- | ||
|
||
On |org_brand|, we don't use cookies, as all resources are public. | ||
|
||
On |com_brand|, we use cookies to store user sessions. | ||
These cookies are set when a user authenticates to access private documentation. | ||
Session cookies have the ``SameSite`` attribute set to ``None``, | ||
which allows them to be sent in cross-origin requests where allowed | ||
(see :ref:`security-implications:Cross-origin requests`), | ||
for example, when embedding private documentation pages in an iframe | ||
(see :ref:`security-implications:Embedding documentation pages`). | ||
|
||
Embedding documentation pages | ||
----------------------------- | ||
|
||
Embedding documentation pages in an iframe is allowed. | ||
Read the Docs doesn't set the ``X-Frame-Options`` or ``Content-Security-Policy`` headers, | ||
which means that the browser's default behavior is used. | ||
|
||
Embedding private documentation pages in an iframe is possible, | ||
but it requires users to be previously authenticated in the embedded domain. | ||
|
||
It's important to note that embedding documentation pages in an iframe does not grant the parent page access the iframe's content. | ||
Documentation pages serve static content only, and the exposed APIs are read-only, | ||
making the exploitation of a clickjacking vulnerability very unlikely. | ||
|
||
If needed, the ``X-Frame-Options`` and ``Content-Security-Policy`` headers can be set on your documentation pages by :doc:`contacting support </support>`. | ||
**You are responsible for providing the correct values for these headers, and making sure they don't break your documentation pages.** |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wasn't sure where to include this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like a good spot 👍