Auth: land back on the /app/<name> the user came for after login/signup#3435
Open
jelveh wants to merge 1 commit into
Open
Auth: land back on the /app/<name> the user came for after login/signup#3435jelveh wants to merge 1 commit into
jelveh wants to merge 1 commit into
Conversation
Landing on /app/<name> logged-out and authenticating used to dump the user at the root dashboard on several paths, losing the app they came for: - OIDC login/signup only sent return_to for /desktop and /dashboard (and the backend whitelist only accepted those two), so OIDC from an app landing redirected to /. - UIWindowSignup defaulted its post-success redirect to /, so password signup reached via the session list, ?action=signup, or in-app signup prompts (IPC.js) lost the app. - OIDC error redirects always went to /?action=..., so a recovered attempt (e.g. account-not-found bounced to signup) also lost the app. New helpers in src/gui/src/helpers/auth_redirect.js: - get_auth_redirect_url(): stay on the page auth started from; /action/* pages go to /; strips action/auth_error/message/ request_code so the reload doesn't re-open the auth window or pass auth params through to the app as launch args. - get_oidc_return_to(): pathname when whitelistable, now including /app/<name> (trailing slash normalized). Backend (OIDCController): - Shared isWhitelistedReturnPath() accepts /desktop, /dashboard, and /app/<name> (charset mirrors APP_NAME_REGEX — no open redirect). - buildErrorRedirectUrl() lands on the whitelisted originating page from the signed state's redirect_uri instead of always /. Tested: 47/47 OIDC controller tests pass (4 new: return_to accepted/ rejected on start, success redirect to /app/<name>, error redirect keeping /app/<name>); verified live on local dev for first-visit temp user, password signup (incl. email-confirmation gate), and password login — all land on /app/camera with the app open.
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
If a logged-out user lands on an app URL (
/app/<name>) and has to log in or sign up, several auth paths dumped them at the root dashboard afterward instead of the app they came for:return_tofor/desktopand/dashboard, and the backend whitelist only accepted those two — OIDC from an app landing always redirected to/.UIWindowSignupdefaulted its post-success redirect to/, so signup reached via the session list,?action=signup, or in-app signup prompts (IPC.js) lost the app./?action=…, so even after the user recovered (e.g. account-not-found bounced to signup, then signed up) the app was gone.(Password login already redirected back to the current URL; that path is unchanged in behavior.)
Changes
New
src/gui/src/helpers/auth_redirect.jsget_auth_redirect_url()— post-auth destination: stay on the page auth started from; standalone/action/*pages go to/; stripsaction/auth_error(+ theirmessage/request_codecompanions) so the reload doesn't re-open the auth window or forward auth params to the app as launch args.get_oidc_return_to()— thereturn_toto send when starting an OIDC flow; now includes/app/<name>landings (trailing slash normalized).UIWindowLogin.js/UIWindowSignup.js— both use the helpers for their defaultredirect_urland OIDCreturn_to.OIDCController.tsisWhitelistedReturnPath()accepting/desktop,/dashboard, and/app/<name>(charset mirrorsAPP_NAME_REGEX:[a-zA-Z0-9_-]{1,100}— still a strict whitelist, no open-redirect surface; the callback's same-origin clamp is unchanged).buildErrorRedirectUrl()now lands error redirects on the whitelisted originating page (from the signed state'sredirect_uri, path re-checked against the whitelist) instead of always/. Popup-flow error URLs are unchanged.Testing
return_toaccepted (/app/<name>) and rejected (extra segments, bad charset, >100 chars,//evil.test) on start; success redirect to/app/<name>; error redirect keeping/app/<name>.tsc --noEmitclean; GUI webpack build clean./app/camerawith the app open. OIDC not exercised live (no provider configured locally); covered by the unit tests above.