Skip to content
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

Pass along the ?service param when the / is requested #210

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion lib/casserver/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
15 changes: 14 additions & 1 deletion spec/casserver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -217,4 +230,4 @@
end
end
end
end
end