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

Allow cookie options to be set in config #175

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
9 changes: 9 additions & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,15 @@ log:

#maximum_session_lifetime: 172800

# Set custom cookie parameters such as max-age or secure

#cookie_options:
# domain:
# path:
# max_age:
# expires:
# secure:
# httponly:

# If you want the usernames entered on the login page to be automatically
# downcased (converted to lowercase), enable the following option. When this
Expand Down
3 changes: 2 additions & 1 deletion lib/casserver/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ def self.init_database!

# 3.6 (ticket-granting cookie)
tgt = generate_ticket_granting_ticket(@username, extra_attributes)
response.set_cookie('tgt', tgt.to_s)
cookie_options = (settings.config[:cookie_options] || {}).symbolize_keys
response.set_cookie('tgt', cookie_options.merge(:value => tgt.to_s))

$LOG.debug("Ticket granting cookie '#{tgt.inspect}' granted to #{@username.inspect}")

Expand Down
1 change: 1 addition & 0 deletions spec/casserver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
click_button 'login-submit'

page.should have_content("You have successfully logged in")
Capybara.current_session.driver.response.headers['Set-Cookie'].should match 'path=/'
end

it "fails to log in with invalid password" do
Expand Down
3 changes: 3 additions & 0 deletions spec/config/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ enable_single_sign_out: true

#maximum_session_lifetime: 172800

cookie_options:
path: "/"

#downcase_username: true

allowed_service_ips:
Expand Down