Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users with multiple open tabs are all redirected to the same return url #57

Open
rtyley opened this issue Feb 20, 2018 · 0 comments
Open

Comments

@rtyley
Copy link
Member

rtyley commented Feb 20, 2018

Steps to reproduce bug

  1. Ensure you have more than 1 Google account - meaning that Google will ask you to choose which Google account to use every time you authenticate.
  2. Go to https://dashboard.ophan.co.uk/ and get the Ophan Heatmap bookmarklet image
  3. Log out of https://dashboard.ophan.co.uk/ with the signout button.
  4. In tab A, go to https://dashboard.ophan.co.uk/ - you should be redirected and see a Google Choose an account to continue to ophan.co.uk message
  5. In tab B, go to https://www.theguardian.com/uk and activate the Ophan Heatmap. You should see a "Please log into Ophan to use the heatmap." message: image
  6. Complete the authentication process (by selecting your guardian.co.uk account) in tab A.

Expected behaviour

Tab A is redirected to https://dashboard.ophan.co.uk/ - which is where the user was trying to go in that tab before the authentication happened.

Actual behaviour

Tab A is redirected to https://dashboard.ophan.co.uk/heatmap/filter-bar?path=/uk&# on completing authentication, and it looks like a mess: image

Cause

The return url is stored in the Play session:

def sendForAuth[A](request: RequestHeader)(implicit ec: ExecutionContext) =
Redirect(loginTarget).withSession {
request.session + (GoogleAuthFilters.LOGIN_ORIGIN_KEY, request.uri)
}

...and is being set with the authentication attempt in Tab A, then overwritten by the authentication attempt in Tab B. When Tab A returns, it unfortunately uses that return url stored by tab B:

def setupSessionWhenSuccessful(userIdentity: UserIdentity)(implicit request: RequestHeader): Result = {
val redirect = request.session.get(GoogleAuthFilters.LOGIN_ORIGIN_KEY) match {
case Some(url) => Redirect(url)
case None => Redirect(defaultRedirectTarget)
}

Proposed Fix

Instead of storing the return url in the Play session, it could be stored in the state of the OAuth authentication request - ie in the JWT token introduced with #52.

The return url should probably be encrypted to avoid return urls leaking to Google servers.

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 a pull request may close this issue.

1 participant