Skip to main content

agentmux_srv/server/service/
credential.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! `credential` service — the paired CEF host's browser-pane Basic-Auth
5//! credential broker calls this, host→srv, to resolve an identity for a
6//! pane and to look up / save / delete / fill a stored site credential.
7//!
8//! **`Fill` is the only method here that ever returns a plaintext
9//! password**, and it's called exactly once per approved use, at the
10//! moment the host is about to hand the credential to CEF's
11//! `AuthCallback::cont()`. `Lookup` deliberately returns only a masked
12//! username — the credential-approval window (agentmux-cef,
13//! `open_subwindow`-based, see `credential_broker` there) uses `Lookup`
14//! to decide what to *display*, and must never receive the real password
15//! even transiently.
16//!
17//! The sign-ins are Vault `login` entries kept per browser profile
18//! ([`crate::backend::vault::signins`], spec
19//! SPEC_VAULT_GENERATE_CAPTURE_AND_BROWSER_SIGNINS_2026_10_28.md §5.4, §9.3).
20//! The host still calls the pane's key `identity_id`; it is now the tab's
21//! profile, `personal` or `profile:<id>`, and the host passes it back unread.
22//! This module is the `/agentmux/service` RPC surface over them, in the same
23//! shape as [`super::host_ipc`] (the other host→srv service module).
24//!
25//! ## Auth: host-only, NOT the shared `X-AuthKey`
26//!
27//! **Every method on this service requires `args[1]` to be this srv
28//! instance's `AGENTMUX_HOST_REG_SECRET`**, the same host-only credential
29//! `host_ipc.Register` proves (see that module's doc comment and
30//! `Config::host_reg_secret`).
31//!
32//! An earlier cut of this module gated on the instance-wide `X-AuthKey`
33//! alone, reasoning that — unlike `host_ipc.Register`'s
34//! "session-hijack-shaped" port+token — every method here only touches data
35//! scoped to a caller-supplied `identity_id`. **That reasoning was wrong,
36//! and it defeated this feature's entire stated security goal** (reagent P0
37//! on PR #2824). `X-AuthKey` is deliberately re-injected into every spawned
38//! agent's own environment as `AGENTMUX_AUTH_KEY`
39//! (`server/agent_handlers/input.rs`), and `AGENTMUX_BLOCKID` is injected
40//! alongside it. So any agent could, with a plain `curl` from its own Shell
41//! tool:
42//!
43//!   1. `credential.ResolveIdentity` with its own known `block_id` →
44//!      `identity_id`
45//!   2. `credential.Fill` with that `identity_id` plus the origin/realm it
46//!      already knows (it is, after all, the thing browsing that site) →
47//!      **the plaintext password**
48//!
49//! …with no human approval window anywhere in the path. `Fill` uniquely
50//! returns a raw password, which is exactly the class of secret that needed
51//! `host_ipc.Register`'s treatment, not a weaker one.
52//!
53//! The gate is applied to the whole service rather than to `Fill` alone:
54//! `ResolveIdentity` leaks identity_ids, `Lookup` confirms which sites have
55//! saved credentials, and `Save`/`Delete` let an agent plant or destroy
56//! them. None of those are things an agent should reach either, and a
57//! uniform gate cannot be defeated by finding the one method someone forgot
58//! to cover.
59//!
60//! Note this proves *caller is the host*, not *a human approved this exact
61//! use*. That is the boundary the threat model needs — the host is the
62//! process that runs the approval window, so a capability token it mints
63//! for itself would add no defence against the attacker in question (an
64//! agent), only an internal consistency check within the host.
65
66use serde::Deserialize;
67
68use crate::backend::obj::Block;
69use crate::backend::service::{get_arg, WebCallType, WebReturnType};
70use crate::backend::vault::signins::{self, Space};
71
72use super::super::AppState;
73use super::host_ipc::secret_matches;
74
75pub(super) async fn handle_credential_service(state: &AppState, call: &WebCallType) -> WebReturnType {
76    if let Some(rejection) = reject_unless_host_caller(state, call) {
77        return rejection;
78    }
79    match call.method.as_str() {
80        "ResolveIdentity" => handle_resolve_identity(state, call),
81        "Lookup" => handle_lookup(state, call),
82        "Save" => handle_save(state, call),
83        "Delete" => handle_delete(state, call),
84        "Fill" => handle_fill(state, call),
85        "Offer" => handle_offer(state, call),
86        "Settled" => handle_settled(state, call),
87        "Navigated" => handle_navigated(state, call),
88        "Form" => handle_form(state, call),
89        "Signup" => handle_signup(state, call),
90        "SignupSent" => handle_signup_sent(state, call),
91        "ChangeSent" => handle_change_sent(state, call),
92        "FieldOpen" => handle_field_open(state, call),
93        "FieldKey" => handle_field_key(state, call),
94        "FieldClose" => handle_field_close(state, call),
95        _ => WebReturnType::error(format!("unknown credential method: {}", call.method)),
96    }
97}
98
99/// `Some(error)` when the caller failed to prove it's the paired host —
100/// checked for EVERY method before dispatch, so a new method added later is
101/// gated by construction rather than by remembering to gate it.
102///
103/// Fails closed when srv has no secret configured: with nothing to verify
104/// against, "allow" would silently restore the exact bypass this exists to
105/// close. Mirrors `host_ipc::handle_register`'s `None` arm.
106/// The whole security decision, as a pure function of the two secrets —
107/// extracted so it can be tested directly (constructing an `AppState` in a
108/// unit test isn't practical, and this gate is far too load-bearing to
109/// leave to integration coverage alone).
110///
111/// `known == None` → always `false`: fail closed. See the caller.
112///
113/// An EMPTY configured secret is treated the same as an absent one. Without
114/// that, `secret_matches("", "")` compares equal and a caller supplying
115/// nothing — precisely what an agent without the secret sends — would be
116/// admitted, turning the misconfiguration into a skeleton key. `Config`
117/// already `.filter(|s| !s.is_empty())`s this value (`host_reg_secret` in
118/// `config.rs`'s `Config::from_env_and_args`), so
119/// today the case is unreachable; the check is here so the gate stays
120/// correct on its own terms rather than depending on a filter two modules
121/// away that a future refactor could drop.
122pub(crate) fn host_caller_allowed(known: Option<&str>, supplied: &str) -> bool {
123    match known {
124        None => false,
125        Some(known) if known.is_empty() => false,
126        Some(known) => secret_matches(known, supplied),
127    }
128}
129
130fn reject_unless_host_caller(state: &AppState, call: &WebCallType) -> Option<WebReturnType> {
131    let supplied = call.args.get(1).and_then(|v| v.as_str()).unwrap_or("");
132    if host_caller_allowed(state.host_reg_secret.as_deref(), supplied) {
133        return None;
134    }
135    match state.host_reg_secret.as_deref() {
136        None => {
137            tracing::error!(
138                "[credential] REJECTED a {} call — this srv instance has no \
139                 AGENTMUX_HOST_REG_SECRET configured, so it cannot verify the caller is \
140                 really the paired host. Refusing rather than falling back to the shared \
141                 X-AuthKey, which every agent can read from its own environment.",
142                call.method
143            );
144            Some(WebReturnType::error(
145                "credential: srv has no host-registration secret configured — refusing",
146            ))
147        }
148        Some(_) => {
149            tracing::error!(
150                "[credential] REJECTED a {} call — args[1] did not match this srv \
151                 instance's AGENTMUX_HOST_REG_SECRET. Either a caller without that \
152                 credential (an agent riding the shared X-AuthKey never has it) is \
153                 attempting to read stored browser passwords, or a genuine host is out \
154                 of sync with srv's current secret (e.g. after a srv recycle).",
155                call.method
156            );
157            Some(WebReturnType::error(
158                "credential: args[1] does not match this srv instance's host-registration secret",
159            ))
160        }
161    }
162}
163
164#[derive(Deserialize)]
165struct ResolveIdentityArgs {
166    block_id: String,
167}
168
169/// `block_id` → the profile its sign-ins are kept under: `personal` for a tab
170/// with no `browser:identity`, `profile:<id>` for a named profile's tab.
171///
172/// Returns `identity_id: ""` (not an error) for an Incognito tab, which never
173/// saves a sign-in (spec §9.1), and for a block that is gone. The host's
174/// credential broker treats an empty one as "no stored credential" and falls
175/// through to the normal prompt, saving nothing.
176fn handle_resolve_identity(state: &AppState, call: &WebCallType) -> WebReturnType {
177    let args: ResolveIdentityArgs = match get_arg(&call.args, 0) {
178        Ok(a) => a,
179        Err(e) => return WebReturnType::error(format!("credential.ResolveIdentity: {e}")),
180    };
181    let profile = state
182        .mstore
183        .get::<Block>(&args.block_id)
184        .ok()
185        .flatten()
186        .and_then(|b| signins::profile_for_tab(b.meta.get(crate::server::browser_identity::IDENTITY_META_KEY).and_then(|v| v.as_str())))
187        .unwrap_or_default();
188    WebReturnType::success(serde_json::json!({ "identity_id": profile }))
189}
190
191#[derive(Deserialize)]
192struct ProtectionSpaceArgs {
193    identity_id: String,
194    origin: String,
195    realm: String,
196    is_proxy: bool,
197}
198
199impl ProtectionSpaceArgs {
200    /// Where the sign-in is used; `None` for a pane with no profile, which keeps none.
201    fn space(self) -> Option<Space> {
202        signins::is_profile(&self.identity_id).then(|| Space { profile: self.identity_id, origin: self.origin, realm: self.realm, proxy: self.is_proxy })
203    }
204}
205
206fn handle_lookup(state: &AppState, call: &WebCallType) -> WebReturnType {
207    let args: ProtectionSpaceArgs = match get_arg(&call.args, 0) {
208        Ok(a) => a,
209        Err(e) => return WebReturnType::error(format!("credential.Lookup: {e}")),
210    };
211    let Some(space) = args.space() else { return WebReturnType::success(serde_json::json!({ "found": false })) };
212    match signins::find(&state.identity_store, &space) {
213        Ok(Some((_, username))) => WebReturnType::success(serde_json::json!({
214            "found": true,
215            "username": mask_username(&username),
216        })),
217        Ok(None) => lookup_shared(state, &space),
218        Err(e) => {
219            // The exact failure is for srv's log, not the caller: the host's
220            // credential broker treats any error here as "not found" and falls
221            // through to the normal prompt.
222            tracing::warn!("[credential] Lookup failed: {e}");
223            WebReturnType::error("lookup failed")
224        }
225    }
226}
227
228/// The profile holds no sign-in of its own for `space`: in an agent's own profile, the login the person shared with
229/// that agent answers ([`crate::server::vault_prompt_share`]). The answer then also says `shared`, the `agent`, and
230/// `approval`: `granted` when the person already said yes to this use (the host answers the prompt without asking),
231/// `ask` when the host asks them as it does for the profile's own.
232fn lookup_shared(state: &AppState, space: &Space) -> WebReturnType {
233    match crate::server::vault_prompt_share::lookup(state, space) {
234        Ok(Some(found)) => WebReturnType::success(serde_json::json!({
235            "found": true,
236            "username": found.username,
237            "shared": true,
238            "agent": found.agent,
239            "approval": if found.granted { "granted" } else { "ask" },
240        })),
241        Ok(None) => WebReturnType::success(serde_json::json!({ "found": false })),
242        Err(e) => {
243            tracing::warn!("[credential] Lookup of a shared sign-in failed: {e}");
244            WebReturnType::error("lookup failed")
245        }
246    }
247}
248
249/// `us***@example.com` / `ab***` style masking for the approval window's
250/// display — enough for a human to recognize which saved login is being
251/// offered, not enough to be useful if somehow logged or screenshotted
252/// wrong. Keeps at most the first 2 characters before any masking.
253fn mask_username(username: &str) -> String {
254    signins::mask(username)
255}
256
257#[derive(Deserialize)]
258struct SaveArgs {
259    identity_id: String,
260    origin: String,
261    realm: String,
262    is_proxy: bool,
263    username: String,
264    password: String,
265}
266
267fn handle_save(state: &AppState, call: &WebCallType) -> WebReturnType {
268    let args: SaveArgs = match get_arg(&call.args, 0) {
269        Ok(a) => a,
270        Err(e) => return WebReturnType::error(format!("credential.Save: {e}")),
271    };
272    let password = zeroize::Zeroizing::new(args.password);
273    if !signins::is_profile(&args.identity_id) {
274        return WebReturnType::error("save failed: this pane keeps no sign-ins");
275    }
276    let space = Space { profile: args.identity_id, origin: args.origin, realm: args.realm, proxy: args.is_proxy };
277    match signins::save(&state.identity_store, &space, &args.username, &password) {
278        Ok(_) => {
279            crate::server::vault_handlers::publish(state);
280            WebReturnType::success_empty()
281        }
282        Err(e) => {
283            tracing::warn!("[credential] Save failed: {e}");
284            WebReturnType::error("save failed")
285        }
286    }
287}
288
289/// The site turned down a sign-in just filled: the Vault keeps it, marked, and
290/// stops offering it (see [`signins::refused`]); nothing is deleted.
291fn handle_delete(state: &AppState, call: &WebCallType) -> WebReturnType {
292    let args: ProtectionSpaceArgs = match get_arg(&call.args, 0) {
293        Ok(a) => a,
294        Err(e) => return WebReturnType::error(format!("credential.Delete: {e}")),
295    };
296    let Some(space) = args.space() else { return WebReturnType::success_empty() };
297    // The profile's own sign-in is the one that was filled when it has one; otherwise it was a shared one.
298    let refused = match signins::find(&state.identity_store, &space) {
299        Ok(None) => crate::server::vault_prompt_share::refused(state, &space),
300        _ => signins::refused(&state.identity_store, &space),
301    };
302    match refused {
303        Ok(()) => {
304            crate::server::vault_handlers::publish(state);
305            WebReturnType::success_empty()
306        }
307        Err(e) => {
308            tracing::warn!("[credential] Delete failed: {e}");
309            WebReturnType::error("delete failed")
310        }
311    }
312}
313
314#[derive(Deserialize)]
315struct OfferArgs {
316    block_id: String,
317    origin: String,
318    #[serde(default)]
319    username: String,
320    password: Option<String>,
321}
322
323/// A sign-in a page in pane `block_id` sent: held for "Save to Vault?"
324/// ([`crate::server::browser_signin_offer`]), never logged.
325fn handle_offer(state: &AppState, call: &WebCallType) -> WebReturnType {
326    let args: OfferArgs = match get_arg(&call.args, 0) {
327        Ok(a) => a,
328        Err(_) => return WebReturnType::error("credential.Offer: bad arguments"),
329    };
330    let password = args.password.map(zeroize::Zeroizing::new);
331    crate::server::browser_signin_offer::offer(state, &args.block_id, &args.origin, zeroize::Zeroizing::new(args.username), password);
332    WebReturnType::success_empty()
333}
334
335#[derive(Deserialize)]
336struct SettledArgs {
337    block_id: String,
338}
339
340/// Pane `block_id`'s page moved on after a sign-in.
341fn handle_settled(state: &AppState, call: &WebCallType) -> WebReturnType {
342    let args: SettledArgs = match get_arg(&call.args, 0) {
343        Ok(a) => a,
344        Err(e) => return WebReturnType::error(format!("credential.Settled: {e}")),
345    };
346    crate::server::browser_signin_offer::settled(state, &args.block_id);
347    WebReturnType::success_empty()
348}
349
350/// Pane `block_id`'s main frame loaded a new page: a held sign-in learns it
351/// went through, and the old page's sign-in forms are gone.
352fn handle_navigated(state: &AppState, call: &WebCallType) -> WebReturnType {
353    let args: SettledArgs = match get_arg(&call.args, 0) {
354        Ok(a) => a,
355        Err(e) => return WebReturnType::error(format!("credential.Navigated: {e}")),
356    };
357    crate::server::browser_signin_offer::settled(state, &args.block_id);
358    crate::server::browser_signin_fill::navigated(state, &args.block_id);
359    crate::server::browser_signup::navigated(state, &args.block_id);
360    crate::server::browser_signin_list::navigated(state, &args.block_id);
361    WebReturnType::success_empty()
362}
363
364#[derive(Deserialize)]
365struct FieldArgs {
366    block_id: String,
367    #[serde(default)]
368    origin: String,
369    #[serde(default)]
370    role: String,
371    #[serde(default)]
372    text: Option<String>,
373    #[serde(default)]
374    key: String,
375}
376
377fn field_args(call: &WebCallType, what: &str) -> Result<FieldArgs, WebReturnType> {
378    get_arg(&call.args, 0).map_err(|e| WebReturnType::error(format!("credential.{what}: {e}")))
379}
380
381/// The person clicked, or pressed Up or Down, in a login field in pane `block_id`: the list of saved
382/// sign-ins ([`crate::server::browser_signin_list`]). The answer tells the host what the page's listener
383/// is to be told.
384fn handle_field_open(state: &AppState, call: &WebCallType) -> WebReturnType {
385    let args = match field_args(call, "FieldOpen") {
386        Ok(a) => a,
387        Err(e) => return e,
388    };
389    let answer = crate::server::browser_signin_list::open(state, &args.block_id, &args.origin, &args.role, args.text.as_deref().unwrap_or(""));
390    WebReturnType::success(answer.to_json())
391}
392
393/// A key the list took in pane `block_id`.
394fn handle_field_key(state: &AppState, call: &WebCallType) -> WebReturnType {
395    let args = match field_args(call, "FieldKey") {
396        Ok(a) => a,
397        Err(e) => return e,
398    };
399    WebReturnType::success(crate::server::browser_signin_list::key(state, &args.block_id, &args.key).to_json())
400}
401
402/// The person pressed elsewhere on the page in pane `block_id`.
403fn handle_field_close(state: &AppState, call: &WebCallType) -> WebReturnType {
404    let args = match field_args(call, "FieldClose") {
405        Ok(a) => a,
406        Err(e) => return e,
407    };
408    WebReturnType::success(crate::server::browser_signin_list::close(state, &args.block_id).to_json())
409}
410
411#[derive(Deserialize)]
412struct FormArgs {
413    block_id: String,
414    origin: String,
415}
416
417/// A frame of pane `block_id` of `origin` shows a sign-in form.
418fn handle_form(state: &AppState, call: &WebCallType) -> WebReturnType {
419    let args: FormArgs = match get_arg(&call.args, 0) {
420        Ok(a) => a,
421        Err(e) => return WebReturnType::error(format!("credential.Form: {e}")),
422    };
423    crate::server::browser_signin_fill::form(state, &args.block_id, &args.origin);
424    WebReturnType::success_empty()
425}
426
427#[derive(Deserialize)]
428struct SignupArgs {
429    block_id: String,
430    origin: String,
431    #[serde(default)]
432    field: String,
433    #[serde(default)]
434    username: String,
435    #[serde(default)]
436    passwordrules: Option<String>,
437    #[serde(default)]
438    minlength: Option<usize>,
439    #[serde(default)]
440    maxlength: Option<usize>,
441}
442
443/// The person focused a field for a new password in pane `block_id`: its key
444/// button offers a strong password ([`crate::server::browser_signup`]).
445fn handle_signup(state: &AppState, call: &WebCallType) -> WebReturnType {
446    let args: SignupArgs = match get_arg(&call.args, 0) {
447        Ok(a) => a,
448        Err(e) => return WebReturnType::error(format!("credential.Signup: {e}")),
449    };
450    let field = crate::server::browser_signup::Field {
451        origin: args.origin,
452        field: args.field,
453        username: args.username,
454        passwordrules: args.passwordrules,
455        minlength: args.minlength,
456        maxlength: args.maxlength,
457    };
458    crate::server::browser_signup::focused(state, &args.block_id, field);
459    WebReturnType::success_empty()
460}
461
462/// A sign-up form a page in pane `block_id` sent: it confirms the password made
463/// for it, or is offered "Save to Vault?". Never logged.
464fn handle_signup_sent(state: &AppState, call: &WebCallType) -> WebReturnType {
465    let args: OfferArgs = match get_arg(&call.args, 0) {
466        Ok(a) => a,
467        Err(_) => return WebReturnType::error("credential.SignupSent: bad arguments"),
468    };
469    let Some(password) = args.password.filter(|p| !p.is_empty()).map(zeroize::Zeroizing::new) else { return WebReturnType::success_empty() };
470    crate::server::browser_signup::sent(state, &args.block_id, &args.origin, zeroize::Zeroizing::new(args.username), password);
471    WebReturnType::success_empty()
472}
473
474/// A password-change form a page in pane `block_id` sent: the password an agent made for it becomes the
475/// saved sign-in's, or the password is offered "Update password?". Never logged.
476fn handle_change_sent(state: &AppState, call: &WebCallType) -> WebReturnType {
477    let args: OfferArgs = match get_arg(&call.args, 0) {
478        Ok(a) => a,
479        Err(_) => return WebReturnType::error("credential.ChangeSent: bad arguments"),
480    };
481    let Some(password) = args.password.filter(|p| !p.is_empty()).map(zeroize::Zeroizing::new) else { return WebReturnType::success_empty() };
482    crate::server::browser_change::sent(state, &args.block_id, &args.origin, zeroize::Zeroizing::new(args.username), password);
483    WebReturnType::success_empty()
484}
485
486/// The one method that returns a real, unmasked password. Called exactly
487/// once per approved credential use — see this module's own doc comment.
488fn handle_fill(state: &AppState, call: &WebCallType) -> WebReturnType {
489    let args: ProtectionSpaceArgs = match get_arg(&call.args, 0) {
490        Ok(a) => a,
491        Err(e) => return WebReturnType::error(format!("credential.Fill: {e}")),
492    };
493    let Some(space) = args.space() else { return WebReturnType::error("no stored credential for this pane") };
494    // The profile's own sign-in first; in an agent's own profile that holds none, the one shared with the agent.
495    let filled = match signins::fill(&state.identity_store, &space) {
496        Ok(None) => crate::server::vault_prompt_share::fill(state, &space),
497        own => own,
498    };
499    match filled {
500        Ok(Some((username, password))) => {
501            crate::server::vault_handlers::publish(state);
502            WebReturnType::success(serde_json::json!({
503                "username": username,
504                "password": password.as_str(),
505            }))
506        }
507        Ok(None) => WebReturnType::error("no stored credential for this profile/origin/realm"),
508        Err(e) => {
509            tracing::warn!("[credential] Fill failed: {e}");
510            WebReturnType::error("fill failed")
511        }
512    }
513}
514
515#[cfg(test)]
516mod tests {
517    use super::*;
518
519    #[test]
520    fn mask_username_keeps_at_most_two_leading_chars() {
521        assert_eq!(mask_username("alice"), "al***");
522        assert_eq!(mask_username("bob"), "bo***");
523    }
524
525    #[test]
526    fn mask_username_handles_very_short_names() {
527        assert_eq!(mask_username("a"), "*");
528        assert_eq!(mask_username("ab"), "**");
529    }
530
531    #[test]
532    fn mask_username_handles_empty() {
533        assert_eq!(mask_username(""), "*");
534    }
535
536    // ── Host-caller gate (reagent P0 on PR #2824) ────────────────────────
537    //
538    // The attack these close: an agent reads AGENTMUX_AUTH_KEY and
539    // AGENTMUX_BLOCKID from its own environment (both injected at spawn) and
540    // curls credential.Fill to get a stored plaintext password with no human
541    // approval anywhere in the path. The only thing standing between an agent
542    // and that password is this gate, so it gets tested directly.
543
544    const KNOWN: &str = "host-registration-secret-value";
545
546    #[test]
547    fn the_real_host_secret_is_accepted() {
548        assert!(host_caller_allowed(Some(KNOWN), KNOWN));
549    }
550
551    /// The exact shape of the bypass: an agent has `X-AuthKey` (which got it
552    /// this far) but cannot produce `AGENTMUX_HOST_REG_SECRET`, so it sends
553    /// nothing for `args[1]` and `unwrap_or("")` yields an empty string.
554    #[test]
555    fn an_absent_secret_is_rejected() {
556        assert!(!host_caller_allowed(Some(KNOWN), ""));
557    }
558
559    #[test]
560    fn a_wrong_secret_is_rejected() {
561        assert!(!host_caller_allowed(Some(KNOWN), "not-the-secret"));
562        assert!(!host_caller_allowed(Some(KNOWN), "host-registration-secret-valu"));
563        assert!(!host_caller_allowed(Some(KNOWN), "host-registration-secret-value-extra"));
564    }
565
566    /// Fails CLOSED. If srv has no secret configured there is nothing to
567    /// verify against, and treating that as "allow" would silently restore
568    /// the full bypass on exactly the misconfiguration least likely to be
569    /// noticed. Mirrors `host_ipc::handle_register`'s `None` arm.
570    #[test]
571    fn no_configured_secret_rejects_everything_rather_than_allowing_it() {
572        assert!(!host_caller_allowed(None, ""));
573        assert!(!host_caller_allowed(None, KNOWN));
574        assert!(!host_caller_allowed(None, "anything at all"));
575    }
576
577    /// An empty configured secret must not become a skeleton key for callers
578    /// that also send nothing — `Some("")` is a misconfiguration, not a
579    /// credential, and the empty-vs-empty comparison would otherwise pass.
580    #[test]
581    fn an_empty_configured_secret_does_not_admit_an_empty_supplied_secret() {
582        assert!(!host_caller_allowed(Some(""), ""));
583    }
584}