Skip to content

Commit 3ccb4ab

Browse files
authored
Authorization middleware supports cookie or authorization header (#594)
* Authorization middleware supports cookie or authorization header * fix typo for 'message' in error response
1 parent 19e68e0 commit 3ccb4ab

File tree

5 files changed

+190
-48
lines changed

5 files changed

+190
-48
lines changed

Cargo.lock

+135-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dim-web/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ nightfall = { git = "https://github.com/Dusk-Labs/nightfall", tag = "0.3.12-rc4"
2020
] }
2121

2222
axum = { version = "0.6.20", features = ["ws", "http2", "macros", "multipart"] }
23+
axum-extra = { version = "0.9.0", features = ["cookie"] }
2324
cfg-if = "1.0.0"
2425
chrono = { version = "0.4.19", features = ["serde"] }
2526
displaydoc = "0.2.3"

dim-web/src/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl IntoResponse for DimErrorWrapper {
4949

5050
let resp = serde_json::json!({
5151
"error": serde_json::json!(&self.0)["error"],
52-
"messsage": self.0.to_string(),
52+
"message": self.0.to_string(),
5353
});
5454
(status, serde_json::to_string(&resp).unwrap()).into_response()
5555
}

dim-web/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub mod error;
2727
pub use error::DimErrorWrapper;
2828

2929
pub mod middleware;
30-
pub use middleware::verify_cookie_token;
30+
pub use middleware::verify_token;
3131

3232
#[derive(Debug, Clone)]
3333
pub struct AppState {
@@ -385,7 +385,7 @@ pub async fn start_webserver(
385385
.merge(stream_routes())
386386
.route_layer(axum::middleware::from_fn_with_state(
387387
app.clone(),
388-
verify_cookie_token,
388+
verify_token,
389389
))
390390
// --- End of routes authenticated by Axum middleware ---
391391
.merge(public_auth_routes())

0 commit comments

Comments
 (0)