Skip to content

Commit

Permalink
feat: don't ask for password when DB exists (apache#17776)
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida authored and bwang221 committed Feb 10, 2022
1 parent 5ffd98a commit 15aa763
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion superset/charts/commands/importers/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _import(
)
config["params"].update({"datasource": dataset.uid})

if config["query_context"]:
if "query_context" in config:
del config["query_context"]

import_chart(session, config, overwrite=overwrite)
8 changes: 7 additions & 1 deletion superset/databases/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
from sqlalchemy.engine.url import make_url
from sqlalchemy.exc import ArgumentError

from superset import db
from superset.db_engine_specs import BaseEngineSpec, get_engine_specs
from superset.exceptions import CertificateException, SupersetSecurityException
from superset.models.core import ConfigurationMethod, PASSWORD_MASK
from superset.models.core import ConfigurationMethod, Database, PASSWORD_MASK
from superset.security.analytics_db_safety import check_sqlalchemy_uri
from superset.utils.core import markdown, parse_ssl_cert

Expand Down Expand Up @@ -620,6 +621,11 @@ def fix_allow_csv_upload(
@validates_schema
def validate_password(self, data: Dict[str, Any], **kwargs: Any) -> None:
"""If sqlalchemy_uri has a masked password, password is required"""
uuid = data["uuid"]
existing = db.session.query(Database).filter_by(uuid=uuid).first()
if existing:
return

uri = data["sqlalchemy_uri"]
password = make_url(uri).password
if password == PASSWORD_MASK and data.get("password") is None:
Expand Down

0 comments on commit 15aa763

Please sign in to comment.