Skip to content
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

Allow embedding by list of trusted referers when GLOBAL_LOGIN is enabled. #1093

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

yatesdr
Copy link
Contributor

@yatesdr yatesdr commented Oct 23, 2024

1). Add a settings key to optionally allow embedding videos from a list of trusted referers when GLOBAL_LOGIN_REQUIRED is true. This is useful if you wish to use MediaCMS as a back-end content manager, with the embedded files being used on another site.

2). If above option is set, modify the auth-bypass regex list in settings.py to permit loading from all origins in the embed view without auth, to paths in r'^/embed.*' and r'^/media/.*'

3). Modify embed view to validate embed requests against the list of allowed referers - check request.META['HTTP_REFERER'], parse the domain, and compare to the list. This required including urlparse to perform the domain parse in a reliable and standard way in this view.

4). Create a "fake player" to render (templates/cms/embed-403.html) with a mock 403 error, that fits to parent element and is generally styled like a generic player element. This is required since embedding in rich content editors often does not properly set referrer on otherwise trusted sites, and giving a 500 API error or redirecting to the MediaCMS main login page is not desirable in this use case.

Example "Bad referrer" render in the stock embed iframe:
image

5). Doc updates to reflect this new option and its usage.

Add settings key GLOBAL_LOGIN_ALLOW_EMBED_DOMAINS, and exclude embed? and /media/ from auth requirements if present.
Dummy player for embedding on rich editors, to permit layout evaluation if the referer is not set until save.
@yatesdr
Copy link
Contributor Author

yatesdr commented Oct 30, 2024

Ping on the draft PR - Just clicked "ready for review".

@yatesdr yatesdr marked this pull request as ready for review October 30, 2024 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant