fix(gateway): retain operator scopes for non-local token-auth clients#1159
Open
BingqingLyu wants to merge 1 commit into
Open
fix(gateway): retain operator scopes for non-local token-auth clients#1159BingqingLyu wants to merge 1 commit into
BingqingLyu wants to merge 1 commit into
Conversation
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.
Summary
Describe the problem and fix in 2-5 bullets:
clearUnboundScopes()unconditionally strips operator scopes for non-local clients without device identity, even when token auth succeeds. This breakschat.sendand other operator.write-scoped methods for backend clients connecting over network with valid--tokenauth.evaluateMissingDeviceIdentity, treatauthOk+authMethodtoken/password as sufficient for operator device-skip (alongsidesharedAuthOk), so non-local token-auth clients retain their self-declared scopes.sharedAuthOkmight disagree with primary auth.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Non-local backend clients connecting with valid token auth now retain their requested scopes (e.g.
operator.admin), sochat.sendand other operator.write methods work as they do for localhost.Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation: N/ARepro + Verification
Environment
--bind tailnet --tokenSteps
openclaw gateway --bind tailnet --token <token>auth.tokenandscopes: ["operator.admin"]chat.sendExpected
chat.sendsucceeds (operator.admin implies operator.write).Actual
missing scope "operator.write". After fix: scopes retained,chat.sendworks.Evidence
Attach at least one:
connect-policy.test.tsincludes a regression test: operator + sharedAuthOk=false but authOk=true + authMethod=token + isLocalClient=false now returnsallow. All tests pass.Human Verification (required)
What you personally verified (not just CI), and how:
pnpm exec vitest run src/gateway/server/ws-connection/connect-policy.test.ts鈥?all tests pass.Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
src/gateway/server/ws-connection/connect-policy.ts,connect-policy.test.ts,message-handler.tsRisks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.None. The change narrows the condition under which scopes are stripped; token-authenticated operators already pass auth and are trusted. No new trust boundary is introduced.