Skip to content

Commit

Permalink
Enabled passwordless connection feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ongdisheng committed Jan 24, 2025
1 parent ce21e44 commit dd11fb8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
8 changes: 4 additions & 4 deletions ibis-server/app/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ class ClickHouseConnectionInfo(BaseModel):
port: SecretStr
database: SecretStr
user: SecretStr
password: SecretStr
password: SecretStr | None = None


class MSSqlConnectionInfo(BaseModel):
host: SecretStr
port: SecretStr
database: SecretStr
user: SecretStr
password: SecretStr
password: SecretStr | None = None
driver: str = Field(default="ODBC Driver 18 for SQL Server")
tds_version: str = Field(default="8.0", alias="TDS_Version")
kwargs: dict[str, str] | None = Field(
Expand All @@ -103,7 +103,7 @@ class MySqlConnectionInfo(BaseModel):
port: SecretStr
database: SecretStr
user: SecretStr
password: SecretStr
password: SecretStr | None = None
ssl_mode: SecretStr | None = Field(alias="sslMode", default=None)
ssl_ca: SecretStr | None = Field(alias="sslCA", default=None)
kwargs: dict[str, str] | None = Field(
Expand All @@ -120,7 +120,7 @@ class PostgresConnectionInfo(BaseModel):
port: SecretStr = Field(examples=[5432])
database: SecretStr
user: SecretStr
password: SecretStr
password: SecretStr | None = None


class SnowflakeConnectionInfo(BaseModel):
Expand Down
17 changes: 11 additions & 6 deletions ibis-server/app/model/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def get_clickhouse_connection(info: ClickHouseConnectionInfo) -> BaseBackend:
port=int(info.port.get_secret_value()),
database=info.database.get_secret_value(),
user=info.user.get_secret_value(),
password=info.password.get_secret_value(),
password=(info.password and info.password.get_secret_value()),
)

@classmethod
Expand All @@ -128,8 +128,11 @@ def get_mssql_connection(cls, info: MSSqlConnectionInfo) -> BaseBackend:
port=info.port.get_secret_value(),
database=info.database.get_secret_value(),
user=info.user.get_secret_value(),
password=cls._escape_special_characters_for_odbc(
info.password.get_secret_value()
password=(
info.password
and cls._escape_special_characters_for_odbc(
info.password.get_secret_value()
)
),
driver=info.driver,
TDS_Version=info.tds_version,
Expand All @@ -147,7 +150,7 @@ def get_mysql_connection(cls, info: MySqlConnectionInfo) -> BaseBackend:
port=int(info.port.get_secret_value()),
database=info.database.get_secret_value(),
user=info.user.get_secret_value(),
password=info.password.get_secret_value(),
password=(info.password and info.password.get_secret_value()),
**kwargs,
)

Expand All @@ -158,7 +161,7 @@ def get_postgres_connection(info: PostgresConnectionInfo) -> BaseBackend:
port=int(info.port.get_secret_value()),
database=info.database.get_secret_value(),
user=info.user.get_secret_value(),
password=info.password.get_secret_value(),
password=(info.password and info.password.get_secret_value()),
)

@staticmethod
Expand Down Expand Up @@ -189,7 +192,9 @@ def _escape_special_characters_for_odbc(value: str) -> str:
@staticmethod
def _create_ssl_context(info: ConnectionInfo) -> Optional[ssl.SSLContext]:
ssl_mode = (
info.ssl_mode.get_secret_value() if hasattr(info, "ssl_mode") else None
info.ssl_mode.get_secret_value()
if hasattr(info, "ssl_mode") and info.ssl_mode
else None
)

if ssl_mode == SSLMode.VERIFY_CA and not info.ssl_ca:
Expand Down

0 comments on commit dd11fb8

Please sign in to comment.