(
&self,
client: &mut C,
_message: PgWireFrontendMessage,
)
| 488 | #[async_trait] |
| 489 | impl NoopStartupHandler for NodeDbPgHandler { |
| 490 | async fn post_startup<C>( |
| 491 | &self, |
| 492 | client: &mut C, |
| 493 | _message: PgWireFrontendMessage, |
| 494 | ) -> PgWireResult<()> |
| 495 | where |
| 496 | C: ClientInfo + Sink<PgWireBackendMessage> + Unpin + Send, |
| 497 | C::Error: Debug, |
| 498 | PgWireError: From<<C as Sink<PgWireBackendMessage>>::Error>, |
| 499 | { |
| 500 | if !matches!(self.auth_mode, AuthMode::Trust) { |
| 501 | return Ok(()); |
| 502 | } |
| 503 | |
| 504 | let username = client |
| 505 | .metadata() |
| 506 | .get("user") |
| 507 | .cloned() |
| 508 | .unwrap_or_else(|| "unknown".to_string()); |
| 509 | |
| 510 | if self |
| 511 | .state |
| 512 | .credentials |
| 513 | .to_identity(&username, AuthMethod::Trust) |
| 514 | .is_some() |
| 515 | { |
| 516 | return Ok(()); |
| 517 | } |
| 518 | |
| 519 | // Bootstrap: an empty credential store admits the first connecting |
| 520 | // user as a tenant-1 superuser and persists them so subsequent |
| 521 | // queries on the same connection (and any reconnect) resolve |
| 522 | // through the normal strict path. |
| 523 | if self.state.credentials.is_empty() { |
| 524 | let _ = self.state.credentials.create_user( |
| 525 | &username, |
| 526 | "", |
| 527 | TenantId::new(1), |
| 528 | vec![Role::Superuser], |
| 529 | ); |
| 530 | return Ok(()); |
| 531 | } |
| 532 | |
| 533 | let source = client.socket_addr().to_string(); |
| 534 | self.state.audit_record( |
| 535 | AuditEvent::AuthFailure, |
| 536 | None, |
| 537 | &source, |
| 538 | &format!("trust auth: user '{username}' does not exist"), |
| 539 | ); |
| 540 | Err(PgWireError::UserError(Box::new(ErrorInfo::new( |
| 541 | "FATAL".to_owned(), |
| 542 | "28000".to_owned(), |
| 543 | format!("trust auth: user '{username}' does not exist"), |
| 544 | )))) |
| 545 | } |
| 546 | } |
nothing calls this directly
no test coverage detected