(
&self,
client: &mut C,
message: PgWireFrontendMessage,
)
| 274 | #[async_trait] |
| 275 | impl StartupHandler for AuthStartup { |
| 276 | async fn on_startup<C>( |
| 277 | &self, |
| 278 | client: &mut C, |
| 279 | message: PgWireFrontendMessage, |
| 280 | ) -> PgWireResult<()> |
| 281 | where |
| 282 | C: ClientInfo + futures::sink::Sink<PgWireBackendMessage> + Unpin + Send + Sync, |
| 283 | C::Error: Debug, |
| 284 | PgWireError: From<<C as Sink<PgWireBackendMessage>>::Error>, |
| 285 | { |
| 286 | match self { |
| 287 | AuthStartup::Trust(handler) => { |
| 288 | <NodeDbPgHandler as StartupHandler>::on_startup(handler, client, message).await?; |
| 289 | |
| 290 | let username = client |
| 291 | .metadata() |
| 292 | .get("user") |
| 293 | .cloned() |
| 294 | .unwrap_or_else(|| "unknown".to_string()); |
| 295 | let source = client.socket_addr().to_string(); |
| 296 | handler.state.audit_record( |
| 297 | AuditEvent::AuthSuccess, |
| 298 | None, |
| 299 | &source, |
| 300 | &format!("trust auth: {username}"), |
| 301 | ); |
| 302 | |
| 303 | // Bind the `database` startup parameter to the session store. |
| 304 | // `psql -d <name>` sets this key in the pgwire StartupMessage; |
| 305 | // we resolve it once at handshake time so every query on this |
| 306 | // connection executes in the declared database context. |
| 307 | let addr = client.socket_addr(); |
| 308 | bind_startup_database(client, &addr, handler); |
| 309 | |
| 310 | Ok(()) |
| 311 | } |
| 312 | AuthStartup::Scram { |
| 313 | sasl, |
| 314 | state, |
| 315 | handler, |
| 316 | } => { |
| 317 | let was_in_auth = matches!( |
| 318 | client.state(), |
| 319 | pgwire::api::PgWireConnectionState::AuthenticationInProgress |
| 320 | ); |
| 321 | |
| 322 | let result = sasl.on_startup(client, message).await; |
| 323 | |
| 324 | let username = client |
| 325 | .metadata() |
| 326 | .get("user") |
| 327 | .cloned() |
| 328 | .unwrap_or_else(|| "unknown".to_string()); |
| 329 | let source = client.socket_addr().to_string(); |
| 330 | |
| 331 | match &result { |
| 332 | Ok(()) |
| 333 | if was_in_auth |
nothing calls this directly
no test coverage detected