Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.
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
2 changes: 1 addition & 1 deletion app/helpers/casino/sessions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def sign_in(authentication_result, options = {})
end

def set_tgt_cookie(tgt)
cookies[:tgt] = { value: tgt.ticket }.tap do |cookie|
cookies[:tgt] = { value: tgt.ticket, httponly: !!CASino.config.httponly_tgt_cookies }.tap do |cookie|
if tgt.long_term?
cookie[:expires] = CASino.config.ticket_granting_ticket[:lifetime_long_term].seconds.from_now
end
Expand Down
1 change: 1 addition & 0 deletions lib/casino.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module CASino
defaults = {
authenticators: HashWithIndifferentAccess.new,
require_service_rules: false,
httponly_tgt_cookies: false,
logger: Rails.logger,
frontend: HashWithIndifferentAccess.new(
sso_name: 'CASino',
Expand Down
18 changes: 18 additions & 0 deletions spec/controllers/sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,24 @@
tgt = CASino::TicketGrantingTicket.last
tgt.long_term.should == true
end

it 'creates a cookie that is not httponly by default' do
post :create, params
controller.cookies['tgt']['httponly'].should be(false)
end

context 'when we are configured for http_only_tgt_cookies' do
before do
CASino.config.httponly_tgt_cookies = true
end
after do
CASino.config.httponly_tgt_cookies = false
end
it 'creates an httponly cookie' do
post :create, params
controller.cookies['tgt']['httponly'].should be(true)
end
end
end

context 'with two-factor authentication enabled' do
Expand Down