MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / on_startup

Method on_startup

nodedb/src/control/server/pgwire/factory.rs:276–387  ·  view source on GitHub ↗
(
        &self,
        client: &mut C,
        message: PgWireFrontendMessage,
    )

Source from the content-addressed store, hash-verified

274#[async_trait]
275impl 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

Callers

nothing calls this directly

Calls 9

bind_startup_databaseFunction · 0.85
ArcAuditEmitterClass · 0.85
to_stringMethod · 0.80
socket_addrMethod · 0.80
audit_recordMethod · 0.80
record_login_successMethod · 0.80
record_login_failureMethod · 0.80
getMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected