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

fix: use StrEnum type for GuestTokenResourceType to fix token parsing #30042

Merged
merged 3 commits into from
Aug 29, 2024

Conversation

hao-zhuventures
Copy link
Contributor

@hao-zhuventures hao-zhuventures commented Aug 28, 2024

SUMMARY

This change is to fix the "incorrect" check results from comparing the guest_token claims with the enum value. By changing the type to be StrEnum, the str based comparison will output the desired results.

Additional context: guest user jwt token claims are casted to the GuestToken type here.

TESTING INSTRUCTIONS

Manual check before / after

>>> 'dashboard' == GuestTokenResourceType.DASHBOARD
False
>>> 'dashboard' == GuestTokenResourceType.DASHBOARD
True

and CI checks.

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.

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.

Thanks for the fix! However, there's already a similar class, so please reuse that one

superset/security/guest_token.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.68%. Comparing base (76d897e) to head (ac96f2b).
Report is 1094 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #30042       +/-   ##
===========================================
+ Coverage   60.48%   83.68%   +23.20%     
===========================================
  Files        1931      528     -1403     
  Lines       76236    38207    -38029     
  Branches     8568        0     -8568     
===========================================
- Hits        46114    31975    -14139     
+ Misses      28017     6232    -21785     
+ Partials     2105        0     -2105     
Flag Coverage Δ
hive 48.92% <100.00%> (-0.24%) ⬇️
javascript ?
mysql 76.77% <100.00%> (?)
postgres 76.84% <100.00%> (?)
presto 53.48% <100.00%> (-0.32%) ⬇️
python 83.68% <100.00%> (+20.20%) ⬆️
sqlite 76.31% <100.00%> (?)
unit 60.29% <100.00%> (+2.66%) ⬆️

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.

@villebro
Copy link
Member

The cypress check seems stubbornly flaky - I'll keep restarting it until it goes green (I can't imagine this change could have broken any of the cypress tests..)

@michael-s-molina michael-s-molina added the v4.1 Label added by the release manager to track PRs to be included in the 4.1 branch label Aug 29, 2024
@michael-s-molina
Copy link
Member

Thanks for the fix @hao-zhuventures

@villebro
Copy link
Member

This has now been restarted 11 times, I'm starting to think there's something weird going on..

@villebro
Copy link
Member

Omg finally 😆

@villebro villebro merged commit e2c4435 into apache:master Aug 29, 2024
38 checks passed
sadpandajoe pushed a commit that referenced this pull request Sep 3, 2024
@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
authentication Related to authentication 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XS 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.

GuestToken and dashboard embed access check failure, causing 403 HTTP responses
4 participants