2026-03-04 05:23:42 +00:00
|
|
|
use super::{RpcHandler, DEV_DEFAULT_PASSWORD};
|
|
|
|
|
use anyhow::Result;
|
|
|
|
|
|
|
|
|
|
impl RpcHandler {
|
|
|
|
|
pub(super) async fn handle_auth_login(
|
|
|
|
|
&self,
|
|
|
|
|
params: Option<serde_json::Value>,
|
|
|
|
|
) -> Result<serde_json::Value> {
|
|
|
|
|
let params = params.ok_or_else(|| anyhow::anyhow!("Missing params"))?;
|
|
|
|
|
let password = params
|
|
|
|
|
.get("password")
|
|
|
|
|
.and_then(|v| v.as_str())
|
|
|
|
|
.ok_or_else(|| anyhow::anyhow!("Missing password"))?;
|
|
|
|
|
|
|
|
|
|
let is_setup = self.auth_manager.is_setup().await?;
|
|
|
|
|
if !is_setup {
|
|
|
|
|
// Dev mode: allow default password so UI can log in without running setup
|
|
|
|
|
if self.config.dev_mode && password == DEV_DEFAULT_PASSWORD {
|
|
|
|
|
return Ok(serde_json::Value::Null);
|
|
|
|
|
}
|
|
|
|
|
return Err(anyhow::anyhow!(
|
|
|
|
|
"User not set up. Please complete setup first."
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let valid = self.auth_manager.verify_password(password).await?;
|
|
|
|
|
if !valid {
|
|
|
|
|
return Err(anyhow::anyhow!("Password Incorrect"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(serde_json::Value::Null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(super) async fn handle_auth_logout(&self) -> Result<serde_json::Value> {
|
|
|
|
|
Ok(serde_json::Value::Null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(super) async fn handle_auth_change_password(
|
|
|
|
|
&self,
|
|
|
|
|
params: Option<serde_json::Value>,
|
2026-03-12 00:19:30 +00:00
|
|
|
session_token: &Option<String>,
|
2026-03-04 05:23:42 +00:00
|
|
|
) -> Result<serde_json::Value> {
|
|
|
|
|
let params = params.ok_or_else(|| anyhow::anyhow!("Missing params"))?;
|
|
|
|
|
let current_password = params
|
|
|
|
|
.get("currentPassword")
|
|
|
|
|
.and_then(|v| v.as_str())
|
|
|
|
|
.ok_or_else(|| anyhow::anyhow!("Missing currentPassword"))?;
|
|
|
|
|
let new_password = params
|
|
|
|
|
.get("newPassword")
|
|
|
|
|
.and_then(|v| v.as_str())
|
|
|
|
|
.ok_or_else(|| anyhow::anyhow!("Missing newPassword"))?;
|
|
|
|
|
let also_change_ssh = params
|
|
|
|
|
.get("alsoChangeSsh")
|
|
|
|
|
.and_then(|v| v.as_bool())
|
|
|
|
|
.unwrap_or(true);
|
|
|
|
|
|
|
|
|
|
self.auth_manager
|
|
|
|
|
.change_password(current_password, new_password, also_change_ssh)
|
|
|
|
|
.await?;
|
|
|
|
|
|
2026-03-12 00:19:30 +00:00
|
|
|
// Session rotation: invalidate all other sessions, rotate the caller's session
|
|
|
|
|
if let Some(token) = session_token {
|
|
|
|
|
self.session_store.invalidate_all_except(token).await;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(serde_json::json!({ "success": true, "session_rotated": true }))
|
2026-03-04 05:23:42 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 09:12:16 +00:00
|
|
|
pub(super) async fn handle_auth_is_setup(&self) -> Result<serde_json::Value> {
|
|
|
|
|
let is_setup = self.auth_manager.is_setup().await?;
|
|
|
|
|
Ok(serde_json::json!(is_setup))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(super) async fn handle_auth_setup(
|
|
|
|
|
&self,
|
|
|
|
|
params: Option<serde_json::Value>,
|
|
|
|
|
) -> Result<serde_json::Value> {
|
|
|
|
|
// Prevent re-setup if already set up
|
|
|
|
|
let is_setup = self.auth_manager.is_setup().await?;
|
|
|
|
|
if is_setup {
|
|
|
|
|
return Err(anyhow::anyhow!("Already set up. Use auth.changePassword to change."));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let params = params.ok_or_else(|| anyhow::anyhow!("Missing params"))?;
|
|
|
|
|
let password = params
|
|
|
|
|
.get("password")
|
|
|
|
|
.and_then(|v| v.as_str())
|
|
|
|
|
.ok_or_else(|| anyhow::anyhow!("Missing password"))?;
|
|
|
|
|
|
|
|
|
|
if password.len() < 8 {
|
|
|
|
|
return Err(anyhow::anyhow!("Password must be at least 8 characters"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.auth_manager.setup_user(password).await?;
|
|
|
|
|
Ok(serde_json::json!(true))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 05:23:42 +00:00
|
|
|
pub(super) async fn handle_auth_onboarding_complete(&self) -> Result<serde_json::Value> {
|
|
|
|
|
self.auth_manager.complete_onboarding().await?;
|
|
|
|
|
Ok(serde_json::json!(true))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(super) async fn handle_auth_is_onboarding_complete(&self) -> Result<serde_json::Value> {
|
|
|
|
|
let complete = self.auth_manager.is_onboarding_complete().await?;
|
|
|
|
|
Ok(serde_json::json!(complete))
|
|
|
|
|
}
|
|
|
|
|
|
security+feat: v1.3.0 — pentest remediation, container reliability, UI overhaul
Security (33 pentest findings addressed):
- CRITICAL: backend binds 127.0.0.1, path traversal in tor.rs/dwn fixed
- HIGH: federation requires signatures, XSS login redirect, RBAC viewer restricted
- HIGH: tar slip prevention, S3 SSRF validation, backup ID validation
- MEDIUM: remember-me random secret, TOTP session rotation, password re-auth
- LOW: CSP unsafe-inline removed, CORS dev-only, onion/webhook validation
Container reliability:
- Memory limits on all 37 containers (OOM prevention)
- Exited vs stopped state distinction with health-aware status badges
- Crash recovery coordination (no more restart cascade)
- User-stopped tracking survives reboots
- Tiered boot recovery (databases → core → services → apps)
UI:
- Wallet TransactionsModal, health-aware app status badges
- Restart button on containers, exited/crashed red state
- Mesh view overhaul, glass button updates, BaseModal/ToggleSwitch
- Apps sticky header removed, dev faucet, mutable mock wallet
Infrastructure:
- LND REST port 8080 exposed over Tor (LND Connect fix)
- Nginx cookie_session fix, deploy script Tor config updated
- Dev environment: podman auto-start, boot mode simulation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 12:44:31 +00:00
|
|
|
pub(super) async fn handle_auth_reset_onboarding(
|
|
|
|
|
&self,
|
|
|
|
|
params: Option<serde_json::Value>,
|
|
|
|
|
) -> Result<serde_json::Value> {
|
|
|
|
|
let params = params.ok_or_else(|| anyhow::anyhow!("Missing params"))?;
|
|
|
|
|
let password = params
|
|
|
|
|
.get("password")
|
|
|
|
|
.and_then(|v| v.as_str())
|
|
|
|
|
.ok_or_else(|| anyhow::anyhow!("Missing password — re-authentication required"))?;
|
|
|
|
|
|
|
|
|
|
let valid = self.auth_manager.verify_password(password).await?;
|
|
|
|
|
if !valid {
|
|
|
|
|
return Err(anyhow::anyhow!("Password Incorrect"));
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 05:23:42 +00:00
|
|
|
self.auth_manager.reset_onboarding().await?;
|
|
|
|
|
Ok(serde_json::json!(true))
|
|
|
|
|
}
|
|
|
|
|
}
|