From f817d39f8cbb292403b62eaa78726cd0cb05fe08 Mon Sep 17 00:00:00 2001 From: Alexey Immoreev Date: Tue, 3 Dec 2024 17:01:50 +0400 Subject: [PATCH] Improvement: add console redirect timeout warning --- proxy/src/auth/backend/console_redirect.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/proxy/src/auth/backend/console_redirect.rs b/proxy/src/auth/backend/console_redirect.rs index bf7a1cb0705f8..42a20cf3f566e 100644 --- a/proxy/src/auth/backend/console_redirect.rs +++ b/proxy/src/auth/backend/console_redirect.rs @@ -49,13 +49,15 @@ impl ReportableError for ConsoleRedirectError { } } -fn hello_message(redirect_uri: &reqwest::Url, session_id: &str) -> String { +fn hello_message(redirect_uri: &reqwest::Url, session_id: &str, duration: std::time::Duration) -> String { + let formatted_duration = humantime::format_duration(duration).to_string(); format!( concat![ "Welcome to Neon!\n", - "Authenticate by visiting:\n", + "Authenticate by visiting (will expire in {duration}):\n", " {redirect_uri}{session_id}\n\n", ], + duration = formatted_duration, redirect_uri = redirect_uri, session_id = session_id, ) @@ -118,7 +120,7 @@ async fn authenticate( }; let span = info_span!("console_redirect", psql_session_id = &psql_session_id); - let greeting = hello_message(link_uri, &psql_session_id); + let greeting = hello_message(link_uri, &psql_session_id, auth_config.console_redirect_confirmation_timeout); // Give user a URL to spawn a new database. info!(parent: &span, "sending the auth URL to the user");