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
4 changes: 3 additions & 1 deletion app/controllers/concerns/fully_authenticatable.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module FullyAuthenticatable
def delete_branded_experience
def delete_branded_experience(logout: false)
ServiceProviderRequestProxy.delete(request_id)
session[:sp] = {} if logout
nil
end

def request_id
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/openid_connect/logout_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module OpenidConnect
class LogoutController < ApplicationController
include SecureHeadersConcern
include FullyAuthenticatable

before_action :apply_secure_headers_override, only: [:index, :delete]
before_action :confirm_two_factor_authenticated, only: [:delete]
Expand Down Expand Up @@ -62,6 +63,8 @@ def handle_successful_logout_request(result, redirect_uri)
}
@params[:state] = logout_params[:state] if !logout_params[:state].nil?
@service_provider_name = @logout_form.service_provider&.friendly_name
delete_branded_experience(logout: true)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do this on every branded experience deletion?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering the same. Looking at all the places where this is used and I don't think I see one where that would be inappropriate to remove the sp session.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one thing it would potentially break is the sp bounce check which gets stored in the SP session (but we've discussed moving it into the user session)

Copy link
Copy Markdown
Contributor Author

@orenyk orenyk Oct 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mitchellhenke @jmhooper In the interest of time I'd like to propose keeping this the way it is - leaving delete_branded_experience the same for existing use cases that aren't part of logout requests and additionally clearing the session[:sp] in logout / auth terminating flows. We can have Katherine refactor after the bug is fixed, I'd just rather not touch the sp bounce code since that's not something I'm familiar with. Does that make sense?


render :index
else
analytics.logout_initiated(**result.to_h.except(:redirect_uri))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ def index
@sp_name = sp_from_sp_session&.friendly_name ||
I18n.t('service_providers.errors.generic_sp_name')

delete_branded_experience
session[:sp] = {}
delete_branded_experience(logout: true)
end
end
end
25 changes: 25 additions & 0 deletions spec/features/openid_connect/openid_connect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
click_link t('openid_connect.logout.deny')

expect(page).to have_content(t('headings.account.login_info'))
expect(page).not_to have_content(service_provider.friendly_name)
end
end
end
Expand Down Expand Up @@ -299,6 +300,30 @@
expect(page).to have_content(t('headings.sign_in_without_sp'))
end

it 'does not destroy the session and redirects to account page when denying logout' do
service_provider = ServiceProvider.find_by(issuer: 'urn:gov:gsa:openidconnect:test')
sign_in_get_id_token(client_id: service_provider.issuer)

state = SecureRandom.hex

visit openid_connect_logout_path(
client_id: service_provider.issuer,
post_logout_redirect_uri: 'gov.gsa.openidconnect.test://result/signout',
state: state,
)
expect(page).to have_content(
t(
'openid_connect.logout.heading_with_sp',
app_name: APP_NAME,
service_provider_name: service_provider.friendly_name,
),
)
click_link t('openid_connect.logout.deny')

expect(page).to have_content(t('headings.account.login_info'))
expect(page).not_to have_content(service_provider.friendly_name)
end

it 'logout rejects requests that include id_token_hint' do
id_token = sign_in_get_id_token

Expand Down