Bug #17101

Google/OIDC login doesn't navigate user back to original path

Added by Peter Amstutz 20 days ago. Updated 14 days ago.

Status:
Resolved
Priority:
Normal
Assigned To:
Category:
Workbench2
Target version:
Start date:
11/11/2020
Due date:
% Done:

100%

Estimated time:
(Total: 0.00 h)
Story points:
-
Release relationship:
Auto

Description

The user can copy the wb2 path (a project or collection) from the URL bar and send it to another user. The 2nd user clicks on it, but need to log in. After the user logs in, they are shown the default starting view, not the project or collection they intended to visit.

Fixing this will make it easier for users to share URLs to collections, as well as making the implementation of "copy to clipboard" and "open in new tab" for projects/collections much simpler.

This happens because the AuthService.login (src/services/auth-service/auth-service.ts) method does not record the path that the user intended to navigate to. It sends the user to the 3rd party login, and the token is returned by redirecting the browser to the /token endpoint, which saves the token, and then the user is shown the default page.

The login method should provides a means of returning to the desired location. This means stashing the current path and query parameters in one of two places:

  • embedded in the URL that will be sent to the login server as return_to.
    The way return_to is used is that the upstream Arvados API server redirects the browser to the URL in "return_to" and adds "api_token=xxx" query parameter. This would require check for "api_token" in the query during initialization and not just when navigating to the "token" endpoint.
  • browser storage (session storage?) so that when returning to the page, it restores the original path and query.

Subtasks

Task #17102: ReviewResolvedDaniel Kutyła

Associated revisions

Revision c28f185b
Added by Daniel Kutyła 19 days ago

Merge branch '17101-login-doesnt-navigate-user-back-to-original-path'
closes #17101

Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <>

History

#1 Updated by Peter Amstutz 20 days ago

  • Description updated (diff)

#2 Updated by Peter Amstutz 20 days ago

  • Description updated (diff)

#3 Updated by Peter Amstutz 20 days ago

  • Description updated (diff)

#5 Updated by Daniel Kutyła 20 days ago

  • Status changed from New to In Progress

#6 Updated by Peter Amstutz 19 days ago

It wasn't working consistently. Sometimes it would go to the correct page, sometimes it wouldn't.

On investigation, and it seems like setting window.location.href causes a page reload, and there is some kind of race condition where on the reload it would sometimes call ApiToken.componentDidMount leading to calling getTargetURL() again, but on the second time it would come back as null, so it then it would call navigateToRootProject. But this doesn't happen consistently.

I fixed this by calling replace() from react-redux-router, which doesn't trigger a page reload. I also changed the value stored in TargetURL to be just the path and query string.

17101-login-doesnt-navigate-user-back-to-original-path @ arvados-workbench2|54e734a4074911ce516a65c7195c84ad523adc75

https://ci.arvados.org/view/Developer/job/developer-tests-workbench2/171/

Take a look at my changes and if you don't have any issues with it, please merge.

#7 Updated by Daniel Kutyła 19 days ago

  • % Done changed from 0 to 100
  • Status changed from In Progress to Resolved

#8 Updated by Peter Amstutz 14 days ago

  • Release set to 36

Also available in: Atom PDF