Skip to content

Don't delete SP info from session after redirect#1561

Merged
monfresh merged 1 commit intomasterfrom
mb-preserve-sp-in-session-after-redirect
Jul 20, 2017
Merged

Don't delete SP info from session after redirect#1561
monfresh merged 1 commit intomasterfrom
mb-preserve-sp-in-session-after-redirect

Conversation

@monfresh
Copy link
Contributor

Why: I don't think there's a valid reason to do that. Digging
into the git history, it looks like the deletion of the SP info from
the session was introduced in the same PR that implemented the branded
experience. I believe the reasoning was that unless the branded
experience was deleted, returning to the IdP after signing out from the
SP would keep the branded experience around, which is not the case since
the entire session is deleted upon logout.

Deleting the SP info from the session is resulting in an exception in
the following scenario:

  • A user launches a mobile app that integrates with login.gov
  • The user completes the account creation process on their mobile device
  • Once they arrive on the completions page and click "Continue",
    they are prompted to launch the mobile app. Whether the user chooses to
    launch the app or click Cancel, the IdP web page stays where it is.
  • If the user comes back to the IdP page at a later time and tries to
    hit the Continue button again, they will get an error because
    CompletionsController#update depends on sp_session[:request_url]
    being present.

How:

  • Don't delete the SP info from the session
  • To allow the user to visit the IdP after being redirected back to
    the SP, update SessionsController#check_user_needs_redirect to
    redirect to signed_in_path instead of
    after_sign_in_path_for(current_user) because the latter will redirect
    back to sp_session[:request_url] now that we are no longer deleting
    sp_session.

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 make these positive expectations?

expect(page.get_rack_session.keys).to include('sp')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Fixed. PTAL

Copy link
Contributor

Choose a reason for hiding this comment

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

same, should we make sure this keeps the sp in the session?

expect(session.key?(:sp)).to eq(true)

**Why**: I don't think there's a valid reason to do that. Digging
into the git history, it looks like the deletion of the SP info from
the session was introduced in the same PR that implemented the branded
experience. I believe the reasoning was that unless the branded
experience was deleted, returning to the IdP after signing out from the
SP would keep the branded experience around, which is not the case since
the entire session is deleted upon logout.

Deleting the SP info from the session is resulting in an exception in
the following scenario:
- A user launches a mobile app that integrates with login.gov
- The user completes the account creation process on their mobile device
- Once they arrive on the completions page and click "Continue",
they are prompted to launch the mobile app. Whether the user chooses to
launch the app or click Cancel, the IdP web page stays where it is.
- If the user comes back to the IdP page at a later time and tries to
hit the Continue button again, they will get an error because
`CompletionsController#update` depends on `sp_session[:request_url]`
being present.

**How**:
- Don't delete the SP info from the session
- To allow the user to visit the IdP after being redirected back to
the SP, update `SessionsController#check_user_needs_redirect` to
redirect to `signed_in_path` instead of
`after_sign_in_path_for(current_user)` because the latter will redirect
back to `sp_session[:request_url]` now that we are no longer deleting
`sp_session`.
@monfresh monfresh force-pushed the mb-preserve-sp-in-session-after-redirect branch from 786aa4c to 913b4a2 Compare July 20, 2017 18:56
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!

@monfresh monfresh merged commit 8103be8 into master Jul 20, 2017
@monfresh monfresh deleted the mb-preserve-sp-in-session-after-redirect branch July 20, 2017 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants