We want to provide users with a link that redirects them to a specific notebook after logging in. However, the next parameter in the URL is lost after a successful login, and the user is taken to the default page instead.
Is there a way to preserve the next parameter so that users are redirected correctly? Alternatively, would using /user-redirect/... be a better approach?
Quite likely, yes. If the URL you want users to arrive at is a URL on their own server once it’s running, that’s precisely what /user-redirect/ is for. e.g. https://jupyterhub.example.edu/user-redirect/lab/tree/subdir/some-notebook.ipynb should ultimately take users to subdir/some-notebook.ipynb in their server, logging in if they aren’t logged in, and starting their server if it’s not running.
If this is more or less a single-purpose Hub, you could also make this your “default url” that users go to after login even without a specially prepared link, rather than the Hub home page:
next on the login page is generally preserved through the login process, but setting it directly would be unusual. Usually you share a link directly to the target resource, and next is populated during the redirect to login if not already logged in. What is the URL that you are using for next, and what URL are you sharing with ?next=...? Can you share some logs? There is some sanitization of next to make sure you cannot redirect outside jupyterhub, and it’s possible an absolute URL (as opposed to purely a path) might get rejected. These sanitizations may be why next is lost and if so, it should be logged.
The problem here is, that redirect to OIDC authentication proxy discards all parameters in URL when redirected back to the originator (hub page). So the question basically is, how to solve this problem for Jupyterhub. Working approach is to store URL parameters into session cookie and pick them once returned from the oauth proxy.
Usecase here is to provide a URL with parameters, e.g., notebook name to be opened, like personalised URL for a student homework. Studen opens the link, it redirect him to oauth for credential, redirects back and the original parameters are currently lost.
So is there already any support in the Jupyterhub code, to remember parameters in the session cookie, where to go after login?