Skip to content
Merged
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
8 changes: 6 additions & 2 deletions app/controllers/openid_connect/authorization_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def check_sp_active
end

def check_sp_handoff_bounced
return unless SpHandoffBounce::IsBounced.call(sp_session)
return unless sp_handoff_bouncer.bounced?
analytics.sp_handoff_bounced_detected
redirect_to bounced_url
true
Expand Down Expand Up @@ -120,7 +120,7 @@ def resolved_authn_context_int_ial

def handle_successful_handoff
track_events
SpHandoffBounce::AddHandoffTimeToSession.call(sp_session)
sp_handoff_bouncer.add_handoff_time!

redirect_user(
@authorize_form.success_redirect_uri,
Expand Down Expand Up @@ -261,5 +261,9 @@ def redirect_user(redirect_uri, issuer, user_uuid)
)
end
end

def sp_handoff_bouncer
@sp_handoff_bouncer ||= SpHandoffBouncer.new(sp_session)
end
end
end
9 changes: 0 additions & 9 deletions app/services/sp_handoff_bounce/add_handoff_time_to_session.rb

This file was deleted.

13 changes: 0 additions & 13 deletions app/services/sp_handoff_bounce/is_bounced.rb

This file was deleted.

20 changes: 20 additions & 0 deletions app/services/sp_handoff_bouncer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

class SpHandoffBouncer
attr_reader :sp_session

def initialize(sp_session)
@sp_session = sp_session
end

def add_handoff_time!(now = Time.zone.now)
sp_session[:sp_handoff_start_time] = now
end

def bounced?(now = Time.zone.now)
start_time = sp_session[:sp_handoff_start_time]
return false if start_time.blank?
start_time = Time.zone.parse(start_time) if start_time.instance_of?(String)
now <= (start_time + IdentityConfig.store.sp_handoff_bounce_max_seconds.seconds)
end
end