Skip to content

Commit

Permalink
Improvement: add console redirect timeout warning
Browse files Browse the repository at this point in the history
  • Loading branch information
luixo committed Dec 3, 2024
1 parent dcb24ce commit f817d39
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions proxy/src/auth/backend/console_redirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit f817d39

Please sign in to comment.