Skip to content

feat(visitor-access): internal Cloudflare Access visitor plugin - #132073

Merged
steipete merged 2 commits into
mainfrom
feat/visitor-access-plugin
Aug 28, 2026
Merged

steipete merged 2 commits into
mainfrom
feat/visitor-access-plugin

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

team.openclaw.ai sits behind Cloudflare Access with a single allow policy: membership in the openclaw GitHub org. There is no way to let a non-org member in — no visitor tier, no expiry, no operator surface. Granting someone temporary access today means hand-editing the Access app in the Cloudflare dashboard and remembering to undo it.

The gateway side of visitor support already shipped: gateway.roles with default: "guest" gives unknown authenticated users view-only access to others' sessions, a single allowed agent, and forced per-principal sandboxing (#128548, #129926, #130229, #131147, #131156). What was missing was the front door.

Why This Change Was Made

This adds extensions/visitor-access, an internal plugin (monorepo, excluded from the npm release via the files exclusion; "private": true following the qa-channel pattern). Because team builds from source, landing on main deploys it there via the hourly updater with no packaging work.

Mechanism: the plugin manages exactly one app-scoped Access allow-policy — an email include-list found strictly by its configured name. Access ORs allow policies, so the maintainer org policy is never read, written, or reordered. Visitors authenticate with their own GitHub account: the GitHub IdP authenticates any GitHub account (the org restriction lives in the policy, not the IdP), so no IdP changes are needed and auto_redirect_to_identity stays on — zero UX change for maintainers.

Three agent tools: visitor_invite (email or GitHub login; public-email resolution with an actionable error when the email is private; default 14-day expiry, forever must be explicit), visitor_revoke, visitor_list (includes drift reporting). Grants live in the plugin keyed store; an hourly sweep plus gateway-start sweep removes expired emails from the policy. Records are persisted before the Cloudflare write so a lost API response still leaves a cleanup record for the next sweep. All policy mutations reread fresh state first, so dashboard edits between calls are preserved; emails added by hand in the dashboard are reported as unmanaged and never auto-deleted.

Trust model (also in the README): plugin tools are not in the sandbox tool allowlist and guest sessions are always sandboxed, so guests cannot reach these tools; anyone who can drive an unsandboxed session (maintainers, by role policy) can manage visitors. The API token is config-supplied and redacted from all error text.

User Impact

Maintainer-only, team-infrastructure feature. Not part of the npm release; no user-facing OpenClaw behavior changes. Operators of other deployments can enable it with their own Cloudflare account/app IDs.

Evidence

  • 45 tests across 3 files (pnpm test extensions/visitor-access), covering create-if-missing, tamper refusal (non-allow decision, non-email rules, duplicate policy names), invite idempotency and expiry refresh, private-email guidance, maxVisitors cap, revoke by login/email, sweep expiry vs unmanaged retention.
  • Live proof against the production team Access app using the plugin's own client: initial read absent → invite creates the policy with the test email (verified by independent reread, policy id 0b9863cf…) → revoke empties and deletes the policy → final read absent. App state verified byte-identical afterward: one policy (OpenClaw Maintainers (org)=allow), same IdP allowlist, autoredirect unchanged.
  • CI=true pnpm check:changed exit 0; pnpm build exit 0 with dist entrypoints present and no INEFFECTIVE_DYNAMIC_IMPORT; oxlint clean; autoreview clean.
  • Deliberately not built (stated non-goals in README): signup/request queue, IdP management, SecretRef deep resolution.

Manage a dedicated app-scoped email allow policy without changing maintainer
policies or identity providers. Add invite, revoke, and bounded drift-aware
list tools with durable grant records and default 14-day expiry.

Share one Gateway-owned manager across tool discovery and expiry sweeps;
preserve cleanup records through remote failures and fence stopped services.
Keep this private source-built plugin out of the npm release.
@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 28, 2026 20:01
@steipete
steipete requested a review from a team as a code owner August 28, 2026 20:01
@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Aug 28, 2026
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Aug 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Guard

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • extensions/visitor-access/package.json
  • pnpm-lock.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfiles or workspace dependency policy changes are present.
  • Treat pnpm-lock.yaml and package-lock.json diffs as dependency security-review surfaces.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Dependency graph changes noted

This PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin, a member of @openclaw/openclaw-secops, or an OpenClaw organization member with Maintain or Admin repository access.

  • Current SHA: 02fab86f887f8841de4149b70344aa549e3dabce
  • Trusted actor: @steipete
  • Trusted role: pull request author; openclaw-secops

Security review is still recommended before merge when the dependency graph change is intentional.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 28, 2026, 4:22 PM ET / 20:22 UTC.

ClawSweeper review

What this changes

This PR adds a bundled internal plugin that lets agent sessions invite, list, revoke, and expire email-based Cloudflare Access visitors.

Merge readiness

⚠️ Ready for maintainer review - 6 items remain

Keep this PR open: the private visitor-plugin direction fits the team deployment, but retargeting its Cloudflare policy configuration can leave expired visitor access active permanently.

Priority: P1
Reviewed head: 02fab86f887f8841de4149b70344aa549e3dabce
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The feature has credible live policy evidence but needs a focused durable-authorization repair before merge.
Proof confidence 🦞 diamond lobster (5/6) Not applicable: This maintainer-created PR includes a redacted live Cloudflare policy trace, while the contributor-proof gate does not apply.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-created PR includes a redacted live Cloudflare policy trace, while the contributor-proof gate does not apply.
Evidence reviewed 6 items Persistent grant lacks its policy target: The introduced durable grant model records identity and expiry but no account, application, or policy binding.
Restart uses only current configuration: Plugin startup constructs its policy client from the currently configured Cloudflare account, application, and policy values.
Expiry sweep deletes orphaned cleanup state: After reconciling the current policy, sweep unconditionally deletes expired local grants; after a target change this cannot revoke the old policy grant.
Findings 1 actionable finding [P1] Preserve grants when configuration is retargeted
Security Needs attention Retargeting can leave external access active: A grant record is deleted after a sweep of the newly configured policy even when the email remains granted in the formerly configured policy.

How this fits together

Visitor Access turns approved agent tool calls into updates of one Cloudflare Access email policy. Plugin state retains issued grants so later expiry sweeps can revoke external access.

flowchart LR
  A[Agent session] --> B[Visitor tools]
  B --> C[Visitor grant service]
  C --> D[Durable grant records]
  C --> E[Cloudflare Access policy]
  D --> F[Expiry sweep]
  F --> E
Loading

Decision needed

Question Recommendation
Should retargeting a Cloudflare Access policy be blocked while this plugin has outstanding visitor grants? Require explicit cleanup before retargeting: Persist the initial target binding and fail closed until grants under that target are revoked or reconciled.

Why: Changing target identity affects durable external authorization and requires an explicit operator-safe lifecycle rather than a best-effort documentation warning.

Before merge

  • Preserve grants when configuration is retargeted (P1) - sweep() deletes every expired local record after updating only the policy selected by current configuration. Because stored grants have no account/application/policy binding, an operator can retarget from policy A to B, sweep an expired record against B, and permanently leave the email granted in A. Persist and validate the original target before cleanup, and fail closed until that target is explicitly reconciled.
  • Resolve security concern: Retargeting can leave external access active - A grant record is deleted after a sweep of the newly configured policy even when the email remains granted in the formerly configured policy.
  • Resolve merge risk (P1) - Changing the configured Cloudflare account, application, or policy while grants remain can delete the only cleanup record without revoking the original external grant.
  • Resolve merge risk (P1) - The changed plugin lacks an end-to-end Gateway-path test proving a sandboxed default visitor session cannot reach the Cloudflare mutation client.
  • Complete next step (P2) - A maintainer must choose the operator-safe retarget lifecycle before the focused durable-state repair can be finalized.

Findings

  • [P1] Preserve grants when configuration is retargeted — extensions/visitor-access/src/visitors.ts:244-270
  • [high] Retargeting can leave external access active — extensions/visitor-access/src/visitors.ts:268
Agent review details

Security

Needs attention: The PR can orphan durable cleanup for an external Access grant after policy retargeting.

PR surface

Source +769, Tests +974, Docs +147, Config +24, Other +13. Total +1927 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 9 769 0 +769
Tests 4 974 0 +974
Docs 1 147 0 +147
Config 3 24 0 +24
Generated 0 0 0 0
Other 1 13 0 +13
Total 18 1927 0 +1927

Review metrics

