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>,
)
| 775 | /// Helper for password-based authentication using AdapterClient |
| 776 | /// and returns an authenticated session. |
| 777 | async 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> |
| 785 | where |
| 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)] |
| 816 | enum State { |
no test coverage detected