-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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(nav): infinite redirect and upload dataset nav permissions #19708
Conversation
20c2dda
to
db9f124
Compare
window.location.href = `/login?next=${ | ||
window.location.pathname + window.location.search | ||
}`; | ||
if (!window.location.pathname.startsWith('/login')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only redirect when we are not on the login page so we never see infinite redirect caused by the API client ever again.
@@ -161,7 +163,7 @@ export default class SupersetClientClass { | |||
headers, | |||
timeout, | |||
fetchRetryOptions, | |||
ignoreUnauthorized, | |||
ignoreUnauthorized = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be more explicit what is the default. I kind of feel this should probably default to true
but that's another topic. Async API requests should never implicitly redirect users as it may often cause surprises. There should be better error handling on the API user side instead.
cc @geido @kgabryje could you give more context on why #17597 made redirects on 401 the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I strongly agree here, this behavior is quite surprising from an api client. Though I guess this approach involves the least amount of code changes.
From a UX perspective I'd suggest presenting the user with the option to re-auth. There could be unsaved work that would be lost via a the redirect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we always want to redirect to login on a 401. 401 means that there's no auth token at all. 403 should be used if the user is forbidden, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh i see. so we're fine with rendering some stuff even when a user is logged out. I guess that's fine then, carry on!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will have a conversation about having the default to true and we'll follow up. Thank you!
show={showModal} | ||
dbEngine={engine} | ||
/> | ||
{canDatabase && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bycatch: only render the DatabaseModal when users can create new database connection.
@@ -240,22 +240,22 @@ const SubMenuComponent: React.FunctionComponent<SubMenuProps> = props => { | |||
if ((props.usesRouter || hasHistory) && !!tab.usesRouter) { | |||
return ( | |||
<Menu.Item key={tab.label}> | |||
<li | |||
<div |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bycatch: fix a React warning about nested <li />
s.
@@ -161,7 +163,7 @@ export default class SupersetClientClass { | |||
headers, | |||
timeout, | |||
fetchRetryOptions, | |||
ignoreUnauthorized, | |||
ignoreUnauthorized = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I strongly agree here, this behavior is quite surprising from an api client. Though I guess this approach involves the least amount of code changes.
From a UX perspective I'd suggest presenting the user with the option to re-auth. There could be unsaved work that would be lost via a the redirect.
Codecov Report
@@ Coverage Diff @@
## master #19708 +/- ##
==========================================
- Coverage 66.51% 66.50% -0.01%
==========================================
Files 1684 1684
Lines 64560 64570 +10
Branches 6625 6630 +5
==========================================
+ Hits 42939 42941 +2
- Misses 19926 19931 +5
- Partials 1695 1698 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
🏷️ preset:2022.15 |
SUMMARY
Currently there is an infinite redirect on the login page (when users are not logged in) that is triggered by an unfortunate sequence of changes:
/api/v1/database
API to find out whether there are databases with file upload enabled, even when the menu is rendered on a page where users haven't logged in. (Although I'm not sure why the redirects didn't show up in fix: update Permissions for right nav #19051's ephemeral environment.)While debugging, I also found out that users without admin access will also see an empty "Data" menu, so I fixed that as well.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
When logged in as non admin users:
Before
There is an empty
Data
menu item with no submenu.After
The
Data
menu item is removedTESTING INSTRUCTIONS
<superset url>/login
. You may see infinitely redirect without this PR. For example, check the ephemeral environment of chore(build): upgrade less-loader #19703username: alpha, passwd: general
), check whether the empty menu item still exists.ADDITIONAL INFORMATION