Skip to content

Commit

Permalink
✨ Add default catcher for 403s
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiBardon committed Aug 10, 2024
1 parent f120777 commit 50392b7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/orangutan-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use crate::{
fn rocket() -> _ {
let rocket = rocket::build()
.mount("/", routes::routes())
.register("/", catchers![unauthorized, not_found])
.register("/", catchers![unauthorized, forbidden, not_found])
.manage(ObjectReader::new())
.attach(AdHoc::on_ignite("Tracing subsciber", |rocket| async move {
let subscriber = FmtSubscriber::builder()
Expand Down Expand Up @@ -86,6 +86,11 @@ async fn unauthorized() -> Result<NamedFile, &'static str> {
not_found().await
}

#[catch(403)]
async fn forbidden() -> &'static str {
"403 Forbidden. Token revoked."
}

/// TODO: Re-enable Basic authentication
/// (`.raw_header("WWW-Authenticate", "Basic realm=\"This page is protected. Please log in.\"")`).
#[catch(404)]
Expand Down

0 comments on commit 50392b7

Please sign in to comment.