Allow embedding by list of trusted referers when GLOBAL_LOGIN is enabled. #1093
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.
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:
5). Doc updates to reflect this new option and its usage.