-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strip out proxy from Rails-based WMS requests (#370)
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |