Skip to content

Commit dd11fb8

Browse files
committed
Enabled passwordless connection feature
1 parent ce21e44 commit dd11fb8

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

ibis-server/app/model/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ class ClickHouseConnectionInfo(BaseModel):
8282
port: SecretStr
8383
database: SecretStr
8484
user: SecretStr
85-
password: SecretStr
85+
password: SecretStr | None = None
8686

8787

8888
class MSSqlConnectionInfo(BaseModel):
8989
host: SecretStr
9090
port: SecretStr
9191
database: SecretStr
9292
user: SecretStr
93-
password: SecretStr
93+
password: SecretStr | None = None
9494
driver: str = Field(default="ODBC Driver 18 for SQL Server")
9595
tds_version: str = Field(default="8.0", alias="TDS_Version")
9696
kwargs: dict[str, str] | None = Field(
@@ -103,7 +103,7 @@ class MySqlConnectionInfo(BaseModel):
103103
port: SecretStr
104104
database: SecretStr
105105
user: SecretStr
106-
password: SecretStr
106+
password: SecretStr | None = None
107107
ssl_mode: SecretStr | None = Field(alias="sslMode", default=None)
108108
ssl_ca: SecretStr | None = Field(alias="sslCA", default=None)
109109
kwargs: dict[str, str] | None = Field(
@@ -120,7 +120,7 @@ class PostgresConnectionInfo(BaseModel):
120120
port: SecretStr = Field(examples=[5432])
121121
database: SecretStr
122122
user: SecretStr
123-
password: SecretStr
123+
password: SecretStr | None = None
124124

125125

126126
class SnowflakeConnectionInfo(BaseModel):

ibis-server/app/model/data_source.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def get_clickhouse_connection(info: ClickHouseConnectionInfo) -> BaseBackend:
118118
port=int(info.port.get_secret_value()),
119119
database=info.database.get_secret_value(),
120120
user=info.user.get_secret_value(),
121-
password=info.password.get_secret_value(),
121+
password=(info.password and info.password.get_secret_value()),
122122
)
123123

124124
@classmethod
@@ -128,8 +128,11 @@ def get_mssql_connection(cls, info: MSSqlConnectionInfo) -> BaseBackend:
128128
port=info.port.get_secret_value(),
129129
database=info.database.get_secret_value(),
130130
user=info.user.get_secret_value(),
131-
password=cls._escape_special_characters_for_odbc(
132-
info.password.get_secret_value()
131+
password=(
132+
info.password
133+
and cls._escape_special_characters_for_odbc(
134+
info.password.get_secret_value()
135+
)
133136
),
134137
driver=info.driver,
135138
TDS_Version=info.tds_version,
@@ -147,7 +150,7 @@ def get_mysql_connection(cls, info: MySqlConnectionInfo) -> BaseBackend:
147150
port=int(info.port.get_secret_value()),
148151
database=info.database.get_secret_value(),
149152
user=info.user.get_secret_value(),
150-
password=info.password.get_secret_value(),
153+
password=(info.password and info.password.get_secret_value()),
151154
**kwargs,
152155
)
153156

@@ -158,7 +161,7 @@ def get_postgres_connection(info: PostgresConnectionInfo) -> BaseBackend:
158161
port=int(info.port.get_secret_value()),
159162
database=info.database.get_secret_value(),
160163
user=info.user.get_secret_value(),
161-
password=info.password.get_secret_value(),
164+
password=(info.password and info.password.get_secret_value()),
162165
)
163166

164167
@staticmethod
@@ -189,7 +192,9 @@ def _escape_special_characters_for_odbc(value: str) -> str:
189192
@staticmethod
190193
def _create_ssl_context(info: ConnectionInfo) -> Optional[ssl.SSLContext]:
191194
ssl_mode = (
192-
info.ssl_mode.get_secret_value() if hasattr(info, "ssl_mode") else None
195+
info.ssl_mode.get_secret_value()
196+
if hasattr(info, "ssl_mode") and info.ssl_mode
197+
else None
193198
)
194199

195200
if ssl_mode == SSLMode.VERIFY_CA and not info.ssl_ca:

0 commit comments

Comments
 (0)