-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handleIncomingRedirect restore all query parameters but shouldn't #1473
Comments
Hi @scenaristeur, the query parameters are not lost, but you'll have to restore them yourself, since routing is app-specific — solid-client-authn-browser cannot know how to do so for you. How to do so is described in the Use Session Restore Event Handler docs, but basically, you can pass a callback to Please let us know whether that resolves your issue. |
thxs @Vinnl I got it working |
I got it working, but their is something that i don't understand : see it here https://scenaristeur.github.io/booklice/
if i run to /about then login all params url are send to authentication. 2021-07-03.14-41-37.mp4 |
Hi @scenaristeur, I reproduced the scenario you described above, and I indeed get sent back to So the URL given to you by solid-client-authn-browser is correct. I am not too familiar with Vue, but it appears that the way you restore that URL isn't quite correct. Given that
results in |
I need to keep the ?query parameter as the app is a PWA, progressive web app that you can install on your mobile phone and use to share your from other app https://web.dev/web-share-target/, sending some parameters like
nevermind, for what is my problem here, and the next demo, i've removed that query parameter in the redirection but it strange that the /about always come back if i login on this page, then close the app and reopen on the / rootbase path, i always be redirected to the url + params with the one i've been logged in. even if i have another route, or other query parameters, ALWAYS the ones when i've logged in come back, so i don't think this is a vuejs-side issue. Where are those parameters stored ? on the server or on the browser ? 2021-07-07.11-09-29.mp4 |
If you open your app at The value of |
Hi @Vinnl , really sorry, but there is always something going wrong, I absolutely don't understand why 2021-07-15.00-44-35.mp4same thing but other way open game-sync, then connect, then open booklice and redirected to game-sync (the page where i've logged in) 2021-07-15.00-51-28.mp4 |
Unfortunately cookies are always shared across an origin ( Since you're using GitHub Pages, you could look at creating different GitHub organizations for your different projects if you don't want that. |
Thanks for this @Vinnl . I had read this tutorial page which introduced handleIncomingRedirect, but I did not see the more detailed page you have linked to. I think we should either add Also, I'm not sure, but I think the behaviour seems unnecessary? It would appear to me we could set a flag on the first session restore so the subsequent ones do not use this initial redirectURL, and or the |
Specifically I used this code:
|
Pinging @NSeydoux to respond to that, since I no longer work at Inrupt and don't really have time to look into this :) |
So I had to use the following code as I have two separate apps running on the same domain. One at Instead I had to add the following code: handle_login.ts
index.tsx
|
@AJamesPhillips happy to see some other with the same problem and that you found a potential workaround, but i basically think that the redirect target should by default be the page where the user were before the session check. Not the one where he was when he logged in for the first time (can be two hours ago !). And we should be able to host many apps on the same domain in subfolder or in subdomains |
@Vinnl , |
@scenaristeur I don't understand - that already is the case? SCA doesn't restore the old parameters; it merely remembers them for you so you can restore them yourself if you wish. (And it by definition can't redirect the user to the page they were at, because it's not SCA that does the redirection - it's the Solid identity provider, and that only knows the page the user was on when they first logged in. So all SCA can do for you is remember the page the user was coming from, and inform your app when the Solid identity provider redirects the user back. But only the app is then in a position to actually restore the parameters if needed (or not, if not).) |
I thought more about this, specifically the desire to have multiple applications on a domain either under different subdomains, paths, or perhaps even determined by query parameters or the hash. From a security point of view if you signed in at: good_app.github.io and latter got sent a link to evil_app.github.io then you obviously do not want the second to have the first's access rights. And I think this is achieved by the call to Using this redirect to the first signin url as a default behaviour I think makes sense and has to stay (from a security) point of view? But also, and I'm not certain, but when you initially authorise an application, if the application could ask for a scope for redirects then that could allow the Solid identity provider to "safely" redirect you to a "session restoring" URL that's different from your initial sign in URL? i.e.:
Would that work or does it have some problems / other disadvantages in it? |
Sorry I took so much time to reply this issue.
I think that's an excellent starting point: why is the library behaving the way it is currently ? The problem we want to solve is the following: a user is logged in a SPA, which means routing happens client-side. The user logs is on some page, Note that when calling Then, the user navigates client-side to a different page, The problem we want to solve happens at this point: for the authentication to be completely silent (transparent to the user), the client must be known to the OIDC provider, so we have to reuse the same client ID/secret as previously used, even if they were dynamically registered. Which means we also MUST reuse the original redirect IRI (in our case So @scenaristeur, part of the issue is that the redirect IRI must exactly match, query parameters included. Unfortunately, I don't see another approach besides overriding the query parameters in the callback passed to |
@AJamesPhillips what you propose here is a very good point:
Asking for such a scope is done via using a proper Client Identifier, and not going through Dynamic Client Registration, as explained on this page. In your client profile document, you may specify as many redirect IRIs as you wish, in which case we could consider using the refreshed IRI as a redirect IRI too, which already carries an assumption that any page in your application the user may refresh is a valid redirect IRI. This for instance does not work for IRIs with dynamic parameters, such as the one @scenaristeur described. One possible workaround would be to provide a transformation callback that gets applied to the IRI in order to compute the associated redirect IRI. This way, one could:
in this case, we could use the current IRI as a redirect IRI if the user either provided an IRI transformation callback and/or is using a Client Identifier. I'm a bit concerned this would get rather involved and bug-prine though, so I'm interested in your feedbacks as you're hitting such issues yourselves. |
@NSeydoux thank you for the response. There's obviously a lot of complexity going on here but I think there's some low hanging fruit. Firstly it would be good to clarify the role of
(I would submit a tentative PR but I can't find where that documentation is on Github)
I think I've misunderstood you as looking at the code I can't see a list of redirectIRIs supported? If possible it would be great to extend the tutorial / docs with: "providing a list of |
And thank you for your comments here @NSeydoux . If I correctly understand what we're all saying: One of the most extreme cases of where this seems to currently fail is where we have different applications on the same top level domain. Currently I do not think the use of a proper Client Identifier and Browser's do however support limitation of cookie scope to subdomains right?... |
indeed, when logging in, only one redirect IRI may be specified, because this gives the OIDC provider an unambiguous information on where the user should be redirected after they log in. If the client is dynamically registered (the default behaviour), then only this redirect IRI will eve be authorized for the given client instance. This constraint stems from the OIDC specification. However, the Solid-OIDC specification defines a new, Solid-specific way of approaching this by allowing the client to host its own profile document, where it can define a list of valid redirect IRIs instead of one. Note that the redirect IRI used at login time still needs to exactly match one of these pre-registered IRIs, IRI patterns are not authorized. Also, to clarify, any call to The problem with having multiple applications on the same origin is that they would share the same local storage (rather than cookies being shared, since cookies in this case only get involved at the OIDC provider level), which is used to detect whether a session is currently active and to kickstart the silent authentication process if applicable. This means only one redirect IRI is expected by origin, which is the problematic assumption we made. However, if we remove this assumption, the problem becomes: how can Overall, there seems to have two discussions going on in this issue:
|
yes there are two issues. thxs all, i'll try what was said with query parameters. and follow #1647 for the second |
Bug description
handleIncomingRedirect with restorePreviousSession restore all query parameters but i don't want
I want the user is logged back when he visits the app and has already logged but not to restore all the query parameters that were in the url when he loggin.
so, to restore his session, i use
import * as sc from '@inrupt/solid-client-authn-browser' ... sc.handleIncomingRedirect({restorePreviousSession : true})
code here https://github.com/scenaristeur/booklice/blob/9f15b5c81878fc1551b4513518b64b107e4f6276/src/plugins/vue-solid.js#L63
But the query parameters are lost when using "restorePreviousSession"
if the url is
http://127.0.0.1:8080/?url=https://the.url.com&title=bookmark&text=blabla
when the user login,the next time he visits the app with some other query parameters, like
http://127.0.0.1:8080/?url=https://another_url.com&title=something_else&text=tiptop
but the new query parameters are replaced with the one that were registered when he logged in.To Reproduce
Expected result
the redirect should be with ?url=https://another_url.com&title=something_else&text=tiptop
Actual result
the redirect is always with ?url=the.url.com&title=bookmark&text=blabla
Environment
Additional information
Another redirection is used to allow hosting on github pages
but it has never been a problem, it was already used on poPock with solid-auth-client https://scenaristeur.github.io/solid-vue-panes/bookmarks?title=Popock&url=https%3A%2F%2Fscenaristeur.github.io%2Fsolid-vue-panes%2F&text=My%20favorite%20Pod%20Manager
The text was updated successfully, but these errors were encountered: