Repository navigation
Let Chrome deliver an organization's policy to Harbor, as a JSON string - #114
Open
samuelcole wants to merge 5 commits into
Open
samuelcole wants to merge 5 commits into
samuelcole wants to merge 5 commits into
Conversation
Chrome only delivers an enterprise policy into chrome.storage.managed if the extension's manifest declares storage.managed_schema. Red first: this test checks the Chrome manifest declares the key, the named schema file exists, and the schema's "policy" property accepts a sample PolicyDocument. Co-Authored-By: Claude Sonnet 5 (Claude Code) <noreply@anthropic.com>
…HBR-163) Chrome only populates chrome.storage.managed for an extension that declares storage.managed_schema in its manifest; Harbor's Chrome manifest didn't, so an organization's enterprise policy for the `policy` key never reached the extension. Firefox doesn't need this (policies.json's "3rdparty" key is enough) and is untouched. - extension/managed-schema.json describes PolicyDocument loosely in Chrome's restricted managed-storage schema format. allow/ask/deny/ preview items are left unconstrained (no "type") because that format has no oneOf/anyOf to express "string or typed rule object". - manifest.chrome.json: storage.managed_schema points at it. - build.mjs copies managed-schema.json into dist-chrome/ only. - docs/PERMISSIONS.md: corrected "Chrome needs a storage.managed_schema ... which Harbor doesn't declare yet" and the FAQ's stale harbor-managed-policy.json filename (the real key is `policy`, set through Chrome's enterprise policy for the extension, not a file Harbor reads). Co-Authored-By: Claude Sonnet 5 (Claude Code) <noreply@anthropic.com>
Chrome's storage.managed_schema format requires exactly one type (or $ref) per node, additionalProperties must be a schema not a boolean and isn't allowed at the root, and there's no union type — so a Harbor rule document (action: string | array | object) can't be described faithfully. The maintainer decided Chrome instead gets `policy` as a JSON string. Red first: these tests describe the new schema shape and the string decoding store.ts doesn't do yet. - chrome-managed-schema.test.ts: replaces the old ad hoc conformance checker with direct checks of Chrome's actual rules (one type/$ref per node, no boolean additionalProperties, none at the root, `policy` typed string), plus a load test that stringifies a PolicyDocument like docs/PERMISSIONS.md's example and expects Policy.load() to accept it. - store.test.ts: a managed policy delivered as a JSON string must produce the same rules as the same document delivered as an object; malformed or wrong-version strings must behave like an invalid object document. Co-Authored-By: Claude Sonnet 5 (Claude Code) <noreply@anthropic.com>
…(HBR-163)
Chrome's docs for storage.managed_schema say each schema node needs
exactly one type or a $ref and that additionalProperties must itself
be a schema, never a boolean, and never appear at the root; an invalid
schema stops Chrome from loading the extension at all. There's also no
union type, while a Harbor rule's `action` can be a string, an array
or an object, so no Chrome schema can describe a rule document
faithfully. Maintainer's decision (2026-11-23): on Chrome, `policy` is
the policy document serialized as a JSON string.
- extension/managed-schema.json: root {type: object, properties:
{policy: {type: string}}}. No additionalProperties anywhere, and
every node has exactly one type.
- store.ts's loadManaged (the `loadManagedPolicy` named in the brief
doesn't exist under that name) now accepts the managed `policy`
value as an object (Firefox) or a JSON string (Chrome), parsing the
string the same way loadUser() already does for the user policy. A
string that fails JSON.parse is caught by the existing try/catch and
treated as "no policy", same as any other error; a string that
parses to a non-version-2 document fails the same `version === 2`
check an invalid object document already fails. No new error path.
- docs/PERMISSIONS.md: "The policy file" and the "centrally manage"
FAQ now say Chrome takes `policy` as a JSON string and Firefox takes
it as an object.
Co-Authored-By: Claude Sonnet 5 (Claude Code) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (Claude Code) <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes HBR-163
Problem
Harbor reads an organization's policy from the browser's managed storage under the key
policy(extension/src/policy/store.ts). Chrome delivers enterprise policy to an extension only if its manifest declares a schema (storage.managed_schema), andmanifest.chrome.jsondidn't, so on Chrome an organization couldn't set a policy. Firefox reads managed storage frompolicies.jsonwithout a schema.A field-by-field schema isn't possible. Chrome's schema format needs exactly one
typeper node and has no union types, and Chrome won't load an extension whose schema is invalid. A Harbor rule'sactioncan be a string, an array or an object.Change
extension/managed-schema.json(new). It declares one property,policy, of type string, with a title and description for the admin console. The maintainer's decision: on Chrome the admin sets the policy document as a JSON string.extension/manifest.chrome.jsondeclaresstorage.managed_schema.extension/build.mjscopies the schema intodist-chromeonly; the Firefox and Safari builds are unchanged.policy/store.tsloadManagedaccepts thepolicyvalue as an object (Firefox) or a JSON string (Chrome). A string that doesn't parse, or isn't a version-2 document, is handled exactly as an invalid object is today: no managed policy.docs/PERMISSIONS.md's policy-file paragraph and the FAQ "Can my organization centrally manage this?" describe both forms. The FAQ used to name aharbor-managed-policy.jsonfile that Harbor never read.Testing
chrome-managed-schema.test.tschecks that the Chrome manifest declares the schema and that every node has exactly onetype, with noadditionalProperties. It also checks thatpolicyis a string, and that the guide's example policy, serialized withJSON.stringify, loads throughPolicy.load().npx vitest run: 145 files, 1617 tests pass.npm run build:chromeshipsmanaged-schema.jsonwith the manifest key.npm run build(Firefox) has nostorageobject.dist-chromeunpacked in Chrome and confirm there's no schema error onchrome://extensions. Then set a policy for the extension (on macOS, a managed preferences profile; or Chrome's policy test page) withpolicyas a JSON string, and confirm the rules appear (for example a deny rule shows in the sidebar's Activity "Why?").What's left
This PR was opened by an AI agent (Claude Code) working for the maintainer.
🤖 Generated with Claude Code