Repository navigation
fix(frontend): preserve redirect target through SSO login - #13270
Conversation
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
The redirect target set by ProtectedRoute travels in react-router state, which does not survive the full page navigation through the identity provider. After the SSO round trip users always landed on /home. Forward the target through the flow as a 'next' query param on the allauth callback URL instead, and recover it on the /logged-in page. Falls back to /home when no valid in-app path is present.
|
I see there's 4 failing checks. I don't think they're related to my change, but maybe I'm not connecting the dots. |
|
@newAM they are not, already working on a fix |
|
fix in #13273; it looks like your code is not the cause for the failure here |
| // the way back. Forward it through the flow instead, appended to the | ||
| // callback URL allauth redirects the browser back to - LoggedIn.tsx | ||
| // picks the 'next' parameter back up once the login completes. | ||
| const next = `${redirect?.redirectUrl ?? ''}${redirect?.queryParams ?? ''}`; |
There was a problem hiding this comment.
against which sso provider did you test this? i am having issues getting this working with arzure ad via (custom) saml provider
There was a problem hiding this comment.
I tried it out with Kanidm, but I'm realizing there's gaps in my understanding, and therefore testing.
I tested with curl because that's what I've used in the past for SSO testing, and I had the script on-hand to navigate Kanidm with curl, but those webapps had little to no javascript in the frontend. My caveman curl approach worked... but missed that this doesn't work for the real case of a real web browser because the SSO flow is started by javascript.
I opened #13279 to fix this.
Sorry about that. My background is in embedded microcontrollers, still learning my way around frontend.
matmair
left a comment
There was a problem hiding this comment.
this looks correct and I do not see a security issue here even after thinking a bit about it;
i would appreciate if you could extend the sso forntend test to also test this just to ensure this keeps on working.
Clean patch, great effort; thank you!
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
…13276) The redirect target set by ProtectedRoute travels in react-router state, which does not survive the full page navigation through the identity provider. After the SSO round trip users always landed on /home. Forward the target through the flow as a 'next' query param on the allauth callback URL instead, and recover it on the /logged-in page. Falls back to /home when no valid in-app path is present. (cherry picked from commit b9b4679) Co-authored-by: Alex Martens <[email protected]> Co-authored-by: Matthias Mair <[email protected]> Co-authored-by: Oliver <[email protected]>
The redirect target set by ProtectedRoute travels in react-router state, which does not survive the full page navigation through the identity provider. After the SSO round trip users always landed on /home.
Forward the target through the flow as a 'next' query param on the allauth callback URL instead, and recover it on the /logged-in page. Falls back to /home when no valid in-app path is present.
I have been using inventree with
inventree-part-import, which provides a URL after adding a part. However I always landed on the home page, never the newly added part. This is my attempt to fix that behaviour.