Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ibis): Enabled Passwordless Connection for Data Sources BE #1043

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading