Skip to content

feat(codegen): signInPlace signs Basic, and fakeApi catches a signed token on another host - #643

Merged
leemour merged 2 commits into
mainfrom
feat/basic-sign-in
Nov 17, 2026
Merged

leemour merged 2 commits into
mainfrom
feat/basic-sign-in

Conversation

@leemour

@leemour leemour commented Nov 17, 2026

Copy link
Copy Markdown
Member

Why

The WordPress foundation in the CLI factory plan: WordPress application passwords sign in by HTTP Basic. signInPlace returned undefined for a basic scheme, so:

  • cli-core kept its own basicPlace in service-api-manifest.ts (cli-core #3094);
  • a CLI's fakeApi could not check Basic, and refused every correctly signed request with 401;
  • fakeApi's leak check looked for the raw token only, and a Basic header carries it in base64, so the token sent to another host went unnoticed.

What

  • signInPlace returns Authorization: Basic <base64 of user:password> for a basic scheme and marks the place basic: true. Digest stays undefined.
  • fakeApi also looks for each scheme's signed value when it checks that the token did not go to another host.
  • A changelog entry under "Changed — may break callers": cli-core told Basic apart by undefined. When it bumps to this version, it drops basicPlace and reads place.basic, so that a token scheme stays first when a call offers both.

No overlap with #642: that PR changes sampleOf in fake.ts (lines 232–280); this one changes the sign-in check (lines 360–410).

Testing

  • A new fakeApi test: a Basic sign-in passes, a wrong password gets 401, and the Basic header sent to another host is refused. Without the change the first check fails with 401, and without the leak fix the third passes through.
  • Locally: typecheck, lint, docs:check, the full suite (1252 tests) and the coverage floors pass.

🤖 Generated with Claude Code

leemour and others added 2 commits November 18, 2026 00:12
…token on another host

WordPress application passwords sign in by HTTP Basic. signInPlace returned undefined for a basic scheme, so
cli-core kept its own basicPlace and a CLI's fakeApi refused every correctly signed request with 401.

- signInPlace returns Authorization: Basic <base64 of user:password> for a basic scheme, marked basic: true, so
  a caller can keep a token scheme first when a call offers both. Digest stays undefined.
- fakeApi's leak check looks for each scheme's signed value too: a Basic header carries the token only in
  base64, so a request to another host slipped through before.

cli-core then drops basicPlace and reads place.basic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… changelog says what callers must do

From the review of #643:
- SEC-1: the leak check looked for the whole header value, so base64 in a query string or under another prefix
  slipped through. It now looks for the bare base64 and its URL-encoded form, worked out only when a scheme is Basic.
- BUG-1: the changelog said cli-core already reads place.basic. It now says what a caller must do, and what goes
  wrong until it does.
- The test builds the header with Buffer, uses a non-ASCII user and a password with a colon, and adds a query leak.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leemour
leemour merged commit d47da64 into main Nov 17, 2026
10 checks passed
@leemour
leemour deleted the feat/basic-sign-in branch November 17, 2026 23:16
leemour added a commit that referenced this pull request Nov 17, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leemour leemour mentioned this pull request Nov 17, 2026
leemour added a commit that referenced this pull request Nov 17, 2026
Carries #642 (Attio: union samples, pattern samples, prefixItems, allOf
of unions, upsert), #643 (Basic sign-in) and #644 (tracker nouns).
Minor: the Unreleased section has Added and Changed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
leemour added a commit that referenced this pull request Nov 18, 2026
…ion keys from a field's value (#647)

## Task

C3 of the content category, cli-base half: read a WordPress site's API
from its own index, and give a publishing write a permission key, so the
WordPress CLI's raw `api` group cannot publish past a profile that
denies it.

## Why

WordPress publishes no OpenAPI. And a key that only checks "is this flag
true" cannot say "`status` is `publish`": an agent could publish with a
plain `POST /wp/v2/posts`, whatever `posts.publish` says (RISK-2323 in
the content-category plan).

## What

- **`syncWpJson` / `readWpJson` / `wpJsonToOpenApi`.** One call, `GET
/wp-json/?context=help`, returns every route with its arguments and its
answer's schema. I checked on WordPress 6.9.4 that this schema equals
what `OPTIONS` returns, for all 78 routes callable directly. So the
snapshot is one file, not one `OPTIONS` call per route as the plan said.
- The snapshot drops the site's name, address and links, and keeps
provenance with the hash.
- The converter writes OpenAPI 3.1, and the existing `adaptOpenApi`
reads it. WordPress 6.9.4's `wp/v2` gives 152 operations
(`getWpV2Posts`, `postWpV2PostsById`…), and the generated types, schemas
and manifest compile.
- GET reads and DELETE deletes, with `force` in the query.
POST/PUT/PATCH becomes one POST write.
  - A collection read answers a list.
- An array in the query travels comma-separated. Checked on WordPress:
`include=1,5` returns both posts, while `include=1&include=5` returns
only the last.
- A route whose value may hold a slash (templates, plugins, fonts) is
left out and listed. So is every namespace not offered.
- A route still a pattern, two routes on one path, or an untyped
argument stops generation unless `exclude` names it.
- **`permissions.valueKeys`.** `{ key: "publish", field: "status",
values: ["publish", "future"] }` gives `<group>.publish` to a write
whose `status` enum lists those values, through refs and unions too. On
WordPress 6.9.4 that covers posts, pages, media, blocks, navigation and
menu items.
- A field that defaults to such a value makes the key always apply.
That's templates, template parts and new menu items, where leaving
`status` out publishes.
- A read that filters by the value, and a field without such an enum (a
comment's `status`), get no key.
- `OperationPermission.values` carries it, and the coverage page says
"`status` is publish or future".
- The plan put this in `overrides`. As a rule beside `deletingFlags`,
one entry covers every post type.
- `sha256` and `sortKeys` move to `snapshot.ts`. Discovery and GraphQL
each had a copy.

Not here: cli-core's runtime check of `values` (next PR, on this
release); `wp-json` as a config `spec.kind` in cli-template (the
WordPress pilot); paging: WordPress pages by headers, so `pagination:
true` finds none yet. Basic sign-in in `fakeApi` was already in 0.117.0
(#643); a test here runs the generated WordPress manifest through it.

## Testing

- `src/codegen/wp-json.test.ts` runs on an excerpt of WordPress 6.9.4's
real index. The excerpt is in `test/fixtures/wp-json/`, with GPL notice.
The tests cover:
  - ids and methods, and where each argument goes;
- draft 4 quirks: `required` in both spellings, `bool`, untyped objects,
`patternProperties`;
  - the omissions and the failures;
- publish keys, including the default-publish case, refs, unions and
reads;
  - `fakeApi` with an application password;
  - sync and read, including a password in the URL and a changed hash.
- The full 6.9.4 snapshot was converted and its generated code compiled.
Full suite: 1,272 tests. Typecheck, lint and docs check pass.
- A fresh review found a bypass: templates and menu items default
`status` to `publish`. It's fixed with the rest of that review's
findings. `_method` / `X-HTTP-Method-Override` can't be sent, because
cli-core's `api` group only takes declared parameters.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant