Skip to content

Review fixes for user authorization tab hiding (#3035)#3036

Open
ramonsmits wants to merge 9 commits into
show-hide-tabsfrom
ramon/review-3035-fixes
Open

Review fixes for user authorization tab hiding (#3035)#3036
ramonsmits wants to merge 9 commits into
show-hide-tabsfrom
ramon/review-3035-fixes

Conversation

@ramonsmits

@ramonsmits ramonsmits commented Jun 19, 2026

Copy link
Copy Markdown
Member

Follow-up fixes for:

Changes:

  • Gate the Throughput menu on admin_read (server-side it is an admin resource, matching the Usage Setup tab).
  • Consume supportsUserPermissions so permissions are only fetched and the tab only shown when ServiceControl exposes the endpoints.
  • Deduplicate concurrent permission refreshes via a shared in-flight request.
  • Extract a shared usePermissionGate composable so PageHeader and ConfigurationView use identical gating.
  • Fetch permissions via the discovered root URLs instead of hardcoded paths.
  • Log permission load failures.
  • Use Bootstrap text-success/text-danger for the permission icons.
  • Add tests for usePermissionGate and UserPermissionsStore.

Throughput is an admin resource server-side (ServiceControl bundles
error:throughput: under the admin permission group, alongside licensing,
notifications and redirects), so the top-nav Throughput item must gate on
admin_read rather than failed_messages_read. This matches the existing
'Usage Setup' configuration tab, which already gates on admin_read.
The supportsUserPermissions flag was computed in EnvironmentAndVersionsStore
but never consumed. Older ServiceControl versions do not expose the
my/permissions endpoints, so without this guard the app would attempt to
fetch permissions (and show the User Permissions tab) against an instance
that returns 404.

- App.vue only triggers permissionsStore.refresh() when the capability is
  present; the watch now also reacts to the flag becoming available.
- ConfigurationView only renders the User Permissions tab when ServiceControl
  advertises the endpoints, in addition to auth being enabled.
App.vue's auth watch and the User Permissions view's onMounted both call
refresh() on load, firing two identical pairs of requests. Share a single
in-flight promise so concurrent callers reuse the same request; the slot is
released once it settles, so later refreshes still re-fetch.
PageHeader and ConfigurationView each defined their own permission gate.
The two predicates had drifted: PageHeader required authEnabled &&
isAuthenticated && summary, while ConfigurationView omitted isAuthenticated.
Extract a single usePermissionGate composable exposing has(flag) so both
views share identical, fail-open gating logic.
The permission endpoint paths were hardcoded in UserPermissionsStore even
though ServiceControl advertises them (mypermissions_summary/mypermissions_all)
in its root document. Expose those URLs from EnvironmentAndVersionsStore and
fetch them through a new serviceControlClient.fetchTypedFromUrl() helper, so
the frontend follows the server's routing instead of duplicating path knowledge.
The catch block discarded the underlying error, leaving no diagnostic trail
when permissions fail to load. Log it via the shared logger (as the other
stores do) while still surfacing the friendly message to the user.
Replace the bespoke .icon-granted/.icon-denied rules (hardcoded hex colours)
with the standard Bootstrap utility classes already used elsewhere for
granted/denied FAIcons (StatusIcon, EndpointInstances, ConnectionResultView).
Covers the gate's core contract: it fails open (shows everything) when
authorization is disabled, when the user is unauthenticated, or while the
summary is still loading; and gates per flag once enabled, authenticated and
loaded. Also asserts it reacts to summary updates.
Covers: a successful refresh fetches the discovered root URLs and populates
summary+descriptor; a failed request sets the friendly error and logs the
cause; and concurrent refresh() calls share one in-flight request (two
endpoint calls, not four) while still re-fetching once settled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant