I'm submitting this issue for the package(s):
I'm submitting a:
Current behavior
hard linking (deep link, using an anchor element) into the app with a query parameter that ends with code= seems to break the app and nothing inside of a SecureRoute will render, even after navigating to new routes. Soft linking around with react router usually works, but will also break sometimes.
Expected behavior
query parameters should not cause SecureRoutes to render nothing.
Minimal reproduction of the problem with instructions
install okta-react 3.0.7, then use this as your react application
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter, Route, Switch, Link } from 'react-router-dom';
import { Security, SecureRoute, LoginCallback } from '@okta/okta-react';
const RootArea = () => <div>root</div>;
const InsecureArea = () => <div>Not secure here</div>;
const First = () => <div>first</div>;
const Second = () => <div>second</div>;
const Third = () => <div>third</div>;
const Fourth = () => <div>fourth</div>;
const SecureArea = () => (
<>
<Route path="/secure/first" component={First} />
<Route path="/secure/second" component={Second} />
<Route path="/secure/third" component={Third} />
<Route path="/secure/fourth" component={Fourth} />
</>
);
const LinkLi = ({ to }) => <li>soft link: <Link to={to}>{to}</Link> --- hard link: <a href={to}>{to}</a></li>;
const App = () => (
<BrowserRouter>
<ul>
<LinkLi to="/" />
<LinkLi to="/not-secure" />
<LinkLi to="/secure/first" />
<LinkLi to="/secure/first?test=pass" />
<LinkLi to="/secure/second" />
<LinkLi to="/secure/second?response_code=123" />
<LinkLi to="/secure/third" />
<LinkLi to="/secure/third?code=1" />
<LinkLi to="/secure/fourth" />
<LinkLi to="/secure/fourth/code=1/hello" />
</ul>
<Security
issuer="XXXXX"
clientId="XXXXX"
redirectUri="XXXXX"
pkce={true}
tokenManager={{ secure: true }}
>
<Switch>
<Route path="/implicit/callback" exact component={LoginCallback} />
<Route path="/not-secure" component={InsecureArea} />
<SecureRoute path="/secure" component={SecureArea} />
<Route component={RootArea} />
</Switch>
</Security>
</BrowserRouter>
);
ReactDOM.render(<App />, global.document.getElementById('root'));
First click around the soft links and notice that it (probably) seems to work as expected, where the bottom will show first, second, third etc. You should be able to click around the insecure routes, the secure routes, and it all looks good.
Now click one of the hard links that has code= somewhere in the query parameters. Now nothing will show for the secure routes. the insecure routes will still show as you navigate to them, but the secure route will never render anything again until you refresh the page or click another "hard" link.
Note: I have seen even the soft links trigger this issue occasionally with some auth sdk error, but it is hard to reproduce.
Extra information about the use case/user story you are trying to implement
Our current use case is processing payments, where we navigate away to enter payment information, and they send the user back to our application with a bunch of query params that indicate success and failure, and why. One of those query parameters is request_code=xxx which causes our application to fail.
Environment
- Package Version: 3.0.7
- Browser: Chrome
- OS: Mac catalina 10.15.7
- Node version (
node -v): 12.16.3
- Other: This does not seem to be an issue on okta-react 1.1.4 but I did not do an exhaustive search
I'm submitting this issue for the package(s):
I'm submitting a:
Current behavior
hard linking (deep link, using an anchor element) into the app with a query parameter that ends with
code=seems to break the app and nothing inside of aSecureRoutewill render, even after navigating to new routes. Soft linking around with react router usually works, but will also break sometimes.Expected behavior
query parameters should not cause SecureRoutes to render nothing.
Minimal reproduction of the problem with instructions
install okta-react 3.0.7, then use this as your react application
First click around the soft links and notice that it (probably) seems to work as expected, where the bottom will show first, second, third etc. You should be able to click around the insecure routes, the secure routes, and it all looks good.
Now click one of the hard links that has
code=somewhere in the query parameters. Now nothing will show for the secure routes. the insecure routes will still show as you navigate to them, but the secure route will never render anything again until you refresh the page or click another "hard" link.Note: I have seen even the soft links trigger this issue occasionally with some auth sdk error, but it is hard to reproduce.
Extra information about the use case/user story you are trying to implement
Our current use case is processing payments, where we navigate away to enter payment information, and they send the user back to our application with a bunch of query params that indicate success and failure, and why. One of those query parameters is
request_code=xxxwhich causes our application to fail.Environment
node -v): 12.16.3