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: use personal access token in OAuth2 databases #20280

Closed
wants to merge 1 commit into from

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented Jun 6, 2022

SUMMARY

Implementation of #20300, adding general support for OAuth2 in databases and a GSheets implementation.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue: [SIP-85] OAuth2 for databases #20300
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Jun 6, 2022

Codecov Report

Merging #20280 (0086136) into master (368e7e6) will decrease coverage by 0.00%.
The diff coverage is 82.46%.

❗ Current head 0086136 differs from pull request most recent head 216fb6d. Consider uploading reports for the commit 216fb6d to get more accurate results

@@            Coverage Diff             @@
##           master   #20280      +/-   ##
==========================================
- Coverage   66.86%   66.85%   -0.01%     
==========================================
  Files        1847     1848       +1     
  Lines       70567    70573       +6     
  Branches     7744     7745       +1     
==========================================
  Hits        47184    47184              
- Misses      21382    21388       +6     
  Partials     2001     2001              
Flag Coverage Δ
javascript 53.81% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../components/ErrorMessage/OAuth2RedirectMessage.tsx 0.00% <0.00%> (ø)
...rset-frontend/src/components/ErrorMessage/types.ts 100.00% <ø> (ø)
superset-frontend/src/setup/setupErrorMessages.ts 0.00% <0.00%> (ø)
superset/config.py 91.84% <ø> (ø)
superset/db_engine_specs/drill.py 85.36% <ø> (ø)
superset/db_engine_specs/trino.py 68.64% <ø> (ø)
superset/exceptions.py 91.30% <ø> (ø)
superset/models/helpers.py 38.19% <0.00%> (ø)
superset/db_engine_specs/gsheets.py 75.91% <71.42%> (ø)
superset/sql_lab.py 82.12% <87.50%> (ø)
... and 20 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

"""
parameters = request.args.to_dict()
if "error" in parameters:
raise Exception(parameters["error"]) # XXX: raise custom SIP-40 exception
Copy link
Member

Choose a reason for hiding this comment

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

is this a todo?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! XXX is a traditional way of adding a todo (vim will highlight it by default, eg).

https://stackoverflow.com/a/5456703/807118

Copy link
Member Author

Choose a reason for hiding this comment

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

Normally I use it for temporary todos, while still working on the PR.

@dobrych
Copy link

dobrych commented Oct 3, 2022

@betodealmeida cool feature! did it get any field use yet? 🙂
I might give it a go, got a use-case with OAuth data source

@betodealmeida betodealmeida force-pushed the gsheets_oauth branch 4 times, most recently from c27613f to b4861ac Compare December 10, 2022 02:36
@betodealmeida betodealmeida changed the title [WIP] feat: use personal access token in OAuth2 databases feat: use personal access token in OAuth2 databases Dec 10, 2022
@betodealmeida betodealmeida force-pushed the gsheets_oauth branch 6 times, most recently from 8bf29df to cafd28d Compare December 10, 2022 03:08
state = jwt.encode(
payload=payload,
key=current_app.config["SECRET_KEY"],
algorithm="HS256",
Copy link
Member

Choose a reason for hiding this comment

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

do we want the algo to be configurable?

Comment on lines +336 to +339
# Settings to enable OAuth2 in the Google Sheets DB engine spec.
# GSHEETS_OAUTH2_CLIENT_ID = "XXX"
# GSHEETS_OAUTH2_CLIENT_SECRET = "YYY"
# GSHEETS_OAUTH2_REDIRECT_URI = "http://localhost:8088/api/v1/database/oauth2/"
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe this should be a dict:

OAUTH2_CREDENTIALS = {
    "GSheets": {
        "CLIENT_ID": "XXX",
...
}

@shohamyamin
Copy link

@betodealmeida Any progress with that? What is missing for that to be merged? I am seeking for the same solution but for Trino Oauth2. maybe I can help with that feature (although I am new in contributing to open source)

@harksin
Copy link

harksin commented Feb 21, 2024

Same use case as you @shohamyamin (trino + Oauth2).
interested in any update or status

@betodealmeida
Copy link
Member Author

Closing this, since it was easier to start the work from scratch in a new branch. I hope we can have this up and running in the next couple weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants