Skip to content

Strip out proxy from Rails-based WMS requests #370

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

Merged
merged 1 commit into from
Sep 3, 2024
Merged
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
18 changes: 18 additions & 0 deletions app/controllers/wms_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

class WmsController < ApplicationController
def handle
# Overriding to use NYU Specific WMS Layer class
response = NyuGeoblacklight::WmsLayer.new(wms_params).feature_info

respond_to do |format|
format.json { render json: response }
end
end

private

def wms_params
params.permit(Settings.GBL_PARAMS)
end
end
12 changes: 12 additions & 0 deletions lib/nyugeoblacklight/wms_layer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

module NyuGeoblacklight
class WmsLayer < Geoblacklight::WmsLayer
def initialize(params)
# Overriding to strip proxy from WMS requests made by Rails app
params['URL'].gsub!('http://proxy.library.nyu.edu/login?url=', '')

super(params)
end
end
end
11 changes: 11 additions & 0 deletions spec/lib/nyu_geoblacklight/wms_layer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper'

RSpec.describe NyuGeoblacklight::WmsLayer do
context 'when the URL param contains the NYU proxy' do
it 'strips out the NYU proxy' do
wms_layer = described_class.new({ 'URL' => 'http://proxy.library.nyu.edu/login?url=http://example.com' })

expect(wms_layer.url).to eq('http://example.com')
end
end
end