File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
packages/nvidia_nat_core/src/nat/front_ends/fastapi Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 4545 (function () {
4646 var returnTo = RETURN_URL_PLACEHOLDER;
4747 if (returnTo) {
48- window.location.replace(returnTo);
48+ var url = new URL(returnTo);
49+ url.searchParams.set('oauth_auth_error', 'cancelled');
50+ window.location.replace(url.toString());
4951 } else {
5052 window.history.back();
5153 }
6062
6163
6264def build_auth_redirect_cancelled_html (return_url : str | None = None ) -> str :
63- """Build the authorization-cancelled HTML page.
64-
65- Redirects back to the UI without the ``oauth_auth_completed`` query
66- parameter so the UI's cancellation-message branch handles it.
65+ """Build the same-page authorization-cancelled HTML page.
6766
6867 Args:
69- return_url: The UI origin to navigate back to. Falls back to
70- ``window.history.back()`` when not provided.
68+ return_url: The URL to redirect to after cancellation. When
69+ provided the page navigates there immediately with an ``oauth_auth_error``
70+ query parameter so the UI can detect the cancellation and avoid a
71+ pre-auth redirect loop; otherwise it falls back to ``window.history.back()``.
7172
7273 Returns:
7374 An HTML string for the post-cancellation redirect page.
Original file line number Diff line number Diff line change @@ -104,7 +104,12 @@ async def _websocket_endpoint(websocket: WebSocket):
104104 token_store = worker ._oauth_token_store ,
105105 session_id = nat_session_id )
106106 handler .set_flow_handler (flow_handler )
107- await flow_handler .pre_authenticate (worker ._config .authentication )
107+ skip_pre_auth = websocket .query_params .get ("skip_pre_auth" ) == "true"
108+ if not skip_pre_auth :
109+ try :
110+ await flow_handler .pre_authenticate (worker ._config .authentication )
111+ except Exception as e :
112+ logger .info ("Pre-authentication did not complete: %s" , e )
108113 await handler .run ()
109114
110115 return _websocket_endpoint
You can’t perform that action at this time.
0 commit comments