Repository navigation
service tokens: 403 ROUTE_NOT_ALLOWLISTED for valid tokens; MCP lists only allowed tools - #185
Merged
Merged
Conversation
… only allowed tools A valid service token calling an eligible route outside its allowlist now gets 403 ROUTE_NOT_ALLOWLISTED instead of a generic 401, and the denial no longer spends the failed-attempt rate-limit budget. Bad, revoked, expired or CIDR-mismatched tokens keep 401. GET service-tokens/self returns the allowlist, and clawctl-operator mcp with --token-file filters tools/list to tools whose declared Hub routes the token holds.
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.
What
The Hub now says which layer denied a service-token request, and the MCP lists only the tools a token can actually use.
ROUTE_NOT_ALLOWLISTED. Before, it got a generic 401UNAUTHENTICATED.serviceAttemptsfailed-attempt budget, because a valid credential is not a guessing attempt.store.AuthenticateServiceToken, the allowlist check now runs after the source CIDR check and returns the newErrServiceRouteNotAllowed.GET /v1/operator/service-tokens/selfalso returnsallowlist.operatorclient.ServiceTokenSelfgained the field.clawctl-operator --token-file … mcpfilterstools/listto the tools whose Hub routes are all in that allowlist.internal/operatoragent/routes.go.This came up for real: the operator-admin token's allowlist lacks
POST /v1/operator/schedule-jobs/{id}/cancel. The MCP still offeredschedule_job_cancel, and the call came back as "401 Authentication required".Consistency guard
TestOperatorToolRoutesAreRegisteredfails if:Tools()declares no routes, oroperatorRoutePolicies.So a new tool cannot be added without declaring its routes, and a renamed route cannot drift.
Tests
TestServiceTokenRouteNotAllowlisted:TestToolsForFiltersByAllowlist: filtering, multi-route tools need every route, nil allowlist lists everything, and MCPtools/listuses it.TestServiceTokenBoundary: the non-allowlisted case now expects 403. The CIDR mismatch case is still 401.Deploy / rollback