vw_small

Hardened fork of Vaultwarden (https://github.com/dani-garcia/vaultwarden) with fewer features.
git clone https://git.philomathiclife.com/repos/vw_small
Log | Files | Refs | README

emergency_access.rs (6406B)


      1 use crate::{auth::Headers, error::Error, util::NumberOrString};
      2 use rocket::{serde::json::Json, Route};
      3 use serde_json::Value;
      4 
      5 pub fn routes() -> Vec<Route> {
      6     routes![
      7         accept_invite,
      8         approve_emergency_access,
      9         confirm_emergency_access,
     10         delete_emergency_access,
     11         get_contacts,
     12         get_emergency_access,
     13         get_grantees,
     14         initiate_emergency_access,
     15         password_emergency_access,
     16         policies_emergency_access,
     17         post_delete_emergency_access,
     18         post_emergency_access,
     19         put_emergency_access,
     20         reject_emergency_access,
     21         resend_invite,
     22         send_invite,
     23         takeover_emergency_access,
     24         view_emergency_access,
     25     ]
     26 }
     27 #[allow(clippy::needless_pass_by_value)]
     28 #[get("/emergency-access/trusted")]
     29 fn get_contacts(_headers: Headers) -> Json<Value> {
     30     Json(json!({
     31       "data": Vec::<Value>::new(),
     32       "object": "list",
     33       "continuationToken": null
     34     }))
     35 }
     36 #[allow(clippy::needless_pass_by_value)]
     37 #[get("/emergency-access/granted")]
     38 fn get_grantees(_headers: Headers) -> Json<Value> {
     39     Json(json!({
     40       "data": Vec::<Value>::new(),
     41       "object": "list",
     42       "continuationToken": null
     43     }))
     44 }
     45 const ACCESS_NOT_ALLOWED_MSG: &str = "Emergency access is not allowed.";
     46 #[allow(unused_variables, clippy::needless_pass_by_value)]
     47 #[get("/emergency-access/<emer_id>")]
     48 fn get_emergency_access(emer_id: &str, _headers: Headers) -> Error {
     49     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
     50 }
     51 
     52 #[derive(Deserialize)]
     53 #[serde(rename_all = "camelCase")]
     54 struct EmergencyAccessUpdateData {
     55     #[allow(dead_code)]
     56     r#type: NumberOrString,
     57     #[allow(dead_code)]
     58     wait_time_days: i32,
     59     #[allow(dead_code)]
     60     key_encrypted: Option<String>,
     61 }
     62 #[allow(unused_variables, clippy::needless_pass_by_value)]
     63 #[put("/emergency-access/<emer_id>", data = "<data>")]
     64 fn put_emergency_access(
     65     emer_id: &str,
     66     data: Json<EmergencyAccessUpdateData>,
     67     _headers: Headers,
     68 ) -> Error {
     69     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
     70 }
     71 
     72 #[allow(unused_variables, clippy::needless_pass_by_value)]
     73 #[post("/emergency-access/<emer_id>", data = "<data>")]
     74 fn post_emergency_access(
     75     emer_id: &str,
     76     data: Json<EmergencyAccessUpdateData>,
     77     _headers: Headers,
     78 ) -> Error {
     79     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
     80 }
     81 
     82 #[allow(unused_variables, clippy::needless_pass_by_value)]
     83 #[delete("/emergency-access/<emer_id>")]
     84 fn delete_emergency_access(emer_id: &str, _headers: Headers) -> Error {
     85     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
     86 }
     87 
     88 #[allow(unused_variables, clippy::needless_pass_by_value)]
     89 #[post("/emergency-access/<emer_id>/delete")]
     90 fn post_delete_emergency_access(emer_id: &str, _headers: Headers) -> Error {
     91     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
     92 }
     93 
     94 #[derive(Deserialize)]
     95 #[serde(rename_all = "camelCase")]
     96 struct EmergencyAccessInviteData {
     97     #[allow(dead_code)]
     98     email: String,
     99     #[allow(dead_code)]
    100     r#type: NumberOrString,
    101     #[allow(dead_code)]
    102     wait_time_days: i32,
    103 }
    104 
    105 #[allow(unused_variables, clippy::needless_pass_by_value)]
    106 #[post("/emergency-access/invite", data = "<data>")]
    107 fn send_invite(data: Json<EmergencyAccessInviteData>, _headers: Headers) -> Error {
    108     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
    109 }
    110 
    111 #[allow(unused_variables, clippy::needless_pass_by_value)]
    112 #[post("/emergency-access/<emer_id>/reinvite")]
    113 fn resend_invite(emer_id: &str, _headers: Headers) -> Error {
    114     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
    115 }
    116 
    117 #[derive(Deserialize)]
    118 #[serde(rename_all = "camelCase")]
    119 struct AcceptData {
    120     #[allow(dead_code)]
    121     token: String,
    122 }
    123 
    124 #[allow(unused_variables, clippy::needless_pass_by_value)]
    125 #[post("/emergency-access/<emer_id>/accept", data = "<data>")]
    126 fn accept_invite(emer_id: &str, data: Json<AcceptData>, _headers: Headers) -> Error {
    127     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
    128 }
    129 
    130 #[derive(Deserialize)]
    131 #[serde(rename_all = "camelCase")]
    132 struct ConfirmData {
    133     #[allow(dead_code)]
    134     key: String,
    135 }
    136 
    137 #[allow(unused_variables, clippy::needless_pass_by_value)]
    138 #[post("/emergency-access/<emer_id>/confirm", data = "<data>")]
    139 fn confirm_emergency_access(emer_id: &str, data: Json<ConfirmData>, _headers: Headers) -> Error {
    140     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
    141 }
    142 
    143 #[allow(unused_variables, clippy::needless_pass_by_value)]
    144 #[post("/emergency-access/<emer_id>/initiate")]
    145 fn initiate_emergency_access(emer_id: &str, _headers: Headers) -> Error {
    146     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
    147 }
    148 
    149 #[allow(unused_variables, clippy::needless_pass_by_value)]
    150 #[post("/emergency-access/<emer_id>/approve")]
    151 fn approve_emergency_access(emer_id: &str, _headers: Headers) -> Error {
    152     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
    153 }
    154 
    155 #[allow(unused_variables, clippy::needless_pass_by_value)]
    156 #[post("/emergency-access/<emer_id>/reject")]
    157 fn reject_emergency_access(emer_id: &str, _headers: Headers) -> Error {
    158     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
    159 }
    160 
    161 #[allow(unused_variables, clippy::needless_pass_by_value)]
    162 #[post("/emergency-access/<emer_id>/view")]
    163 fn view_emergency_access(emer_id: &str, _headers: Headers) -> Error {
    164     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
    165 }
    166 
    167 #[allow(unused_variables, clippy::needless_pass_by_value)]
    168 #[post("/emergency-access/<emer_id>/takeover")]
    169 fn takeover_emergency_access(emer_id: &str, _headers: Headers) -> Error {
    170     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
    171 }
    172 
    173 #[derive(Deserialize)]
    174 #[serde(rename_all = "camelCase")]
    175 struct EmergencyAccessPasswordData {
    176     #[allow(dead_code)]
    177     new_master_password_hash: String,
    178     #[allow(dead_code)]
    179     key: String,
    180 }
    181 
    182 #[allow(unused_variables, clippy::needless_pass_by_value)]
    183 #[post("/emergency-access/<emer_id>/password", data = "<data>")]
    184 fn password_emergency_access(
    185     emer_id: &str,
    186     data: Json<EmergencyAccessPasswordData>,
    187     _headers: Headers,
    188 ) -> Error {
    189     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
    190 }
    191 
    192 #[allow(unused_variables, clippy::needless_pass_by_value)]
    193 #[get("/emergency-access/<emer_id>/policies")]
    194 fn policies_emergency_access(emer_id: &str, _headers: Headers) -> Error {
    195     Error::new(ACCESS_NOT_ALLOWED_MSG, ACCESS_NOT_ALLOWED_MSG)
    196 }