Skip to content

Commit

Permalink
record info for link auth
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Jan 29, 2024
1 parent 5f1714f commit 24cac26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion proxy/src/auth/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ impl<'a> BackendType<'a, ComputeUserInfoMaybeEndpoint> {
Link(url) => {
info!("performing link authentication");

let node_info = link::authenticate(&url, client).await?;
let node_info = link::authenticate(ctx, &url, client).await?;

(
CachedNodeInfo::new_uncached(node_info),
Expand Down
5 changes: 5 additions & 0 deletions proxy/src/auth/backend/link.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{
auth, compute,
console::{self, provider::NodeInfo},
context::RequestMonitoring,
error::UserFacingError,
stream::PqStream,
waiters,
Expand Down Expand Up @@ -54,6 +55,7 @@ pub fn new_psql_session_id() -> String {
}

pub(super) async fn authenticate(
ctx: &mut RequestMonitoring,
link_uri: &reqwest::Url,
client: &mut PqStream<impl AsyncRead + AsyncWrite + Unpin>,
) -> auth::Result<NodeInfo> {
Expand Down Expand Up @@ -94,6 +96,9 @@ pub(super) async fn authenticate(
.dbname(&db_info.dbname)
.user(&db_info.user);

ctx.set_user(db_info.user.into());
ctx.set_project(db_info.aux.clone());

// Backwards compatibility. pg_sni_proxy uses "--" in domain names
// while direct connections do not. Once we migrate to pg_sni_proxy
// everywhere, we can remove this.
Expand Down

0 comments on commit 24cac26

Please sign in to comment.