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

Add UI-only database configuration method for extended authorization scenarios #8448

Merged
merged 9 commits into from
Oct 28, 2019

Conversation

willbarrett
Copy link
Member

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

Problem statement: currently connections to BigQuery databases cannot be configured without adding code to Superset or adding configuration to its execution environment in the form of Google Cloud account credentials.

Solution proposed: Add an encrypted field on the dbs table to hold extended connection information. This field can hold JSON configuration including secrets and add that information on to the database connection object during instantiation. This allows us to configure a service account in Google Cloud and connect to a BigQuery dataset without any code or configuration changes in Superset.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen Shot 2019-10-24 at 12 50 46 PM

TEST PLAN

  • Create a dataset in BigQuery in Google Cloud
  • Create a service account in Google Cloud with access to the dataset
  • Download the service account's identity file in JSON format
  • Open the Add Database screen in Superset
  • Fill in the SqlAlchemy URL with bigquery://project-name where project-name is the name of the Google Cloud project that your BigQuery dataset is associated with.
  • Add JSON to the Secure Extra field with the following structure:
{
    "credentials_info": <content from the identity file from Google Cloud>
}
  • Click "Test Connection" - It should say the connection is OK.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

@mistercrunch @dpgaspar

@@ -94,6 +94,7 @@ class DatabaseMixin:
"impersonate_user",
"allow_multi_schema_metadata_fetch",
"extra",
"encrypted_extra",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just confirmed that this doesn't show in show_columns

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very nice feature 👍 One small nit, other than that LGTM.

@codecov-io
Copy link

codecov-io commented Oct 25, 2019

Codecov Report

Merging #8448 into master will decrease coverage by 1.03%.
The diff coverage is 52.63%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8448      +/-   ##
==========================================
- Coverage   67.61%   66.57%   -1.04%     
==========================================
  Files         448      448              
  Lines       22486    22509      +23     
  Branches     2364     2364              
==========================================
- Hits        15204    14986     -218     
- Misses       7144     7385     +241     
  Partials      138      138
Impacted Files Coverage Δ
superset/models/core.py 81.46% <50%> (-0.47%) ⬇️
superset/views/database/__init__.py 78.78% <57.14%> (-1.22%) ⬇️
superset/db_engine_specs/presto.py 22.43% <0%> (-42.49%) ⬇️
superset/db_engine_specs/pinot.py 43.33% <0%> (-26.67%) ⬇️
superset/db_engine_specs/hive.py 27.85% <0%> (-12.33%) ⬇️
superset/db_engine_specs/mssql.py 58.33% <0%> (-11.12%) ⬇️
superset/db_engine_specs/postgres.py 83.87% <0%> (-9.68%) ⬇️
superset/db_engine_specs/bigquery.py 45.07% <0%> (-8.46%) ⬇️
superset/models/sql_types/presto_sql_types.py 65.51% <0%> (-6.9%) ⬇️
superset/db_engine_specs/base.py 80.73% <0%> (-4.66%) ⬇️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a39c24e...9202bd5. Read the comment docs.

@willbarrett willbarrett requested a review from dpgaspar October 25, 2019 21:16
@dpgaspar dpgaspar merged commit 148cec4 into apache:master Oct 28, 2019
@dpgaspar dpgaspar deleted the wbarrett/json-secrets branch October 28, 2019 15:49
graceguo-supercat pushed a commit that referenced this pull request Nov 13, 2019
…scenarios (#8448)

* Add encrypted_extra to dbs

* WIP - UI-based BigQuery connection configuration

* Fix 500 bubbling to the surface when adding a database connection

* Add check for valid json

* black formatting:

* isort

* Incorporate PR feedback. Thanks all!

* black

* Typo fix in CONTRIBUTING.md
@dpgaspar dpgaspar added v0.35 and removed v0.35 labels Dec 20, 2019
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.36.0 labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M 🚢 0.36.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants