Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Show '?' in access logs when user is not authenticated
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiBardon committed May 29, 2024
1 parent 54867e3 commit dfff27d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/orangutan-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "orangutan-server"
version = "0.4.4"
version = "0.4.5"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
25 changes: 16 additions & 9 deletions src/orangutan-server/src/routes/debug_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,22 @@ fn access_logs(token: Token) -> Result<String, Status> {
}

let mut res = String::new();
for log in ACCESS_LOGS.read().unwrap().iter() {
let mut user = log.user.clone();
user.sort();
res.push_str(&format!(
"{} | {}: {}\n",
log.timestamp,
user.join(","),
log.path
));
for AccessLog {
timestamp,
user,
path,
} in ACCESS_LOGS.read().unwrap().iter()
{
let mut profiles = user.clone();
// Sort profiles so they are always presented in the same order
profiles.sort();
let user = if profiles.is_empty() {
"?".to_owned()
} else {
profiles.join(",")
};

res.push_str(&format!("{timestamp} | {user}: {path}\n"));
}

Ok(res)
Expand Down

0 comments on commit dfff27d

Please sign in to comment.