Add csrf protection

This commit is contained in:
Trinity Pointard
2018-06-24 18:58:57 +02:00
parent 3bc90e71d4
commit 30e9620d0a
10 changed files with 135 additions and 13 deletions
+15
View File
@@ -20,3 +20,18 @@ fn server_error(req: &Request) -> Template {
"account": user
}))
}
#[derive(FromForm)]
pub struct Uri {
target: String,
}
#[post("/csrf-violation?<uri>")]
fn csrf_violation(uri: Option<Uri>) -> Template {
if let Some(uri) = uri {
eprintln!("Csrf violation while acceding \"{}\"", uri.target)
}
Template::render("errors/csrf", json!({
"error_message":""
}))
}