You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 44292ad
Browse filesBrowse the repository at this point in the historyBrowse files
Accept unnamespaced names; make the prototype mapping exact
Operator decision, and it replaces the loosest thing in the build.
wp_get_secret( 'api_key' ) is now a legal call that reports through
_doing_it_wrong(). That contradicts the build brief's §5.5 ("no
unnamespaced form and no escape hatch for one") deliberately: code
written against the Displace prototype uses a flat keyspace, and
refusing those names means every call site must be rewritten before any
of it can be ported. Accepting them makes the move incremental, and the
notice becomes a running list of which call sites still need a
namespace. The relaxation is narrow -- it drops the "exactly one slash"
rule and nothing else. Character rules, length cap, and rejection of
uppercase/spaces/dots all still apply, and two-plus slashes are still
invalid.
That in turn removes the reason the prototype fallback store existed in
its old shape. It used to drop the namespace, so
wp_get_secret( 'anything/api_key' ) inherited Displace's 'api_key'.
Now the correspondence is identity: an unnamespaced name reaches its own
prototype key, a namespaced name reaches nothing. Nothing is rewritten
or inferred, and a caller can no longer end up silently wired to
prototype data through a name it did not choose.
The migrator's default namespace changes from 'legacy' to none, which
is not cosmetic. If it kept prefixing, `migrate-legacy` would write
'legacy/api_key' while a plain wp_get_secret( 'api_key' ) still missed,
fell through to the untouched prototype row, and upgraded it a second
time -- one prototype secret, two current-format records, diverging the
moment either was rotated. Pinned by
test_migrating_then_reading_does_not_produce_a_second_copy(), which
asserts exactly one _wp_secret_ row survives both paths. --namespace and
--map remain for putting a migrated secret somewhere specific.
Test churn worth noting: a number of tests used an unnamespaced name as
their example of an *invalid* name, which is no longer true. Those now
use a name that is invalid on its own terms ('Not A Valid Name') so they
keep testing rejection rather than accidentally testing the new notice
path. The validate-name provider also had two array entries keyed
'two slashes', so one was silently overwriting the other -- caught while
editing it, now one case plus new coverage for the accepted form.
Plugin URI points at ericmann/secrets-api rather than a
WordPress/secrets-api that does not exist.
Recorded as open question #17, including the consequences that are easy
to miss: an unnamespaced name gives a future cross-namespace access
check nothing to check against, and two plugins both choosing 'api-key'
collide silently.
414 tests, 937 assertions single-site, 949 multisite. Lint, compat,
phpstan clean.
Copy file name to clipboardExpand all lines: docs/open-questions.md
+38-6Lines changed: 38 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,7 @@ hardens**, because names are the hardest thing to change after adoption.
93
93
|`secret_invalid_argument` (`WP_SECRETS_ERROR_INVALID_ARGUMENT`) | Added when #12 converted caller-error throws to WP_Error; the proposal's error list predates that decision | A genuinely new error *string*, not just a new constant name — the only one on this list that is |
94
94
|`WP_SECRETS_CAP_MANAGE` / `WP_SECRETS_CAP_MANAGE_NETWORK`| Wrappers over the two published capability strings | Strings match the proposal exactly (`manage_secrets`, `manage_network_secrets`); only the constant names are new |
95
95
|`WP_SECRETS_MAX_NAME_LENGTH` (172), `WP_SECRETS_RECORD_VERSION` (1) | A cap and a format version both have to exist | 172 is derived, not published — see the note under §5.5 in the build brief about subtracting the option prefix from 191 |
96
+
| Accepting unnamespaced names at all | Adoption path for prototype-era code; see #17| Contradicts the brief's §5.5 outright. The proposal never discusses naming, so this is unpublished either way -- but it is the one place the implementation deliberately loosened a stated rule rather than adding to it |
96
97
| The `wp-content/secrets.php` drop-in filename, and `$GLOBALS['wp_secrets_store']` / `$GLOBALS['wp_secrets_keyring']`| The proposal describes drop-in-style replacement without naming the file or the mechanism | A drop-in filename is effectively permanent once hosts ship against it, in the same way `object-cache.php` is |
97
98
98
99
Not on this list, deliberately: `Secrets_API_Legacy_Reader`, `Secrets_API_Migrator`, and
@@ -350,12 +351,11 @@ returns here. So an AI-plugin site upgrades one secret at a time, on first use,
350
351
nobody running anything -- which is the outcome that actually minimises broken
351
352
sites. It is one-way, one-time, and flagged `needs_rotation`.
352
353
353
-
The mapping is namespace-agnostic: `wp_get_secret( 'ai/api_key' )` inherits the
354
-
prototype's `api_key`. Requiring an exact namespace match would mean guessing which
355
-
namespace the adopting plugin picks, and guessing wrong is the broken site we are
356
-
trying to avoid. This is not a new exposure -- the prototype's keyspace is already
357
-
global, so any plugin could read any prototype secret by bare key -- but it is worth
358
-
knowing, and it is why the inherited copy is always a new row rather than a move.
354
+
The mapping is exact: `wp_get_secret( 'api_key' )` inherits the prototype's
355
+
`api_key`, and a namespaced name inherits nothing, because the prototype had no
356
+
namespaces and so never owned that name. An earlier revision dropped the namespace
357
+
instead, letting any namespace claim any prototype row; that was removed in favour
358
+
of accepting the unnamespaced form outright — see #17.
359
359
360
360
**Non-interference is the load-bearing promise.** The prototype's rows are never
361
361
written to or deleted, by anything, ever. The two option namespaces do not overlap
@@ -416,6 +416,38 @@ install` inside an already-running container) rather than this one.
416
416
417
417
---
418
418
419
+
## 17. 🟢 Unnamespaced secret names are accepted — CLOSED
420
+
421
+
**Operator decision: `wp_get_secret( 'api_key' )` works, and reports through
422
+
`_doing_it_wrong()`.** This contradicts the build brief's §5.5 ("There is no unnamespaced form
423
+
and no escape hatch for one"), deliberately.
424
+
425
+
The reasoning is adoption, the same as everything else in #15. Code written against the Displace
426
+
prototype uses a flat keyspace. Refusing those names means every call site has to be rewritten
427
+
before *any* of it can be ported, which makes the move all-or-nothing for exactly the team we are
428
+
trying not to break. Accepting them makes it incremental: swap `get_secret()` for
429
+
`wp_get_secret()`, keep the key, add the namespace later — and the notice is a running list of
430
+
which call sites still need one.
431
+
432
+
What this replaced is worth recording, because it was worse. The prototype fallback store used to
433
+
map `namespace/key` onto the prototype's `key` by dropping the namespace, so
434
+
`wp_get_secret( 'anything/api_key' )` inherited it. That worked and was not a new exposure (the
435
+
prototype's keyspace was already global), but any namespace could silently claim any prototype
436
+
row, and a caller had no way to see which of its names were wired to prototype data. Making the
437
+
unnamespaced form legal removed the need for the rewrite entirely.
438
+
439
+
**The relaxation is narrow.** It drops the "exactly one slash" requirement and nothing else: an
440
+
unnamespaced name is still held to the same character rules, the same length cap, and the same
441
+
rejection of anything with uppercase, spaces, or dots. Two or more slashes are still invalid.
442
+
443
+
**Consequences that are easy to miss:** an unnamespaced name has no namespace for a future
444
+
cross-namespace access check to check against (#6), and two plugins both choosing `api-key`
445
+
collide silently. Namespaced names remain the documented default everywhere, and
446
+
`wp secret migrate-legacy` keeps `--namespace` and `--map` for putting a migrated secret
447
+
somewhere specific.
448
+
449
+
---
450
+
419
451
## Resolved
420
452
421
453
Decisions that were open and are now closed, kept so the reasoning is not lost.
* Description: Feature plugin for the WordPress Secrets API proposed for 7.2. Encrypted, versioned credential storage with pluggable storage and keyring back ends.
6
6
* Version: 0.1.0
7
7
* Requires at least: 6.6
@@ -14,8 +14,9 @@
14
14
*/
15
15
16
16
/*
17
-
* The slug and display name above are provisional. See docs/open-questions.md #2 -- a
18
-
* neutral, non-Displace-branded slug needs a human decision before any .org submission.
17
+
* Plugin URI points at the current home, which is private for now. Availability of
18
+
* the slug on WordPress.org is settled at submission, not here -- see
__( 'Secret names may contain only lowercase letters, numbers, hyphens, and underscores, and must not start or end with a hyphen or underscore.', 'default' )
245
+
);
246
+
}
247
+
248
+
/*
249
+
* Reported here rather than at each public entry point: this is the one
250
+
* place that decides what a name is, so a caller cannot reach the store
251
+
* with an unnamespaced name without passing through it.
252
+
*/
253
+
_doing_it_wrong(
254
+
__FUNCTION__,
255
+
sprintf(
256
+
/* translators: %s: The unnamespaced secret name. */
257
+
__( 'The secret name "%s" has no namespace. Namespaced names ("plugin-slug/secret-name") group secrets by owner and give a future access check something to check against; unnamespaced names are supported only so that code written against the Displace prototype can be ported incrementally.', 'default' ),
258
+
$name
259
+
),
260
+
'7.2.0'
226
261
);
262
+
263
+
returntrue;
227
264
}
228
265
229
266
$segments = explode( '/', $name );
@@ -237,8 +274,6 @@ function wp_secrets_validate_name( $name ) {
0 commit comments