25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
use std::fmt::Debug;
#[derive(Clone, PartialEq, Eq)]
pub struct SqlServerAuth {
user: String,
password: String,
}
impl SqlServerAuth {
pub(crate) fn user(&self) -> &str {
&self.user
}
pub(crate) fn password(&self) -> &str {
&self.password
}
}
impl Debug for SqlServerAuth {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("SqlServerAuth")
.field("user", &self.user)
.field("password", &"<HIDDEN>")
.finish()
}
}
#[derive(Clone, PartialEq, Eq)]
#[cfg(any(all(windows, feature = "winauth"), doc))]
#[cfg_attr(feature = "docs", doc(all(windows, feature = "winauth")))]
pub struct WindowsAuth {
pub(crate) user: String,
pub(crate) password: String,
pub(crate) domain: Option<String>,
}
#[cfg(any(all(windows, feature = "winauth"), doc))]
#[cfg_attr(feature = "docs", doc(all(windows, feature = "winauth")))]
impl Debug for WindowsAuth {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("WindowsAuth")
.field("user", &self.user)
.field("password", &"<HIDDEN>")
.field("domain", &self.domain)
.finish()
}
}
/// Defines the method of authentication to the server.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum AuthMethod {
/// Authenticate directly with SQL Server.
SqlServer(SqlServerAuth),
/// Authenticate with Windows credentials.
#[cfg(any(all(windows, feature = "winauth"), doc))]
#[cfg_attr(feature = "docs", doc(cfg(all(windows, feature = "winauth"))))]
Windows(WindowsAuth),
/// Authenticate as the currently logged in user. On Windows uses SSPI and
/// Kerberos on Unix platforms.
#[cfg(any(
all(windows, feature = "winauth"),
all(unix, feature = "integrated-auth-gssapi"),
doc
))]
#[cfg_attr(
feature = "docs",
doc(cfg(any(windows, all(unix, feature = "integrated-auth-gssapi"))))
)]
Integrated,
/// Authenticate with an AAD token. The token should encode an AAD user/service principal
/// which has access to SQL Server.
AADToken(String),
#[doc(hidden)]
None,
}
impl AuthMethod {
/// Construct a new SQL Server authentication configuration.
pub fn sql_server(user: impl ToString, password: impl ToString) -> Self {
Self::SqlServer(SqlServerAuth {
user: user.to_string(),
password: password.to_string(),
})
}
/// Construct a new Windows authentication configuration.
#[cfg(any(all(windows, feature = "winauth"), doc))]
#[cfg_attr(feature = "docs", doc(cfg(all(windows, feature = "winauth"))))]
pub fn windows(user: impl AsRef<str>, password: impl ToString) -> Self {
let (domain, user) = match user.as_ref().find('\\') {
Some(idx) => (Some(&user.as_ref()[..idx]), &user.as_ref()[idx + 1..]),
_ => (None, user.as_ref()),
};
Self::Windows(WindowsAuth {
user: user.to_string(),
password: password.to_string(),
domain: domain.map(|s| s.to_string()),
})
}
/// Construct a new configuration with AAD auth token.
pub fn aad_token(token: impl ToString) -> Self {
Self::AADToken(token.to_string())
}
}