aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel García <[email protected]>2018-07-18 14:07:28 +0200
committerGitHub <[email protected]>2018-07-18 14:07:28 +0200
commit48e69cebab29585684be4bf22282ff1dd4697d24 (patch)
treed3b0d2929e07aac56ca83722f763431b47ecda76
parent798a3b6a437fca9b20bdc6fd8d883c978eecd59f (diff)
parent2dc1427027cb2c5436ec8ebc4d11d6b0964d803a (diff)
downloadvaultwarden-48e69cebab29585684be4bf22282ff1dd4697d24.tar.gz
vaultwarden-48e69cebab29585684be4bf22282ff1dd4697d24.zip
Merge pull request #92 from mprasil/not_found0.11.0
Return 404 in case the path doesn't match instead of 500
-rw-r--r--Cargo.toml2
-rw-r--r--src/api/web.rs21
2 files changed, 14 insertions, 9 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 2fda83d6..31445dd1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bitwarden_rs"
-version = "0.10.0"
+version = "0.11.0"
authors = ["Daniel García <[email protected]>"]
[dependencies]
diff --git a/src/api/web.rs b/src/api/web.rs
index 8c4ae0a5..33a8d308 100644
--- a/src/api/web.rs
+++ b/src/api/web.rs
@@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
use rocket::request::Request;
use rocket::response::{self, NamedFile, Responder};
use rocket::response::content::Content;
-use rocket::http::ContentType;
+use rocket::http::{ContentType, Status};
use rocket::Route;
use rocket_contrib::{Json, Value};
@@ -49,14 +49,19 @@ struct WebHeaders<R>(R);
impl<'r, R: Responder<'r>> Responder<'r> for WebHeaders<R> {
fn respond_to(self, req: &Request) -> response::Result<'r> {
- let mut res = self.0.respond_to(req)?;
+ match self.0.respond_to(req) {
+ Ok(mut res) => {
+ res.set_raw_header("Referrer-Policy", "same-origin");
+ res.set_raw_header("X-Frame-Options", "SAMEORIGIN");
+ res.set_raw_header("X-Content-Type-Options", "nosniff");
+ res.set_raw_header("X-XSS-Protection", "1; mode=block");
- res.set_raw_header("Referrer-Policy", "same-origin");
- res.set_raw_header("X-Frame-Options", "SAMEORIGIN");
- res.set_raw_header("X-Content-Type-Options", "nosniff");
- res.set_raw_header("X-XSS-Protection", "1; mode=block");
-
- Ok(res)
+ Ok(res)
+ },
+ Err(_) => {
+ Err(Status::NotFound)
+ }
+ }
}
}