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

Restrict Media Access On Admin Routes #2889

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
23 changes: 17 additions & 6 deletions app/controllers/embed_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,36 @@ def lite
raise Blacklight::Exceptions::RecordNotFound unless @document
xml = @document['xml']
@pbcore = PBCorePresenter.new(xml)

response.headers.delete('X-Frame-Options')
if can? :play_embedded, @pbcore
# can? play because we're inside this block
if @pbcore.proxy_start_time && params["proxy_start_time"].nil? && !media_start_time?(params)
params["proxy_start_time"] = @pbcore.proxy_start_time
end
end

response.headers.delete('X-Frame-Options')

render 'lite', layout: 'lite_embed'
render 'lite', layout: 'lite_embed'
else
head :unauthorized
end
end

def openvault
@response, @document = fetch_from_solr(params['id'])
raise Blacklight::Exceptions::RecordNotFound unless @document
xml = @document['xml']
@pbcore = PBCorePresenter.new(xml)

response.headers.delete('X-Frame-Options')
response.headers['Content-Security-Policy'] = 'frame-ancestors https://ov.wgbh-mla.org http://localhost:4000 http://localhost:3000;'

if can? :play, @pbcore
# can? play because we're inside this block
if @pbcore.proxy_start_time && params["proxy_start_time"].nil? && !media_start_time?(params)
params["proxy_start_time"] = @pbcore.proxy_start_time
end
else
head :unauthorized
end

response.headers.delete('X-Frame-Options')
Expand All @@ -51,13 +59,16 @@ def video
raise Blacklight::Exceptions::RecordNotFound unless @document
xml = @document['xml']
@pbcore = PBCorePresenter.new(xml)

response.headers.delete('X-Frame-Options')

if can? :play, @pbcore
# can? play because we're inside this block
if @pbcore.proxy_start_time && params["proxy_start_time"].nil? && !media_start_time?(params)
params["proxy_start_time"] = @pbcore.proxy_start_time
end
else
head :unauthorized
end

response.headers.delete('X-Frame-Options')
end
end