Add vault-level access control

This commit is contained in:
Andras Schmelczer 2025-03-29 12:25:15 +00:00
parent a8c813b9a7
commit b3e98d32b6
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
17 changed files with 86 additions and 41 deletions

View file

@ -20,7 +20,7 @@ use crate::{
AppState,
database::models::{DocumentVersionWithoutContent, VaultId, VaultUpdateId},
},
errors::{SyncServerError, server_error, unauthorized_error},
errors::{SyncServerError, server_error, unauthenticated_error},
};
// This is required for aide to infer the path parameter types and names
@ -73,9 +73,9 @@ async fn websocket(
let (mut sender, mut receiver) = stream.split();
if let Some(Ok(Message::Text(token))) = receiver.next().await {
auth(&state, &token)?;
auth(&state, &token, &vault_id)?;
} else {
return Err(unauthorized_error(anyhow::anyhow!(
return Err(unauthenticated_error(anyhow::anyhow!(
"Failed to authenticate"
)));
}