Repository navigation
Offer console actions only to users whose scopes allow the call - #4135
Conversation
With scopes enforced at the gateway, several console actions were offered
to roles whose token cannot make the call behind them, so the user clicked
and got 401 ("Authentication failed"), or reached a page they could only
read:
- Publish page and portal cards: publish, unpublish, deprecate and save
draft need the API kind's publication / draft scopes; without them the
page is read-only and the card's Publish is disabled with the reason.
- Publish sidebar item and the overview's Publish step: shown / linked only
for users who may publish. The empty-state Add Portal needs CreateApiPortal.
- Policies: editing needs UpdateRESTAPI / UpdateGraphQLAPI (saving is an
API update); otherwise the panel is read-only.
- Test page: the test API key is minted only with CreateAPIKey /
CreateGraphQLAPIKey, and the proxy call mode needs InvokeRESTAPIOnGateway
(else the request goes direct).
- API list: GraphQL rows are deleted under DeleteGraphQLAPI, not DeleteRESTAPI.
- Cloud Deploy page: adding a gateway needs ap:gateway:create|manage; deploy
and stop also accept the API kind's deployment scopes
(ap:{rest,graphql}_api:deployment:create|undeploy|manage, *_api:manage).
- Cloud gateway overview: minting / reconfiguring registration tokens needs
the token scopes; Edit follows UpdateManagedGateway.
- Deploy to Gateway: a host that overrides the Deploy page declares
actionScopes (the cloud: its deploy scopes); a user without them gets
"View deployments".
- New feature key project-delete, for deployments whose projects are deleted
elsewhere (the cloud gateway serves no DELETE /projects/{id}).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedThis review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry. Next included review available in 59 minutes. View limit details
Tip 🎯 Customize your risk assessments
✅ Automatic approvals, with your rules
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4135 +/- ##
==========================================
- Coverage 64.13% 62.17% -1.96%
==========================================
Files 1279 1308 +29
Lines 197785 200840 +3055
Branches 6239 6265 +26
==========================================
- Hits 126847 124871 -1976
- Misses 62072 67338 +5266
+ Partials 8866 8631 -235
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Purpose
When scope enforcement is on, the gateway checks every console call against the scopes the route accepts. The console, though, offered several actions without checking whether the signed-in user's scopes allow the call behind them. A user without the scope saw the button, clicked it, and got
401 Authentication failed, or opened a page full of actions that all failed.These were found by signing in as each WSO2 Cloud organization role (Admin, Platform Engineer, Developer, API Publisher) and comparing every gated control in the console with the scopes of the API call it makes.
Goals
Offer an action only to a user whose scopes allow the call it makes:
Approach
The console already has the permission machinery.
OPERATION_SCOPES(generated from the OpenAPI spec) maps each operation to its accepted scopes, anduseCan(operation)/useActionPermission(operation)answer "does this session hold one of them?". The cloud plugins do the same withpermissions.canAny(scopes). This PR applies those checks where they were missing.1. Publishing an API to a portal
Where: an API's Publish page (left menu Publish). It lists one card per API Portal, each with a Publish button (and a menu with Configure & Publish). The button opens the per-portal publish page and publishes automatically.
publishRestApiToApiPortal/publishGraphQLApiToApiPortal)saveApiPublicationDraft.CreateApiPortal)2. Policies
Where: an API's Develop → Policies page.
UpdateRESTAPI/UpdateGraphQLAPIthe page is read-only: policies are listed, the editing controls are off. This is the same view a gateway-owned API already had, but without the "managed by the gateway" notice.3. Test
Where: an API's Test page.
POST …/api-keys). Users without key-create rights saw an error as soon as the page loaded.CreateAPIKey/CreateGraphQLAPIKey.InvokeRESTAPIOnGateway); without that scope, Execute failed with 401.4. API list
Where: a project's APIs list, the delete action on each row or card.
DeleteRESTAPI)DeleteGraphQLAPI5. Deploy (cloud plugin
apip-cloud-ui-deploy)Where: an API's Deploy page in WSO2 Cloud.
ap:gateway:createorap:gateway:manage; otherwise disabled with the tooltipap:deployment:deploy/undeploy/manageap:rest_api:deployment:create|undeploy|manage, theap:graphql_api:…equivalents, andap:rest_api:manage/ap:graphql_api:manage. Developers and API Publishers can deploy the APIs they build.6. Gateway details (cloud plugin
apip-cloud-ui-gateways)Where: API Gateways → open a gateway.
ap:gateway:token:create|manage,ap:gateway:manage)UpdateManagedGateway7. "Deploy to Gateway" button
Where: the API overview header.
DeployAPIoperation, even in WSO2 Cloud, where the Deploy page is replaced by a cloud plugin that deploys under different scopes. A user could see an enabled Deploy to Gateway and land on a page where every action was disabled.actionScopes: a page override declares the scopes its main action needs. The cloud declares its deploy scopes. A user without them sees View deployments instead.8. New feature key
project-deleteDELETE /projects/{id}(projects are deleted from the Cloud Console), so it failed with 404.project-deletejoins thedisable_featureslist. A deployment that deletes projects elsewhere hides the action. Nothing changes unless a deployment sets it.Result per WSO2 Cloud role
User stories
Documentation
N/A: behaviour follows the existing scopes.
project-deleteis listed with the otherdisable_featuresnames insrc/config/features.ts.Automation tests
PortalPublicationCard.test.tsx(Publish enabled with the right, disabled without it). Typecheck and lint are clean. In the suites for portals, overview, navigation, permissions and config, 572 of 577 pass; the 5 failures (PortalPublishPagethumbnail and banner timing) also fail on unmodifiedmainin the same environment (6 there). Cloud-plugin deploy suite: 66 of 66.Security checks
Related PRs
Test environment
macOS, Node 22, local WSO2 Cloud (OpenChoreo k3d), Chrome (headless).
🤖 Generated with Claude Code