[control] Share and token fixes: settle the epoch before minting, mint in its own task so a dropped client frees its key, token checks off the async threads, CLI refuses to run as another user than the state dir's owner

This commit is contained in:
2026-11-07 19:20:05 +01:00
parent 43918943da
commit 7d3af00720
6 changed files with 102 additions and 13 deletions
+8 -2
View File
@@ -370,8 +370,14 @@ async fn guard(State(st): State<Arc<AppState>>, mut req: Request, next: Next) ->
let auth = req
.headers()
.get(header::AUTHORIZATION)
.and_then(|v| v.to_str().ok());
let tok = st.ctl.tokens.check(auth).map_err(|r| {
.and_then(|v| v.to_str().ok())
.map(str::to_owned);
// The token store takes a file lock: off the async threads.
let ctl = st.ctl.clone();
let checked = tokio::task::spawn_blocking(move || ctl.tokens.check(auth.as_deref()))
.await
.unwrap_or(Err(Refusal::Unknown));
let tok = checked.map_err(|r| {
let (code, params) = match r {
Refusal::Missing => ("token.missing", Params::new()),
Refusal::Unknown => ("token.unknown", Params::new()),