feat(login): tokenUser:tokenPass Basic auth + meshctrl --token (VS-1) #21
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/meshctrl-token-vs-1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Wires the existing
createLoginTokenadmin action to a Basic-auth login path on/loginand removes themeshctrl --tokenstub.Changes
Server (
crates/meshcentral-web/src/login.rs):post_loginextracts headers + body bytes directly so the Basic-auth path can short-circuit before the form decoder runs.parse_basic+basic_token_loginhelpers verify the token-user's stored salt/hash, honour theexpirefield, and mint a normalmc_sessioncookie. Success is 200 + Set-Cookie; failure is 401.meshcentral-webgains aserde_urlencodeddirect dep.Client (
crates/meshctrl):login::login_token(client, base, "user:pass")does the Basic-auth POST and captures the cookie.--token(env:MESHCTRL_TOKEN) shortcircuits before the--user/--passrequirement and dispatches throughlogin_token.meshctrlgains abase64direct dep.Test plan
cargo check --workspaceclean.cargo test -p meshcentral-web --test login(3/3 still passing; existing form path unchanged).meshctrl --token <user:pass> list-meshes.Closes VS-1.
Server: `post_login` now inspects `Authorization: Basic <b64>` before parsing the form body. The token-auth path looks up `logintoken-<tokenUser>` (already minted by the existing `createLoginToken` admin action), runs `verify_password` against its stored salt/hash, checks the `expire` field, and mints a normal `mc_session` cookie. Success is 200 with Set-Cookie; failure is 401 (without disclosing which half is wrong). The form-body path is unchanged. Client: `meshctrl --token <user:pass>` (env: `MESHCTRL_TOKEN`) now reaches `meshctrl::login::login_token`, which sends the Basic header and captures the session cookie. The earlier `bail!("not implemented yet")` is gone; `--token` short-circuits before the `--user`/`--pass` requirement so a token-only invocation works without a dummy username. Cargo: `meshcentral-web` gains a `serde_urlencoded` direct dep (Form extractor was replaced by manual decode of the body bytes so the Basic-auth path doesn't need a body); `meshctrl` gains `base64`. #VS-1 State Done