AxaFrance / oidc-client

Light, Secure, Pure Javascript OIDC (Open ID Connect) Client. We provide also a REACT wrapper (compatible NextJS, etc.).
MIT License
584 stars 159 forks source link

lost history props #419

Closed samuel-gomez-axa closed 2 years ago

samuel-gomez-axa commented 4 years ago

Issue and Steps to Reproduce

I'm using the HOC withOidcSecure on my routes and renderProps to pass router props.

image

Since i updated to the v3.0.9-alpha.0 from 2.0.8

i'm losing history prop on pages.

i tested to take of the HOC withOidcSecure and i retreive all router props on my pages.

Versions v3.0.9-alpha.0

Screenshots

props received on my page WITH withOidcSecure

image

props received on my page WITHOUT withOidcSecure

withoutHOC

Expected

Actual

Additional Details

youf-olivier commented 4 years ago

Can you show me your global layout ? With your Router and your React oidc provider ?

samuel-gomez-axa commented 4 years ago

Here my App.js file with AuthenticationProvider

image

Thanks for your help

samuel-gomez-axa commented 4 years ago

i tested to rollback to v2.0.8 and the bug doesn't exist anymore. I also noticed that there was a redirection problem on the callback on my router, this may be related. if this problem persists after fixing this bug, I will do another issue

youf-olivier commented 4 years ago

Since few versions React Oidc is React Router Agnostic. Can you try to switch Router Provider and React OIdc line ?

Like :

<authenticationProvider {...} >
   <router {...} >
   </router>
<authenticationProvider />

React oidc uses his own history object. He possibly override or hide the history props.

samuel-gomez-axa commented 4 years ago

ok thank you, i try it

samuel-gomez-axa commented 4 years ago

The switch doesn't fix the bug. I think the bug comes from this file. : AuthenticationConsumers.js

` export const withOidcSecurewithRouter = WrappedComponent => ({ location, history, authenticateUser: authenticateUserInternal, getUserManager: getUserManagerInternal, ...otherProps }) => { const { oidcUser, authenticating, isEnabled } = useOidcSecure( authenticateUserInternal, getUserManagerInternal, location, history ); const requiredAuth = useMemo(() => isRequireAuthentication(oidcUser, false) && isEnabled, [ isEnabled, oidcUser, ]);

const AuthenticatingComponent = authenticating || Authenticating; return requiredAuth ? : <WrappedComponent {...otherProps} />; };`

In this HOC, the location and history have been spread but not re-injected in WrappedComponent.

What do you think about this ?

youf-olivier commented 4 years ago

You're probably right

guillaume-chervet commented 2 years ago

I this this is fixed by v4. May i close the issue @samuel-gomez-axa ?