MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / authenticate_with_password

Function authenticate_with_password

src/pgwire/src/protocol.rs:777–813  ·  view source on GitHub ↗

Helper for password-based authentication using AdapterClient and returns an authenticated session.

(
    conn: &FramedConn<A>,
    adapter_client: &mz_adapter::Client,
    user: String,
    password: Password,
    conn_uuid: Uuid,
    helm_chart_version: Option<String>,
)

Source from the content-addressed store, hash-verified

775/// Helper for password-based authentication using AdapterClient
776/// and returns an authenticated session.
777async fn authenticate_with_password<A>(
778 conn: &FramedConn<A>,
779 adapter_client: &mz_adapter::Client,
780 user: String,
781 password: Password,
782 conn_uuid: Uuid,
783 helm_chart_version: Option<String>,
784) -> Result<Session, PasswordRequestError>
785where
786 A: AsyncRead + AsyncWrite + AsyncReady + Send + Sync + Unpin,
787{
788 let authenticated = match adapter_client.authenticate(&user, &password).await {
789 Ok(authenticated) => authenticated,
790 Err(err) => {
791 warn!(?err, "pgwire connection failed authentication");
792 return Err(PasswordRequestError::InvalidPasswordError(
793 ErrorResponse::fatal(SqlState::INVALID_PASSWORD, "invalid password"),
794 ));
795 }
796 };
797
798 let session = adapter_client.new_session(
799 SessionConfig {
800 conn_id: conn.conn_id().clone(),
801 uuid: conn_uuid,
802 user,
803 client_ip: conn.peer_addr().clone(),
804 external_metadata_rx: None,
805 helm_chart_version,
806 authenticator_kind: mz_auth::AuthenticatorKind::Password,
807 groups: None,
808 },
809 authenticated,
810 );
811
812 Ok(session)
813}
814
815#[derive(Debug)]
816enum State {

Callers 1

runFunction · 0.85

Calls 5

new_sessionMethod · 0.80
authenticateMethod · 0.45
cloneMethod · 0.45
conn_idMethod · 0.45
peer_addrMethod · 0.45

Tested by

no test coverage detected