From 0329b199d4fdf9c58dd9be85f269974e895b10a0 Mon Sep 17 00:00:00 2001 From: Marcello Barnaba Date: Wed, 14 May 2014 18:04:29 +0200 Subject: [PATCH] Pass along the ?service param when the / is requested --- lib/casserver/server.rb | 6 +++++- spec/casserver_spec.rb | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/casserver/server.rb b/lib/casserver/server.rb index 77f7633a..489f891f 100644 --- a/lib/casserver/server.rb +++ b/lib/casserver/server.rb @@ -499,7 +499,11 @@ def self.init_database! end get /^#{uri_path}\/?$/ do - redirect "#{config['uri_path']}/login", 303 + service = if params['service'] + "?service=#{clean_service_url(params['service'])}" + end + + redirect "#{config['uri_path']}/login#{service}", 303 end diff --git a/spec/casserver_spec.rb b/spec/casserver_spec.rb index b49c1a03..5322b362 100644 --- a/spec/casserver_spec.rb +++ b/spec/casserver_spec.rb @@ -20,6 +20,19 @@ @target_service = 'http://my.app.test' end + describe "/" do + it "redirects to /login" do + visit "/" + page.current_url.should =~ %r{/login$} + end + + it "redirects to /login preserving the ?service= parameter" do + visit "/?service=http://foo.bar" + + page.current_url.should =~ %r{/login\?service=http://foo\.bar$} + end + end + describe "/login" do before do load_server("default_config") @@ -217,4 +230,4 @@ end end end -end \ No newline at end of file +end