feat: audit log #114

Merged
treadful merged 15 commits from feat/database into main 2026-06-05 20:38:07 +00:00
Owner

Implements a basic audit log to log authenticated/authorized actions.

Fixes #113

Implements a basic audit log to log authenticated/authorized actions. Fixes #113
feat: adds JSON metadata to audit log
All checks were successful
/ test-and-check (pull_request) Successful in 3m14s
ac8a957e14
feat: implements some basic audit log filters
All checks were successful
/ test-and-check (pull_request) Successful in 2m55s
32084cc1b8
@ -613,0 +777,4 @@
Ok(d32) => d32,
Err(_) => {
return Err(JotApiError::Client(
"Invalid since".to_string(),
Author
Owner

*before

*before
treadful marked this conversation as resolved
@ -0,0 +94,4 @@
query.push_bind(encode::try_audit_action(act).unwrap());
}
Err(err) => {
trace!(error = err.to_string(), "Invalid action filter");
Author
Owner

Should this error or continue to fail silently?

Should this error or continue to fail silently?
Author
Owner

This should probably fail earlier with a 400. Maybe the DB shouldn't be accepting String user input anyway. The _insert function takes AuditAction as input, this should too.

This should probably fail earlier with a 400. Maybe the DB shouldn't be accepting String user input anyway. The `_insert` function takes `AuditAction` as input, this should too.
treadful marked this conversation as resolved
@ -0,0 +107,4 @@
query.push(" LIMIT ");
query.push_bind(limit);
//.build_query_as::<AuditLogEntry>()
Author
Owner

trash

trash
treadful marked this conversation as resolved
@ -0,0 +18,4 @@
Some(adl) => match &adl.root_key {
Some(rk) => rk,
None => {
debug!("Failed to authenticate for audit log, no root key set");
Author
Owner

make this an warning level log message

make this an warning level log message
Author
Owner

Changed my mind. This is likely to happen often on servers that intentionally don't have a root key configured.

Changed my mind. This is likely to happen often on servers that intentionally don't have a root key configured.
treadful marked this conversation as resolved
@ -0,0 +30,4 @@
let limit = context.req.query::<u32>("limit").unwrap_or(500);
let since_stamp = context.req.query::<u32>("since");
let action_filter = context.req.query::<String>("action");
let key_id_filter = context.req.query::<String>("key_id");
Author
Owner

This query param should be short_id for clarity

This query param should be `short_id` for clarity
treadful marked this conversation as resolved
@ -0,0 +63,4 @@
Ok(m) => match m {
Some(e) => e,
None => {
warn!("Unauthorized: root key not set");
Author
Owner

maybe "root key not initialized"?

maybe "root key not initialized"?
treadful marked this conversation as resolved
@ -172,0 +185,4 @@
.audit_log_insert(
short_id.clone(),
request_address(&context.req),
AuditAction::Upload,
Author
Owner

Maybe this action should be Put?

Maybe this action should be `Put`?
treadful marked this conversation as resolved
@ -193,0 +218,4 @@
AuditLogList,
Delete,
ListFiles,
#[default]
Author
Owner

Why is Register default? Why is there a default at all?

Why is `Register` default? Why is there a default at all?
treadful marked this conversation as resolved
chore: minor PR feedback resolved
All checks were successful
/ test-and-check (pull_request) Successful in 2m40s
34037eadd3
refactor(server): do input formattig in the route, not the Database
All checks were successful
/ test-and-check (pull_request) Successful in 2m22s
64a02ed436
treadful deleted branch feat/database 2026-06-05 20:38:07 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
treadful/jot!114
No description provided.