mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2024-12-02 13:06:58 +01:00
Merge pull request #92 from mprasil/not_found
Return 404 in case the path doesn't match instead of 500
This commit is contained in:
commit
48e69cebab
2 changed files with 14 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "bitwarden_rs"
|
name = "bitwarden_rs"
|
||||||
version = "0.10.0"
|
version = "0.11.0"
|
||||||
authors = ["Daniel García <dani-garcia@users.noreply.github.com>"]
|
authors = ["Daniel García <dani-garcia@users.noreply.github.com>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
|
||||||
use rocket::request::Request;
|
use rocket::request::Request;
|
||||||
use rocket::response::{self, NamedFile, Responder};
|
use rocket::response::{self, NamedFile, Responder};
|
||||||
use rocket::response::content::Content;
|
use rocket::response::content::Content;
|
||||||
use rocket::http::ContentType;
|
use rocket::http::{ContentType, Status};
|
||||||
use rocket::Route;
|
use rocket::Route;
|
||||||
use rocket_contrib::{Json, Value};
|
use rocket_contrib::{Json, Value};
|
||||||
|
|
||||||
|
@ -49,14 +49,19 @@ struct WebHeaders<R>(R);
|
||||||
|
|
||||||
impl<'r, R: Responder<'r>> Responder<'r> for WebHeaders<R> {
|
impl<'r, R: Responder<'r>> Responder<'r> for WebHeaders<R> {
|
||||||
fn respond_to(self, req: &Request) -> response::Result<'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");
|
Ok(res)
|
||||||
res.set_raw_header("X-Frame-Options", "SAMEORIGIN");
|
},
|
||||||
res.set_raw_header("X-Content-Type-Options", "nosniff");
|
Err(_) => {
|
||||||
res.set_raw_header("X-XSS-Protection", "1; mode=block");
|
Err(Status::NotFound)
|
||||||
|
}
|
||||||
Ok(res)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue