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

Iiif endpoint #2907

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions app/controllers/media_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class MediaController < ApplicationController

def show
if can?(:access_media_url, pbcore)
# TODO: wrap in conditional specific to CORS-allowed requests once confirmed
# that the headers are correctly being set.
allow_cors!
redirect_to media_url
else
render nothing: true, status: :unauthorized
Expand Down Expand Up @@ -46,4 +49,12 @@ def solr_doc
def sony_ci
@sony_ci ||= SonyCiApi::Client.new(Rails.root + 'config/ci.yml')
end

def allow_cors!
Rails.logger.info("Allowing CORS access to media content.")
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'GET, OPTIONS'
headers['Access-Control-Request-Method'] = '*'
headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
end
end
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class User
DARTMOUTH_HOST_RE = /^(.+\.)?meptest\.dartmouth\.edu$/
DARTMOUTH_HOST_2_RE = /^(.+\.)?pub\.dartmouth\.edu$/
GITHUB_IO = /^(.+\.)?github\.io$/
AVIARY_PLATFORM = /^(.+\.)?iiif\.aviaryplatform\.com$/
AVIARY_PLATFORM = /^(.+)?iiif\.aviaryplatform\.com$/
POPUP_HOST_RE = /^(.+\.)?popuparchive\.com$/
AAPB_HOST_RE = /^(.+\.)?americanarchive\.org$/
AWS_HOST_RE = /^(.+\.)?wgbh-mla\.org$/
Expand Down