dashboard: POST /matrix-account-login + account-aware hive-priv matrix-token write (BE-2)
This commit is contained in:
parent
8799a9aa11
commit
9c480daf0a
6 changed files with 228 additions and 12 deletions
|
|
@ -242,9 +242,23 @@ async fn exec(req: PrivRequest, writer: &mut OwnedWriteHalf) -> Result<(String,
|
|||
PrivRequest::WriteAgentMatrixToken {
|
||||
ref agent_name,
|
||||
ref token,
|
||||
ref account,
|
||||
} => {
|
||||
validate_agent_name(agent_name)?;
|
||||
write_agent_state_file(agent_name, "matrix-token", &format!("{token}\n"))
|
||||
// Build the token filename. `None` → the hive account's
|
||||
// `matrix-token`; `Some(a)` → `matrix-token-<a>`. The account
|
||||
// suffix MUST be validated as a plain identifier (no `/`, `.`,
|
||||
// `..`) before it goes into the filename, or a crafted account
|
||||
// could traverse out of the state dir — `write_agent_state_file`
|
||||
// trusts its `filename` argument.
|
||||
let filename = match account {
|
||||
None => "matrix-token".to_owned(),
|
||||
Some(a) => {
|
||||
validate_name_chars(a)?;
|
||||
format!("matrix-token-{a}")
|
||||
}
|
||||
};
|
||||
write_agent_state_file(agent_name, &filename, &format!("{token}\n"))
|
||||
}
|
||||
|
||||
PrivRequest::RestartMatrixDaemon { ref agent_name } => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue