ui: keep the console loading when a role denies listLdapConfigurations - #14152
Open
stag7824 wants to merge 1 commit into
Open
ui: keep the console loading when a role denies listLdapConfigurations#14152stag7824 wants to merge 1 commit into
stag7824 wants to merge 1 commit into
Conversation
GetInfo runs a dozen independent bootstrap calls inside a single Promise and wires several of them to the same reject. listLdapConfigurations is one of those, and all it does with the answer is record whether LDAP is configured. When a role denies that API the 432 rejects the shared promise, and it wins the race against listApis resolving it because it is a far smaller query. GetInfo then rejects, and the router guard in permission.js treats that as a failed session and logs the user out, so the console never renders at all. Default the flag and let the console finish loading instead, matching listNetworkServiceProviders and cloudianIsEnabled either side of it, which already swallow their own errors. Fixes apache#13912
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #13912
A role that denies
listLdapConfigurationscannot use the web console at all: the UI neverrenders and the user is redirected back to
/user/login.GetInfoinui/src/store/modules/user.jsruns about a dozen independent bootstrap callsinside a single
new Promise, and several of them are wired to that one sharedreject.listLdapConfigurationsis one of them, and all it does with the answer is record a flag:When the role denies it, the 432 rejects the shared promise. That is a race against
listApisresolving it, and the tiny denied query almost always settles first, soGetInforejects. The router guard in
ui/src/permission.jstreats a rejectedGetInfoas a failedsession and logs the user out instead of building routes — so one denied flag read takes down
the whole console.
The tolerant pattern is already in the same function, a few lines away.
listNetworkServiceProvidersandcloudianIsEnabledboth swallow their own error and theconsole loads fine without them. This change gives
listLdapConfigurationsthe sametreatment, defaulting the flag rather than rejecting:
Defaulting to
falsematches what the flag already means elsewhere —Logoutresets it, anda denied read is not evidence that LDAP is configured.
Scope
I have deliberately changed only the call named in the issue.
listCapabilities,listZonesand the second
listUsersare wired to the same sharedrejectand carry the same hazard,but unlike this one they are not pure flag reads, so whether each is "essential" is a call for
you rather than for me. Happy to widen this PR if you'd like them handled together, or to
leave that to a follow-up.
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
I could not add a unit test for this proportionately:
user.jsimports@/router,@/storeand
@/vue-app, there are no existing tests for any store module to build on, and standingthat scaffolding up for a three-line change seemed like more maintenance burden than it is
worth. Happy to add one if you disagree.
What I did instead was reduce
GetInfo's promise structure to a runnable model — a latelistApisthat resolves, a tolerant denied call, and the deniedlistLdapConfigurations—and run it both ways:
which reproduces the reported behaviour and the race described in the issue: the small denied
query settles before
listApiscan resolve the shared promise.I also ran what CI runs, on Node 16 to match
.github/workflows/ui.yml:vue-cli-service lintautofixes by default, so I checked separately that it left the fileuntouched rather than quietly reformatting the change into shape.
I do not have a deployment with custom roles to confirm the console rendering end to end, so
that part is unverified by me. The change itself is the same shape as the two tolerant calls
either side of it.
The same construction is present on 4.20 (it uses
api(rather thangetAPI(there). I havetargeted 4.22 since that is what the issue names, but happy to retarget.