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: SupersetClient config to override 401 behavior #19144

Merged
merged 11 commits into from
Mar 21, 2022

Conversation

suddjian
Copy link
Member

@suddjian suddjian commented Mar 14, 2022

SUMMARY

Requests should be able to be made without triggering the usual redirect-to-login if a 401 is returned.

Additionally, we need to have a default action other than a redirect if we get a 401 in the embedded page. This PR also adds code for Embedded so that 401s result in a toast warning instead of a redirect. We may want to change this to something other than a toast in the future, but for now it gets the job done.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before, a 401 resulted in a redirect to our login screen, which since you were already logged in to Preset, redirected to an app-in-app experience, which is pretty confusing. Now you get error messages and this explanation. Less brain-bending.

Screen Shot 2022-03-18 at 7 12 07 PM

TESTING INSTRUCTIONS

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

@suddjian suddjian marked this pull request as draft March 14, 2022 23:25
@suddjian suddjian force-pushed the client-override-unauthorized branch from 0c7214a to 605e281 Compare March 14, 2022 23:46
@suddjian suddjian changed the title Client override unauthorized feat: SupersetClient config to override 401 behavior Mar 19, 2022
@suddjian suddjian marked this pull request as ready for review March 19, 2022 02:19
max-width: 600px;
position: fixed;
bottom: 0px;
${({ position }) => (position === 'bottom' ? 'bottom' : 'top')}: 0px;
Copy link
Member Author

Choose a reason for hiding this comment

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

By default toasts are at the bottom, but the bottom of an embedded iframe could be offscreen, so for embedded it looks better to have toasts at the top.

});
}

function validateMessageEvent(event: MessageEvent) {
if (
Copy link
Member Author

Choose a reason for hiding this comment

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

This stuff isn't required, and I think it will be more confusing long-term than not having it here.

@codecov
Copy link

codecov bot commented Mar 19, 2022

Codecov Report

Merging #19144 (5cfae15) into master (e3e03d2) will increase coverage by 0.01%.
The diff coverage is 68.42%.

@@            Coverage Diff             @@
##           master   #19144      +/-   ##
==========================================
+ Coverage   66.55%   66.56%   +0.01%     
==========================================
  Files        1646     1643       -3     
  Lines       63617    63664      +47     
  Branches     6471     6494      +23     
==========================================
+ Hits        42339    42379      +40     
- Misses      19600    19602       +2     
- Partials     1678     1683       +5     
Flag Coverage Δ
javascript 51.31% <68.42%> (+0.04%) ⬆️

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

Impacted Files Coverage Δ
superset-frontend/src/embedded/index.tsx 0.00% <0.00%> (ø)
...nd/src/components/MessageToasts/ToastPresenter.tsx 93.33% <80.00%> (-6.67%) ⬇️
...rset-ui-core/src/connection/SupersetClientClass.ts 100.00% <100.00%> (ø)
...nd/src/components/MessageToasts/ToastContainer.tsx 100.00% <100.00%> (ø)
...ontend/src/components/MessageToasts/withToasts.tsx 100.00% <100.00%> (ø)
...d/src/SqlLab/components/QueryAutoRefresh/index.jsx 61.29% <0.00%> (-22.05%) ⬇️
...rontend/src/explore/components/EmbedCodeButton.jsx 55.00% <0.00%> (-11.67%) ⬇️
...RUD/data/database/DatabaseModal/SqlAlchemyForm.tsx 57.14% <0.00%> (-9.53%) ⬇️
...d/src/SqlLab/components/AceEditorWrapper/index.tsx 44.82% <0.00%> (-8.75%) ⬇️
...ontend/src/components/URLShortLinkButton/index.jsx 93.75% <0.00%> (-6.25%) ⬇️
... and 68 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 e3e03d2...5cfae15. Read the comment docs.

@suddjian suddjian merged commit 96a123f into apache:master Mar 21, 2022
@sadpandajoe
Copy link
Member

🏷️ preset:2022.11

sadpandajoe pushed a commit to preset-io/superset that referenced this pull request Mar 21, 2022
* wip

* feat: make 401 responses configurable in SupersetClient

* sort

* guest unauthorized handler

* add toast container to embedded app

* add option for toast presenter to go at the top

* remove confusing comms logging

* lint

* Update superset-frontend/src/embedded/index.tsx

* type correction

(cherry picked from commit 96a123f)
@villebro villebro mentioned this pull request Mar 22, 2022
9 tasks
michael-hoffman-26 pushed a commit to nielsen-oss/superset that referenced this pull request Mar 23, 2022
* wip

* feat: make 401 responses configurable in SupersetClient

* sort

* guest unauthorized handler

* add toast container to embedded app

* add option for toast presenter to go at the top

* remove confusing comms logging

* lint

* Update superset-frontend/src/embedded/index.tsx

* type correction
villebro pushed a commit that referenced this pull request Apr 3, 2022
* wip

* feat: make 401 responses configurable in SupersetClient

* sort

* guest unauthorized handler

* add toast container to embedded app

* add option for toast presenter to go at the top

* remove confusing comms logging

* lint

* Update superset-frontend/src/embedded/index.tsx

* type correction

(cherry picked from commit 96a123f)
@mistercrunch mistercrunch added 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.0 labels Mar 13, 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 lts-v1 preset:2022.11 preset-io size/L 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants