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