Skip to content

Commit

Permalink
Strip out proxy from Rails-based WMS requests (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
spilth authored Sep 3, 2024
1 parent 4fc9836 commit c538513
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
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

0 comments on commit c538513

Please sign in to comment.