1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//! Secret names the platform mints for itself, and the guard that keeps an
//! author-supplied reference off them.
//!
//! A `ToolService` carries `spec.auth.bearerSecretRef` — a Secret name chosen
//! by whoever wrote the resource — and a remote URL, also author-chosen. Both
//! the control plane (when it composes a turn's connectors) and this crate's
//! reconciler (when it health-checks one) resolve that Secret and present its
//! value as an `Authorization` header to that URL. Without a guard, naming
//! [`STATE_ATTESTATION_SECRET`] ships the key the journal signs its roots with
//! to a URL the author controls, and forged attestations defeat verified
//! replay. Naming a `polychrome-wallet-key-…` Secret does the same for the
//! control plane's signing roles.
//!
//! So the names live here, in the crate that also defines
//! [`BearerSecretRef`](crate::BearerSecretRef), and every path that resolves
//! one calls [`check_secret_ref`] first. `polychrome state bootstrap` — the
//! command that writes this material — names the same constants, so the
//! written set and the refused set cannot drift.
//!
//! The guard **refuses**; it never sanitizes. A connector naming reserved
//! material is dropped rather than dialed without auth, because "resolve to
//! empty and dial anyway" is still an author-controlled request carrying
//! whatever the remote infers from an unauthenticated call.
/// Secret holding the State certificate authority's certificate and key. It
/// mints the client and server identities for both planes, so it is the
/// sharpest single name on this list.
///
/// `polychrome state bootstrap` writes it to a namespace of its own, which is
/// not the namespace a resolver reads a `bearerSecretRef` from — so a
/// reference to this name resolves to nothing there anyway. It stays reserved
/// regardless: the name belongs to the platform, and a cluster mid-migration
/// still has the real authority under it.
pub const STATE_MTLS_CA_SECRET: &str = "polychrome-state-mtls-ca";
/// Secret holding State's own server identity and key.
pub const STATE_MTLS_SERVER_SECRET: &str = "polychrome-state-mtls-server";
/// Secret holding the control plane's client identity for the State dial, plus
/// the workload identity State admits it under.
pub const STATE_MTLS_CLIENT_SECRET: &str = "polychrome-state-mtls-client";
/// Secret holding the key the journal signs its roots with.
pub const STATE_ATTESTATION_SECRET: &str = "polychrome-state-attestation";
/// The State plane's four fixed Secret names, in the order
/// `polychrome state bootstrap` writes them.
///
/// The first goes to the authority namespace and the other three to the
/// target namespace. All four are refused here, because the guard reserves
/// names rather than locations.
pub const RESERVED_SECRET_NAMES: = ;
/// Prefix of the per-role Secrets holding the control plane's signing keys.
///
/// The full name appends the hex sha256 of the custody reference, which is
/// derivable from public strings — so the whole prefix is reserved, not the
/// individual digests.
pub const CONTROL_KEY_SECRET_PREFIX: &str = "polychrome-wallet-key-";
/// A resolution refused because the referenced name belongs to the platform's
/// own key material rather than to a connector's token.
///
/// The message names the reservation, not the contents: after the authority
/// moved out of the target namespace, `polychrome-state-mtls-ca` is a reserved
/// name there that holds nothing at all, and it is still refused.
/// Refuse an author-supplied Secret name that points at platform key material.
///
/// Call this before reading any Secret whose name came out of a custom
/// resource's spec.
///
/// # Errors
///
/// Returns [`ReservedSecret`] when `name` is one of [`RESERVED_SECRET_NAMES`]
/// or starts with [`CONTROL_KEY_SECRET_PREFIX`].