diff --git a/crates/oxidetalis/src/middlewares/mod.rs b/crates/oxidetalis/src/middlewares/mod.rs index 8ec3c79..cdd26ae 100644 --- a/crates/oxidetalis/src/middlewares/mod.rs +++ b/crates/oxidetalis/src/middlewares/mod.rs @@ -24,10 +24,8 @@ use salvo::{ Response, }; -mod public_key; mod signature; -pub use public_key::*; pub use signature::*; use crate::{routes::write_json_body, schemas::MessageSchema}; diff --git a/crates/oxidetalis/src/middlewares/public_key.rs b/crates/oxidetalis/src/middlewares/public_key.rs deleted file mode 100644 index a811db6..0000000 --- a/crates/oxidetalis/src/middlewares/public_key.rs +++ /dev/null @@ -1,32 +0,0 @@ -// OxideTalis Messaging Protocol homeserver implementation -// Copyright (C) 2024 Awiteb , OxideTalis Contributors -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -//! Request sender public key middleware. - -use salvo::{handler, http::StatusCode, FlowCtrl, Request, Response}; - -use crate::utils; - -/// Middleware to check the public key of the request sender. -/// -/// If the public key is valid, the request will be passed to the next handler. -/// Otherwise, a 401 Unauthorized response will be returned. -#[handler] -pub async fn public_key_check(req: &mut Request, res: &mut Response, ctrl: &mut FlowCtrl) { - if let Err(err) = utils::extract_public_key(req) { - super::write_error(res, ctrl, err.to_string(), StatusCode::UNAUTHORIZED) - } -} diff --git a/crates/oxidetalis/src/routes/user.rs b/crates/oxidetalis/src/routes/user.rs index ec57da2..cca02f7 100644 --- a/crates/oxidetalis/src/routes/user.rs +++ b/crates/oxidetalis/src/routes/user.rs @@ -150,6 +150,5 @@ pub fn route() -> Router { .push(Router::with_path("register").post(register)) .push(Router::with_path("whitelist").get(user_whitelist)) .push(Router::with_path("blacklist").get(user_blacklist)) - .hoop(middlewares::public_key_check) .hoop(middlewares::signature_check) } diff --git a/crates/oxidetalis/src/websocket/mod.rs b/crates/oxidetalis/src/websocket/mod.rs index 9f93b2a..c1887cc 100644 --- a/crates/oxidetalis/src/websocket/mod.rs +++ b/crates/oxidetalis/src/websocket/mod.rs @@ -264,5 +264,4 @@ pub fn route() -> Router { Router::new() .push(Router::with_path("chat").get(user_connected)) .hoop(middlewares::signature_check) - .hoop(middlewares::public_key_check) }