okta / okta-react

Okta OIDC SDK for React
https://github.com/okta/okta-react
Other
114 stars 78 forks source link

Cannot specify "fromUri" with query parameters to login() #183

Open RacingTadpole opened 5 years ago

RacingTadpole commented 5 years ago

I'm submitting this issue for the package(s):

I'm submitting a:

Current behavior

When a user is required to re-authenticate, I would like them to be redirected back to the same URL they came from afterwards. In my case, auth.history does not match window.location because I am updating the URL as the users navigate the site (using browserHistory). So auth.login() doesn't do what I want.

Now auth.login's first parameter is fromUri, but it is limited: it must be a string corresponding to a pathname, as Auth.js uses it like so:

const referrerPath = fromUri ? { pathname: fromUri } : this._history.location;

So

this.props.auth.login(window.location.pathname)

works, but it is not enough – my users need to be redirected to a URL including query parameters (from location.search, not just location.pathname), and they are stripped.

I tried

this.props.auth.login(window.location.pathname + window.location.search)

but this simply hangs when it returns.

Expected behavior

Ideally I could just do

this.props.auth.login(window.location)

To achieve this, Auth.js's login could check if fromUri is an object, and if so just use it.

Minimal reproduction of the problem with instructions

Extra information about the use case/user story you are trying to implement

Environment

jmelberg-okta commented 5 years ago

Thanks for the report @RacingTadpole!

I'll label this as an enhancement.