Hi,
We’ve implemented okta in our React app and it is working fine for Signons. But… once signed in the session never seems to expire.
I can see the response from https://…/api/v1/authn
has the expiresAt
field set correctly with the timestamp.
The React app looks roughly like this:
<Security
oktaAuth={oktaAuth}
onAuthRequired={customAuthHandlerCallback}
restoreOriginalUri={restoreOriginalUriCallback}
>
<UserProvider>
<AuthorizationProvider>
<ProtectedPage>
<Component {...pageProps} />
</ProtectedPage>
</AuthorizationProvider>
</UserProvider>
<Notifications />
<ReactQueryDevtools initialIsOpen={false} />
</Security>
We aren’t using SecureRoute
because we’re using next router instead of react router.
ProtectedPage
is sort of our own version of SecureRoute
and uses const { authState } = useOktaAuth()
and authState.isAuthenticated
in a useEffect
to check if we should redirect to login.
authState.isAuthenticated
never changes after the first login, always returns true even long after the timeout period has passed.
I’m sure I’ve missed something crucial, some call to check if the session is still valid or something, but can’t see what I’ve missed. (And couldn’t see SecureRoute
doing anything more than we do.)
What are the likely candidates?
Thanks