Metric Value Why it matters
Plugin configuration surface 3 required, 3 optional/defaulted External account, application, credential, policy, expiry, and capacity settings need a safe authorization lifecycle.
Production versus test LOC production +793, tests +974, docs +147, lockfile +13 New feature growth is substantial and should land only with the durable authorization boundary repaired.

Stored data model

Persistent data-model change detected: vector/embedding metadata: extensions/visitor-access/index.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Repair durable target ownership (recommended)
    Bind existing grants to their original Access policy and retain records whenever the configured target differs.
  2. Pause the plugin
    Leave the internal feature unmerged until its authorization lifecycle has a safe retarget path.

Technical review

Best possible solution:

Keep the visitor manager plugin-local, but bind outstanding grants to one immutable Cloudflare target and refuse retargeting until that target has been explicitly reconciled or revoked.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: invite into target A, retarget configuration to B, then run an expiry sweep; the sweep queries B and deletes the local record while A retains the email grant.

Is this the best way to solve the issue?

No. A README warning and manual revoke instruction do not enforce the durable authorization invariant at the state owner.

Full review comments:

  • [P1] Preserve grants when configuration is retargeted — extensions/visitor-access/src/visitors.ts:244-270
    sweep() deletes every expired local record after updating only the policy selected by current configuration. Because stored grants have no account/application/policy binding, an operator can retarget from policy A to B, sweep an expired record against B, and permanently leave the email granted in A. Persist and validate the original target before cleanup, and fail closed until that target is explicitly reconciled.
    Confidence: 0.99
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c417dcf392bf.

Labels

Label changes:

  • add P1: The introduced lifecycle can leave an expired visitor with active external Access authorization.
  • add merge-risk: 🚨 compatibility: An operator configuration retarget can silently invalidate the plugin's ability to clean up pre-existing grants.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-created PR includes a redacted live Cloudflare policy trace, while the contributor-proof gate does not apply.
  • remove P2: Current review triage priority is P1, so this older priority label is no longer current.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P1: The introduced lifecycle can leave an expired visitor with active external Access authorization.
  • merge-risk: 🚨 compatibility: An operator configuration retarget can silently invalidate the plugin's ability to clean up pre-existing grants.
  • merge-risk: 🚨 security-boundary: The defect can preserve external access beyond the recorded grant expiry.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-created PR includes a redacted live Cloudflare policy trace, while the contributor-proof gate does not apply.

Evidence

Security concerns:

  • [high] Retargeting can leave external access active — extensions/visitor-access/src/visitors.ts:268
    A grant record is deleted after a sweep of the newly configured policy even when the email remains granted in the formerly configured policy.
    Confidence: 0.99

What I checked:

Likely related people:

  • steipete: Authored the visitor-access implementation and recent work governing its plugin and sandbox availability. (role: feature and adjacent runtime contributor; confidence: high; commits: 18e0d85501d3, d90267b71dc4; files: extensions/visitor-access/index.ts, extensions/visitor-access/src/visitors.ts, src/agents/sandbox/tool-policy.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Bind grants to their original target and add a retarget-before-expiry regression.
  • Add a Gateway-path test proving the nearest sandboxed unauthorized session cannot reach Cloudflare mutation I/O.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-28T20:11:45.963Z sha 18e0d85 :: needs maintainer review before merge. :: none

The bundled typed-hook contract keeps hook registrations on an explicit
allowlist; visitor-access registers gateway_start for its expiry sweep.
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 28, 2026
@steipete
steipete merged commit 697f773 into main Aug 28, 2026
257 checks passed
@steipete
steipete deleted the feat/visitor-access-plugin branch August 28, 2026 21:28
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
…claw#132073)

* feat(visitor-access): add internal Cloudflare Access visitor grants

Manage a dedicated app-scoped email allow policy without changing maintainer
policies or identity providers. Add invite, revoke, and bounded drift-aware
list tools with durable grant records and default 14-day expiry.

Share one Gateway-owned manager across tool discovery and expiry sweeps;
preserve cleanup records through remote failures and fence stopped services.
Keep this private source-built plugin out of the npm release.

* test(plugins): allow visitor-access gateway_start hook registration

The bundled typed-hook contract keeps hook registrations on an explicit
allowlist; visitor-access registers gateway_start for its expiry sweep.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies-changed PR changes dependency-related files maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant