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(db_engine): Implement user impersonation support for StarRocks #28110

Merged

Conversation

Woellchen
Copy link
Contributor

SUMMARY

This PR adds user impersonation support for the StarRocks database by leveraging the native EXECUTE AS {user} WITH NO REVERT user management query.

TESTING INSTRUCTIONS

  1. If necessary create a separate user on your StarRocks DB and your Superset instance. The names must match and it should be different from the user that is used for the StarRocks connection itself
  2. Enable the user impersonation feature in the security settings of your StarRocks database
  3. Log in to Superset with your testing user
  4. Execute SELECT CURRENT_USER(); and see that it shows your current Superset user
  5. Disable user impersonation feature again
  6. Execute SELECT CURRENT_USER(); again and see that it changed back to the user of the StarRocks connection

ADDITIONAL INFORMATION

  • Has associated issue:
  • 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

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️

We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register.

@john-bodley
Copy link
Member

Thanks @Woellchen for the change. Would you mind adding unit/integration tests to help ensure we don't have future regressions?

@Woellchen
Copy link
Contributor Author

Thanks @john-bodley! Sure, I will look into it :)

@rusackas
Copy link
Member

Looks like the pre-commit hooks also need to be run to make the linters happy.

@Woellchen Woellchen force-pushed the feature/starrocks-user-impersonation branch from 51b878d to b94ea18 Compare April 22, 2024 13:22
@pull-request-size pull-request-size bot added size/L and removed size/M labels Apr 22, 2024
@Woellchen Woellchen force-pushed the feature/starrocks-user-impersonation branch 2 times, most recently from e0d6b38 to 8cf48bf Compare April 22, 2024 13:28
@Woellchen
Copy link
Contributor Author

Woellchen commented Apr 22, 2024

Hey @rusackas and @john-bodley, I have tried to address your comments. Could you please another look at it? :)

@rusackas
Copy link
Member

Running CI... fingers crossed!

@villebro villebro self-requested a review August 22, 2024 18:20
@villebro
Copy link
Member

@Woellchen can you rebase the PR to restart CI?

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.

LGTM, but we need to rebase the PR to ensure tests are running ok on the other dbs due to the sig changes. Please ping me for a new review once done.

@villebro villebro closed this Sep 4, 2024
@villebro villebro reopened this Sep 4, 2024
@Woellchen Woellchen force-pushed the feature/starrocks-user-impersonation branch from 8cf48bf to 25619a2 Compare September 6, 2024 13:30
@Woellchen
Copy link
Contributor Author

Hey @villebro! I have rebased the branch and verified that everything still works as expected :) Thank you

Copy link

codecov bot commented Sep 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.65%. Comparing base (76d897e) to head (4147eeb).
Report is 688 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #28110       +/-   ##
===========================================
+ Coverage   60.48%   83.65%   +23.16%     
===========================================
  Files        1931      529     -1402     
  Lines       76236    38312    -37924     
  Branches     8568        0     -8568     
===========================================
- Hits        46114    32051    -14063     
+ Misses      28017     6261    -21756     
+ Partials     2105        0     -2105     
Flag Coverage Δ
hive 48.86% <53.84%> (-0.30%) ⬇️
javascript ?
mysql 76.66% <53.84%> (?)
postgres 76.73% <53.84%> (?)
presto 53.41% <53.84%> (-0.39%) ⬇️
python 83.65% <100.00%> (+20.16%) ⬆️
sqlite 76.19% <53.84%> (?)
unit 60.40% <100.00%> (+2.78%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Woellchen Woellchen force-pushed the feature/starrocks-user-impersonation branch from 25619a2 to 4147eeb Compare September 6, 2024 15:34
@Woellchen
Copy link
Contributor Author

I had missed one usage for databricks, I fixed that now

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.

LGTM, thanks for the patience and apologies for the loooong review process, excited to see this finally get merged! 🚀

@villebro villebro merged commit 6294e33 into apache:master Sep 6, 2024
37 checks passed
@Woellchen Woellchen deleted the feature/starrocks-user-impersonation branch September 6, 2024 17:47
@Woellchen
Copy link
Contributor Author

No problem, glad we merged it! Thank you too!

This pull request was closed.
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.

5 participants