Skip to content

Fix adding new phone number redirects to SP (LG-3784)#4660

Merged
mitchellhenke merged 6 commits intomasterfrom
mitchellhenke/new-phone-number-bad-redirect-lg-3784
Feb 11, 2021
Merged

Fix adding new phone number redirects to SP (LG-3784)#4660
mitchellhenke merged 6 commits intomasterfrom
mitchellhenke/new-phone-number-bad-redirect-lg-3784

Conversation

@mitchellhenke
Copy link
Contributor

@mitchellhenke mitchellhenke commented Feb 9, 2021

related to #1561 and #2426

The issue at hand is authenticating with an SP, then going back to the account page and adding a phone causes the user to be redirected back to the SP, when they'd expect to go back to the account page. The root issue is adding a phone ends up here, and hitting the SP redirect due to the SP context still existing in the session: https://github.com/18F/identity-idp/blob/6a6b321/app/controllers/application_controller.rb#L162-L166

The crux of the changes is adding session.delete(:sp) as part of delete_branded_experience, which is called when redirecting back to an SP. My understanding is at that point, the SP authentication is complete, and it should be safe to delete any session data related to it.

There were some tests and pieces of functionality that relied upon the SP session existing after successful authentication though:

  1. SP Handoff Bouncing - This was stored in sp_session to prevent multiple quick SP authentications, but it should be safe to move it to the regular session
  2. OIDC Logout CSP check - Used the sp_session to add the redirect_uris to the form-action CSP header. We shouldn't need to add those to form-action since we aren't submitting forms to them, just redirecting back.
  3. Multiple tabs spec - From what I can tell, the tests were ensuring that someone could complete authentication to an SP, and then go /two_factor_authentication and still be redirected back to the SP. It wasn't clear from LG-554 Fix already authenticated users redirecting to account page #2426 why that behavior was being verified, but I think we get into muddy territory if SP context is still around after completing authentication?

@mitchellhenke mitchellhenke marked this pull request as ready for review February 9, 2021 17:00
@mitchellhenke mitchellhenke requested review from achapm, stevegsa and zachmargolis and removed request for zachmargolis February 9, 2021 17:00
click_submit_default

expect(current_url).to start_with('http://localhost:7654/auth/result')
expect(page.get_rack_session.keys).to include('sp')
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just flip the assertion to expect it's not there? expect().to_not include('sp')

Ditto for the one below

Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@stevegsa stevegsa left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@achapm achapm left a comment

Choose a reason for hiding this comment

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

LGTM

@mitchellhenke mitchellhenke merged commit 9155949 into master Feb 11, 2021
@mitchellhenke mitchellhenke deleted the mitchellhenke/new-phone-number-bad-redirect-lg-3784 branch February 11, 2021 17:17
zachmargolis added a commit that referenced this pull request Feb 25, 2021
zachmargolis added a commit that referenced this pull request Feb 25, 2021
* Add failing spec for double click issue

* Revert "Fix adding new phone number redirects to SP (LG-3784) (#4660)"

This reverts commit 9155949.
zachmargolis added a commit that referenced this pull request Feb 25, 2021
* Add failing spec for double click issue

* Revert "Fix adding new phone number redirects to SP (LG-3784) (#4660)"

This reverts commit 9155949.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants