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

commit 5470d37485815fa14172df3a55bd38a896f6808c
parent 3326935aa4654343a316c6e80bfec2ff09238f1c
Author: Zack Newman <zack@philomathiclife.com>
Date:   Fri, 15 Dec 2023 20:42:43 -0700

order routes alphabetically

Diffstat:
Msrc/api/core/accounts.rs | 52++++++++++++++++++++++++++--------------------------
Msrc/api/core/ciphers.rs | 72++++++++++++++++++++++++++++++++++++------------------------------------
Msrc/api/core/emergency_access.rs | 22+++++++++++-----------
Msrc/api/core/events.rs | 2+-
Msrc/api/core/folders.rs | 8++++----
Msrc/api/core/mod.rs | 12++++++------
Msrc/api/core/organizations.rs | 124++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/api/core/sends.rs | 16++++++++--------
Msrc/api/core/two_factor/authenticator.rs | 2+-
Msrc/api/core/two_factor/mod.rs | 6+++---
Msrc/api/core/two_factor/webauthn.rs | 4++--
Msrc/api/identity.rs | 2+-
Msrc/api/notifications.rs | 2+-
Msrc/api/web.rs | 4++--
Msrc/auth.rs | 2+-
Msrc/main.rs | 6+++---
Msrc/priv_sep.rs | 1-
17 files changed, 168 insertions(+), 169 deletions(-)

diff --git a/src/api/core/accounts.rs b/src/api/core/accounts.rs @@ -20,42 +20,42 @@ use serde_json::Value; pub fn routes() -> Vec<rocket::Route> { routes![ - register, - profile, - put_profile, - post_profile, + api_key, + delete_account, + get_auth_request, + get_auth_request_response, + get_auth_requests, + get_known_device, + get_known_device_from_path, get_public_keys, + password_hint, + post_auth_request, + post_clear_device_token, + post_delete_account, + post_delete_recover, + post_delete_recover_token, + post_device_token, + post_email, + post_email_token, + post_kdf, post_keys, post_password, - post_kdf, + post_profile, post_rotatekey, post_sstamp, - post_email_token, - post_email, post_verify_email, post_verify_email_token, - post_delete_recover, - post_delete_recover_token, - post_device_token, - delete_account, - post_delete_account, - revision_date, - password_hint, prelogin, - verify_password, - api_key, - rotate_api_key, - get_known_device, - get_known_device_from_path, + profile, + put_auth_request, put_avatar, - put_device_token, put_clear_device_token, - post_clear_device_token, - post_auth_request, - get_auth_request, - put_auth_request, - get_auth_request_response, - get_auth_requests, + put_device_token, + put_profile, + register, + revision_date, + rotate_api_key, + verify_password, ] } diff --git a/src/api/core/ciphers.rs b/src/api/core/ciphers.rs @@ -31,56 +31,56 @@ pub fn routes() -> Vec<Route> { // determining the write accessibility of a cipher, so most // admin/non-admin implementations can be shared. routes![ - sync, - get_ciphers, - get_cipher, - get_cipher_admin, - get_cipher_details, - post_ciphers, - put_cipher_admin, - post_ciphers_admin, - post_ciphers_create, - post_ciphers_import, - get_attachment, - post_attachment_v2, - post_attachment_v2_data, - post_attachment, // legacy - post_attachment_admin, // legacy - post_attachment_share, - delete_attachment_post, - delete_attachment_post_admin, + delete_all, delete_attachment, delete_attachment_admin, - post_cipher_admin, - post_cipher_share, - put_cipher_share, - put_cipher_share_selected, - post_cipher, - post_cipher_partial, - put_cipher, - put_cipher_partial, + delete_attachment_post, + delete_attachment_post_admin, + delete_cipher, + delete_cipher_admin, delete_cipher_post, delete_cipher_post_admin, delete_cipher_put, delete_cipher_put_admin, - delete_cipher, - delete_cipher_admin, delete_cipher_selected, - delete_cipher_selected_post, - delete_cipher_selected_put, delete_cipher_selected_admin, + delete_cipher_selected_post, delete_cipher_selected_post_admin, + delete_cipher_selected_put, delete_cipher_selected_put_admin, - restore_cipher_put, - restore_cipher_put_admin, - restore_cipher_selected, - delete_all, + get_attachment, + get_cipher, + get_cipher_admin, + get_cipher_details, + get_ciphers, move_cipher_selected, move_cipher_selected_put, - put_collections_update, - post_collections_update, + post_attachment, + post_attachment_admin, + post_attachment_share, + post_attachment_v2, + post_attachment_v2_data, + post_cipher, + post_cipher_admin, + post_cipher_partial, + post_cipher_share, + post_ciphers, + post_ciphers_admin, + post_ciphers_create, + post_ciphers_import, post_collections_admin, + post_collections_update, + put_cipher, + put_cipher_admin, + put_cipher_partial, + put_cipher_share, + put_cipher_share_selected, put_collections_admin, + put_collections_update, + restore_cipher_put, + restore_cipher_put_admin, + restore_cipher_selected, + sync, ] } diff --git a/src/api/core/emergency_access.rs b/src/api/core/emergency_access.rs @@ -7,24 +7,24 @@ use rocket::Route; pub fn routes() -> Vec<Route> { routes![ + accept_invite, + approve_emergency_access, + confirm_emergency_access, + delete_emergency_access, get_contacts, - get_grantees, get_emergency_access, + get_grantees, + initiate_emergency_access, + password_emergency_access, + policies_emergency_access, + post_delete_emergency_access, post_emergency_access, put_emergency_access, - delete_emergency_access, - post_delete_emergency_access, - send_invite, - resend_invite, - accept_invite, - confirm_emergency_access, - initiate_emergency_access, - approve_emergency_access, reject_emergency_access, + resend_invite, + send_invite, takeover_emergency_access, - password_emergency_access, view_emergency_access, - policies_emergency_access, ] } #[allow(clippy::needless_pass_by_value)] diff --git a/src/api/core/events.rs b/src/api/core/events.rs @@ -6,7 +6,7 @@ use crate::{ use rocket::{form::FromForm, serde::json::Json, Route}; use serde_json::Value; pub fn routes() -> Vec<Route> { - routes![get_org_events, get_cipher_events, get_user_events,] + routes![get_cipher_events, get_org_events, get_user_events,] } #[derive(FromForm)] diff --git a/src/api/core/folders.rs b/src/api/core/folders.rs @@ -8,13 +8,13 @@ use serde_json::Value; pub fn routes() -> Vec<rocket::Route> { routes![ - get_folders, + delete_folder, + delete_folder_post, get_folder, - post_folders, + get_folders, post_folder, + post_folders, put_folder, - delete_folder_post, - delete_folder, ] } diff --git a/src/api/core/mod.rs b/src/api/core/mod.rs @@ -11,20 +11,20 @@ pub use ciphers::{CipherData, CipherSyncData, CipherSyncType}; pub fn routes() -> Vec<Route> { let mut eq_domains_routes = routes![get_eq_domains, post_eq_domains, put_eq_domains]; let mut hibp_routes = routes![hibp_breach]; - let mut meta_routes = routes![alive, now, version, config]; + let mut meta_routes = routes![alive, config, now, version]; let mut routes = Vec::new(); routes.append(&mut accounts::routes()); routes.append(&mut ciphers::routes()); routes.append(&mut emergency_access::routes()); + routes.append(&mut eq_domains_routes); routes.append(&mut events::routes()); routes.append(&mut folders::routes()); - routes.append(&mut organizations::routes()); - routes.append(&mut two_factor::routes()); - routes.append(&mut sends::routes()); - routes.append(&mut public::routes()); - routes.append(&mut eq_domains_routes); routes.append(&mut hibp_routes); routes.append(&mut meta_routes); + routes.append(&mut organizations::routes()); + routes.append(&mut public::routes()); + routes.append(&mut sends::routes()); + routes.append(&mut two_factor::routes()); routes } diff --git a/src/api/core/organizations.rs b/src/api/core/organizations.rs @@ -23,84 +23,84 @@ use serde_json::Value; pub fn routes() -> Vec<Route> { routes![ - get_organization, + accept_invite, + activate_organization_user, + api_key, + bulk_activate_organization_user, + bulk_confirm_invite, + bulk_deactivate_organization_user, + bulk_delete_groups, + bulk_delete_organization_collections, + bulk_delete_user, + bulk_public_keys, + bulk_reinvite_user, + bulk_restore_organization_user, + bulk_revoke_organization_user, + confirm_invite, create_organization, + deactivate_organization_user, + delete_group, + delete_group_user, delete_organization, - post_delete_organization, - leave_organization, - get_user_collections, + delete_organization_collection, + delete_organization_collection_user, + delete_user, + edit_user, + get_collection_users, + get_group, + get_group_details, + get_group_users, + get_groups, + get_org_collection_detail, get_org_collections, get_org_collections_details, - get_org_collection_detail, - get_collection_users, - put_collection_users, - put_organization, - post_organization, - post_organization_collections, - delete_organization_collection_user, - post_organization_collection_delete_user, - post_organization_collection_update, - put_organization_collection_update, - delete_organization_collection, - post_organization_collection_delete, - bulk_delete_organization_collections, get_org_details, + get_org_export, get_org_users, - send_invite, - reinvite_user, - bulk_reinvite_user, - confirm_invite, - bulk_confirm_invite, - accept_invite, - get_user, - edit_user, - put_organization_user, - delete_user, - bulk_delete_user, - post_delete_user, - post_org_import, - list_policies, - list_policies_token, - get_policy, - put_policy, + get_organization, + get_organization_keys, get_organization_tax, get_plans, get_plans_all, get_plans_tax_rates, + get_policy, + get_reset_password_details, + get_user, + get_user_collections, + get_user_groups, import, - post_org_keys, - get_organization_keys, - bulk_public_keys, - deactivate_organization_user, - bulk_deactivate_organization_user, - revoke_organization_user, - bulk_revoke_organization_user, - activate_organization_user, - bulk_activate_organization_user, - restore_organization_user, - bulk_restore_organization_user, - get_groups, + leave_organization, + list_policies, + list_policies_token, + post_delete_group, + post_delete_group_user, + post_delete_organization, + post_delete_user, + post_group, post_groups, - get_group, + post_org_import, + post_org_keys, + post_organization, + post_organization_collection_delete, + post_organization_collection_delete_user, + post_organization_collection_update, + post_organization_collections, + post_user_groups, + put_collection_users, put_group, - post_group, - get_group_details, - delete_group, - post_delete_group, - bulk_delete_groups, - get_group_users, put_group_users, - get_user_groups, - post_user_groups, - put_user_groups, - delete_group_user, - post_delete_group_user, - put_reset_password_enrollment, - get_reset_password_details, + put_organization, + put_organization_collection_update, + put_organization_user, + put_policy, put_reset_password, - get_org_export, - api_key, + put_reset_password_enrollment, + put_user_groups, + reinvite_user, + restore_organization_user, + revoke_organization_user, rotate_api_key, + send_invite, ] } diff --git a/src/api/core/sends.rs b/src/api/core/sends.rs @@ -12,18 +12,18 @@ use serde_json::Value; pub fn routes() -> Vec<rocket::Route> { routes![ - get_sends, + delete_send, + download_send, get_send, - post_send, - post_send_file, + get_sends, post_access, post_access_file, - put_send, - delete_send, - put_remove_password, - download_send, + post_send, + post_send_file, post_send_file_v2, - post_send_file_v2_data + post_send_file_v2_data, + put_remove_password, + put_send, ] } diff --git a/src/api/core/two_factor/authenticator.rs b/src/api/core/two_factor/authenticator.rs @@ -13,9 +13,9 @@ use rocket::Route; pub fn routes() -> Vec<Route> { routes![ - generate_authenticator, activate_authenticator, activate_authenticator_put, + generate_authenticator, ] } diff --git a/src/api/core/two_factor/mod.rs b/src/api/core/two_factor/mod.rs @@ -15,12 +15,12 @@ pub mod webauthn; pub fn routes() -> Vec<Route> { let mut routes = routes![ - get_twofactor, - get_recover, - recover, disable_twofactor, disable_twofactor_put, get_device_verification_settings, + get_recover, + get_twofactor, + recover, ]; routes.append(&mut authenticator::routes()); routes.append(&mut protected_actions::routes()); diff --git a/src/api/core/two_factor/webauthn.rs b/src/api/core/two_factor/webauthn.rs @@ -24,11 +24,11 @@ use webauthn_rs::{ pub fn routes() -> Vec<Route> { routes![ - get_webauthn, - generate_webauthn_challenge, activate_webauthn, activate_webauthn_put, delete_webauthn, + generate_webauthn_challenge, + get_webauthn, ] } diff --git a/src/api/identity.rs b/src/api/identity.rs @@ -21,7 +21,7 @@ use rocket::{ use serde_json::Value; pub fn routes() -> Vec<Route> { - routes![login, prelogin, identity_register] + routes![identity_register, login, prelogin] } #[post("/connect/token", data = "<data>")] diff --git a/src/api/notifications.rs b/src/api/notifications.rs @@ -48,7 +48,7 @@ pub fn ws_anonymous_subscriptions() -> &'static Arc<AnonymousWebSocketSubscripti } pub fn routes() -> Vec<Route> { - routes![websockets_hub, anonymous_websockets_hub] + routes![anonymous_websockets_hub, websockets_hub] } #[derive(FromForm, Debug)] diff --git a/src/api/web.rs b/src/api/web.rs @@ -12,9 +12,9 @@ use std::path::{Path, PathBuf}; pub fn routes() -> Vec<Route> { // If adding more routes here, consider also adding them to // crate::utils::LOGGED_ROUTES to make sure they appear in the log - let mut routes = routes![attachments, alive, alive_head, static_files]; + let mut routes = routes![alive, alive_head, attachments, static_files]; if config::get_config().web_vault_enabled { - routes.append(&mut routes![web_index, web_index_head, app_id, web_files]); + routes.append(&mut routes![app_id, web_files, web_index, web_index_head]); } routes } diff --git a/src/auth.rs b/src/auth.rs @@ -141,7 +141,7 @@ fn init_ed_keys() -> Result<(), Error> { .read(true) .write(true) .open(Config::PRIVATE_ED25519_KEY)?; - let mut priv_pem = Vec::with_capacity(192); + let mut priv_pem = Vec::with_capacity(128); let ed_key = if file.read_to_end(&mut priv_pem)? == 0 { let ed_key = PKey::generate_ed25519()?; priv_pem = ed_key.private_key_to_pem_pkcs8()?; diff --git a/src/main.rs b/src/main.rs @@ -175,18 +175,18 @@ async fn launch_rocket(pool: db::DbPool) -> Result<(), Error> { let basepath = config::get_config().domain_path(); let instance = rocket::custom(&config::get_config().rocket) .mount([basepath, "/"].concat(), api::web_routes()) - .mount([basepath, "/api"].concat(), api::core_routes()) .mount([basepath, "/admin"].concat(), api::admin_routes()) + .mount([basepath, "/api"].concat(), api::core_routes()) .mount([basepath, "/events"].concat(), api::core_events_routes()) - .mount([basepath, "/identity"].concat(), api::identity_routes()) .mount([basepath, "/icons"].concat(), api::icons_routes()) + .mount([basepath, "/identity"].concat(), api::identity_routes()) .mount( [basepath, "/notifications"].concat(), api::notifications_routes(), ) .register([basepath, "/"].concat(), api::web_catchers()) - .register([basepath, "/api"].concat(), api::core_catchers()) .register([basepath, "/admin"].concat(), api::admin_catchers()) + .register([basepath, "/api"].concat(), api::core_catchers()) .manage(pool) .manage(api::start_notification_server()) .manage(Arc::clone(api::ws_anonymous_subscriptions())) diff --git a/src/priv_sep.rs b/src/priv_sep.rs @@ -1,4 +1,3 @@ -#![allow(clippy::implicit_return, clippy::pub_use)] #[cfg(not(all(feature = "priv_sep", target_os = "openbsd")))] use core::convert::Infallible; #[cfg(all(feature = "priv_sep", target_os = "openbsd"))]