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(embedded): add hook to allow superset admins to validate guest token parameters #30132

Merged
merged 16 commits into from
Sep 11, 2024

Conversation

dmarkey
Copy link
Contributor

@dmarkey dmarkey commented Sep 2, 2024

SUMMARY

This allows the Superset admin to tighten up Guest token configuration with a validator hook. Any aspect can be validated but most likely the RLS Clause.

TESTING INSTRUCTIONS

Set GUEST_TOKEN_VALIDATOR_HOOK = lambda x: len(x["rls"]) == 1 and "tenant_id=" in x["rls"][0]["clause"] and the RLS clause in the guest token will need to contain "tenant_id="

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

@github-actions github-actions bot added the api Related to the REST API label Sep 2, 2024
@dosubot dosubot bot added the authentication:row-level-security Related to Row Level Security label Sep 2, 2024
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.

@dmarkey dmarkey changed the title feat(embedded) Add hook to allow superset admins to validate guest to ken parameters feat(embedded) Add hook to allow superset admins to validate guest token parameters Sep 2, 2024
Copy link

codecov bot commented Sep 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.69%. Comparing base (76d897e) to head (8bcf43f).
Report is 1094 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #30132       +/-   ##
===========================================
+ Coverage   60.48%   83.69%   +23.20%     
===========================================
  Files        1931      529     -1402     
  Lines       76236    38421    -37815     
  Branches     8568        0     -8568     
===========================================
- Hits        46114    32157    -13957     
+ Misses      28017     6264    -21753     
+ Partials     2105        0     -2105     
Flag Coverage Δ
hive 48.86% <33.33%> (-0.30%) ⬇️
javascript ?
mysql 76.66% <100.00%> (?)
postgres 76.73% <100.00%> (?)
presto 53.39% <33.33%> (-0.41%) ⬇️
python 83.69% <100.00%> (+20.20%) ⬆️
sqlite 76.18% <100.00%> (?)
unit 60.44% <33.33%> (+2.81%) ⬆️

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.

@nytai nytai changed the title feat(embedded) Add hook to allow superset admins to validate guest token parameters feat(embedded): Add hook to allow superset admins to validate guest token parameters Sep 3, 2024
@nytai nytai changed the title feat(embedded): Add hook to allow superset admins to validate guest token parameters feat(embedded): add hook to allow superset admins to validate guest token parameters Sep 3, 2024
@nytai nytai changed the title feat(embedded): add hook to allow superset admins to validate guest token parameters feat(embedded): guest token validator hook Sep 3, 2024
@nytai nytai changed the title feat(embedded): guest token validator hook feat(embedded): add hook to allow superset admins to validate guest token parameters Sep 3, 2024
Copy link
Member

@nytai nytai left a comment

Choose a reason for hiding this comment

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

LGTM

@rusackas
Copy link
Member

rusackas commented Sep 9, 2024

Thanks @giftig and @dmarkey for dialing this in. @nytai already approved it, which is giving me an itchy trigger finger. If any of @giftig 's change requests are blockers, feel free to hit the "request changes" button to block the merge. Just make sure you're around to unblock it when the required adjustments are made ;) Thanks all :D

@giftig
Copy link
Contributor

giftig commented Sep 9, 2024

My comments aren't really blocking, just a small improvement which would be nice imo. It's an easy +1 for me if the tests can be separated like they were before but without the repetition of test fixtures, but it's not a big enough issue to block the PR.

@dmarkey
Copy link
Contributor Author

dmarkey commented Sep 9, 2024

Alright did another test refactor, broke out the tests again and moved them to their own class with the heavy dashboard fixture loaded in the class scope.

Copy link
Contributor

@giftig giftig left a comment

Choose a reason for hiding this comment

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

Minor question about noqa but LGTM

tests/integration_tests/security/api_tests.py Outdated Show resolved Hide resolved
@dmarkey
Copy link
Contributor Author

dmarkey commented Sep 10, 2024

Not sure if I need to take action based on that failed cypress test?

@villebro
Copy link
Member

@dmarkey nothing that you've caused - we're investigating it currently, but it seems like a flaky test that may be caused by a perf regression that's been recently introduced. We're looking into it, but for now we'll just keep restarting the CI check until it passes..

@rusackas rusackas merged commit a31a4ee into apache:master Sep 11, 2024
37 checks passed
mz0in added a commit to mz0in/superset that referenced this pull request Sep 11, 2024
feat(embedded): add hook to allow superset admins to validate guest t……oken parameters (apache#30132)  Co-authored-by: David Markey
@dmarkey
Copy link
Contributor Author

dmarkey commented Sep 12, 2024

Thanks for merging! I guess it will be in 4.2.0?

@rusackas rusackas added the v4.1 Label added by the release manager to track PRs to be included in the 4.1 branch label Sep 13, 2024
@rusackas
Copy link
Member

No, thank YOU!

It'll definitely be in 5.0, and if we do a 4.2 (TBD) it'll definitely be in there, too. Right now, @sadpandajoe is building 4.1 RCs. I've labeled this PR to get cherries, but I'm not sure if that'll happen or not at this point.

sadpandajoe pushed a commit that referenced this pull request Oct 15, 2024
…oken parameters (#30132)

Co-authored-by: David Markey <markey@rapidraitngs.com>
(cherry picked from commit a31a4ee)
@github-actions github-actions bot added 🍒 4.1.0 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to the REST API authentication:row-level-security Related to Row Level Security 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L v4.1 Label added by the release manager to track PRs to be included in the 4.1 branch 🍒 4.1.0 🍒 4.1.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants