feat: add authentication #6

Merged
skylar merged 4 commits from feat/add-authentication into main 2026-07-08 19:12:04 +12:00
Owner

Adds bearer auth for the POST /pump (write) endpoint

Adds bearer auth for the POST /pump (write) endpoint
skylar requested reviews from Sam, fred2104 2026-07-06 23:46:01 +12:00
chore: update cargo hash
All checks were successful
nix-build / build (pull_request) Successful in 2m32s
1cd512aeba
skylar self-assigned this 2026-07-06 23:48:16 +12:00
@ -52,0 +67,4 @@
.ok_or(StatusCode::UNAUTHORIZED)?;
let is_authorized =
bcrypt::verify(header_text, &login_hash).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
Collaborator

This might just be my unfamiliarity with Rust, but shouldn't unhandled errors be caught by your top-level route handler? Like errors bubbling up is actually desired because it means you don't need to manually throw/respond with an internal server error in a bunch of different places.

This might just be my unfamiliarity with Rust, but shouldn't unhandled errors be caught by your top-level route handler? Like errors bubbling up is actually desired because it means you don't need to manually throw/respond with an internal server error in a bunch of different places.
Author
Owner

Kinda a noob but this is my understanding.

In Rust, errors are just values like Result<T, E> and as such means that they don't propagate up on their own and need to be handled explicitly. The ? operator makes the error propagate, but it still needs to be mapped to the type the function expects.

Thinking about what you said though, I think it might be possible to make an implementation of IntoResponse with From that could default to 500 though (when using ? operator) which would be nice. I will look into that and see if I can make it separately. I saw it done similarly here at point 5 which looks applicable.

Kinda a noob but this is my understanding. In Rust, errors are just values like Result<T, E> and as such means that they don't propagate up on their own and need to be handled explicitly. The ? operator makes the error propagate, but it still needs to be mapped to the type the function expects. Thinking about what you said though, I think it might be possible to make an implementation of IntoResponse with From that could default to 500 though (when using ? operator) which would be nice. I will look into that and see if I can make it separately. I saw it done [similarly here](https://dev.to/syeedmdtalha/error-handling-in-axum-31a2) at point 5 which looks applicable.
NachoToast marked this conversation as resolved
NachoToast approved these changes 2026-07-08 19:03:15 +12:00
skylar merged commit 544848ce92 into main 2026-07-08 19:12:04 +12:00
skylar deleted branch feat/add-authentication 2026-07-08 19:12:04 +12:00
skylar referenced this pull request from a commit 2026-07-08 19:12:04 +12:00
skylar removed review requests for Sam, fred2104 2026-07-08 19:12:14 +12:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
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
skylar/pulse!6
No description provided.