From 8941a8ab02caf60ee6cc27f6a7393cba92632006 Mon Sep 17 00:00:00 2001 From: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> Date: Mon, 28 Aug 2023 10:15:47 -0500 Subject: [PATCH 01/10] [SM-865] Part 1 Add openapi generated bindings (#153) * Add openapi auto generation * Regenerated open api doc --- .../.openapi-generator/FILES | 14 +- crates/bitwarden-api-api/README.md | 34 +- .../src/apis/auth_requests_api.rs | 6 +- .../bitwarden-api-api/src/apis/ciphers_api.rs | 57 ++- .../bitwarden-api-api/src/apis/devices_api.rs | 157 +++++++ crates/bitwarden-api-api/src/apis/mod.rs | 4 +- .../apis/organization_auth_requests_api.rs | 180 ++++++++ .../src/apis/organization_users_api.rs | 384 ++---------------- .../src/apis/organizations_api.rs | 56 +++ .../bitwarden-api-api/src/apis/plans_api.rs | 92 +++++ .../bitwarden-api-api/src/apis/secrets_api.rs | 49 +++ ...admin_auth_request_update_request_model.rs | 26 ++ .../src/models/auth_request_type.rs | 2 + .../src/models/base_secret_response_model.rs | 47 +++ ...cret_response_model_list_response_model.rs | 29 ++ .../src/models/billing_subscription_item.rs | 9 + .../src/models/bitwarden_product_type.rs | 34 ++ ...k_deny_admin_auth_request_request_model.rs | 21 + .../cipher_bulk_restore_request_model.rs | 7 +- ...mini_response_model_list_response_model.rs | 29 ++ .../src/models/device_keys_request_model.rs | 33 ++ .../src/models/device_response_model.rs | 12 + .../environment_config_response_model.rs | 3 + .../src/models/get_secrets_request_model.rs | 21 + .../models/global_equivalent_domains_type.rs | 2 + .../src/models/member_decryption_type.rs | 36 ++ crates/bitwarden-api-api/src/models/mod.rs | 26 +- .../organization_create_request_model.rs | 19 +- .../src/models/organization_license.rs | 6 + .../src/models/organization_response_model.rs | 24 ++ ...rganization_subscription_response_model.rs | 35 ++ .../organization_upgrade_request_model.rs | 14 +- ...rganization_user_details_response_model.rs | 3 + ...zation_user_user_details_response_model.rs | 3 + ...rganization_auth_request_response_model.rs | 53 +++ ...uest_response_model_list_response_model.rs | 29 ++ .../src/models/plan_response_model.rs | 36 ++ .../profile_organization_response_model.rs | 3 + ...le_provider_organization_response_model.rs | 3 + ...nager_subscription_update_request_model.rs | 38 ++ .../src/models/sso_configuration_data.rs | 7 + .../models/sso_configuration_data_request.rs | 6 + 42 files changed, 1275 insertions(+), 374 deletions(-) create mode 100644 crates/bitwarden-api-api/src/apis/organization_auth_requests_api.rs create mode 100644 crates/bitwarden-api-api/src/models/admin_auth_request_update_request_model.rs create mode 100644 crates/bitwarden-api-api/src/models/base_secret_response_model.rs create mode 100644 crates/bitwarden-api-api/src/models/base_secret_response_model_list_response_model.rs create mode 100644 crates/bitwarden-api-api/src/models/bitwarden_product_type.rs create mode 100644 crates/bitwarden-api-api/src/models/bulk_deny_admin_auth_request_request_model.rs create mode 100644 crates/bitwarden-api-api/src/models/cipher_mini_response_model_list_response_model.rs create mode 100644 crates/bitwarden-api-api/src/models/device_keys_request_model.rs create mode 100644 crates/bitwarden-api-api/src/models/get_secrets_request_model.rs create mode 100644 crates/bitwarden-api-api/src/models/member_decryption_type.rs create mode 100644 crates/bitwarden-api-api/src/models/pending_organization_auth_request_response_model.rs create mode 100644 crates/bitwarden-api-api/src/models/pending_organization_auth_request_response_model_list_response_model.rs create mode 100644 crates/bitwarden-api-api/src/models/secrets_manager_subscription_update_request_model.rs diff --git a/crates/bitwarden-api-api/.openapi-generator/FILES b/crates/bitwarden-api-api/.openapi-generator/FILES index 609c85d74..4fbc2fbf9 100644 --- a/crates/bitwarden-api-api/.openapi-generator/FILES +++ b/crates/bitwarden-api-api/.openapi-generator/FILES @@ -21,6 +21,7 @@ src/apis/installations_api.rs src/apis/licenses_api.rs src/apis/misc_api.rs src/apis/mod.rs +src/apis/organization_auth_requests_api.rs src/apis/organization_connections_api.rs src/apis/organization_domain_api.rs src/apis/organization_export_api.rs @@ -53,6 +54,7 @@ src/models/access_token_create_request_model.rs src/models/access_token_creation_response_model.rs src/models/access_token_response_model.rs src/models/access_token_response_model_list_response_model.rs +src/models/admin_auth_request_update_request_model.rs src/models/api_key_response_model.rs src/models/attachment_request_model.rs src/models/attachment_response_model.rs @@ -65,6 +67,8 @@ src/models/auth_request_update_request_model.rs src/models/authentication_extensions_client_outputs.rs src/models/authenticator_attestation_raw_response.rs src/models/base_access_policy_response_model.rs +src/models/base_secret_response_model.rs +src/models/base_secret_response_model_list_response_model.rs src/models/billing_history_response_model.rs src/models/billing_invoice.rs src/models/billing_payment_response_model.rs @@ -75,8 +79,10 @@ src/models/billing_subscription_item.rs src/models/billing_subscription_upcoming_invoice.rs src/models/billing_transaction.rs src/models/bit_pay_invoice_request_model.rs +src/models/bitwarden_product_type.rs src/models/bulk_delete_response_model.rs src/models/bulk_delete_response_model_list_response_model.rs +src/models/bulk_deny_admin_auth_request_request_model.rs src/models/cipher_attachment_model.rs src/models/cipher_bulk_delete_request_model.rs src/models/cipher_bulk_move_request_model.rs @@ -94,12 +100,12 @@ src/models/cipher_login_uri_model.rs src/models/cipher_mini_details_response_model.rs src/models/cipher_mini_details_response_model_list_response_model.rs src/models/cipher_mini_response_model.rs +src/models/cipher_mini_response_model_list_response_model.rs src/models/cipher_partial_request_model.rs src/models/cipher_password_history_model.rs src/models/cipher_reprompt_type.rs src/models/cipher_request_model.rs src/models/cipher_response_model.rs -src/models/cipher_response_model_list_response_model.rs src/models/cipher_secure_note_model.rs src/models/cipher_share_request_model.rs src/models/cipher_type.rs @@ -115,6 +121,7 @@ src/models/collection_response_model_list_response_model.rs src/models/collection_with_id_request_model.rs src/models/config_response_model.rs src/models/delete_recover_request_model.rs +src/models/device_keys_request_model.rs src/models/device_request_model.rs src/models/device_response_model.rs src/models/device_response_model_list_response_model.rs @@ -147,6 +154,7 @@ src/models/folder_request_model.rs src/models/folder_response_model.rs src/models/folder_response_model_list_response_model.rs src/models/folder_with_id_request_model.rs +src/models/get_secrets_request_model.rs src/models/global_domains.rs src/models/global_equivalent_domains_type.rs src/models/granted_access_policy_request.rs @@ -176,6 +184,7 @@ src/models/keys_request_model.rs src/models/keys_response_model.rs src/models/license_type.rs src/models/master_password_policy_response_model.rs +src/models/member_decryption_type.rs src/models/mod.rs src/models/open_id_connect_redirect_behavior.rs src/models/organization_api_key_information.rs @@ -237,6 +246,8 @@ src/models/password_request_model.rs src/models/payment_method_type.rs src/models/payment_request_model.rs src/models/payment_response_model.rs +src/models/pending_organization_auth_request_response_model.rs +src/models/pending_organization_auth_request_response_model_list_response_model.rs src/models/permissions.rs src/models/plan_response_model.rs src/models/plan_response_model_list_response_model.rs @@ -305,6 +316,7 @@ src/models/secret_update_request_model.rs src/models/secret_verification_request_model.rs src/models/secret_with_projects_inner_project.rs src/models/secret_with_projects_list_response_model.rs +src/models/secrets_manager_subscription_update_request_model.rs src/models/secrets_with_projects_inner_secret.rs src/models/secure_note_type.rs src/models/selection_read_only_request_model.rs diff --git a/crates/bitwarden-api-api/README.md b/crates/bitwarden-api-api/README.md index 2d9138b2a..0754e9680 100644 --- a/crates/bitwarden-api-api/README.md +++ b/crates/bitwarden-api-api/README.md @@ -137,6 +137,7 @@ All URIs are relative to _http://localhost_ | _CiphersApi_ | [**ciphers_organization_details_get**](docs/CiphersApi.md#ciphers_organization_details_get) | **GET** /ciphers/organization-details | | _CiphersApi_ | [**ciphers_post**](docs/CiphersApi.md#ciphers_post) | **POST** /ciphers | | _CiphersApi_ | [**ciphers_purge_post**](docs/CiphersApi.md#ciphers_purge_post) | **POST** /ciphers/purge | +| _CiphersApi_ | [**ciphers_restore_admin_put**](docs/CiphersApi.md#ciphers_restore_admin_put) | **PUT** /ciphers/restore-admin | | _CiphersApi_ | [**ciphers_restore_put**](docs/CiphersApi.md#ciphers_restore_put) | **PUT** /ciphers/restore | | _CiphersApi_ | [**ciphers_share_post**](docs/CiphersApi.md#ciphers_share_post) | **POST** /ciphers/share | | _CiphersApi_ | [**ciphers_share_put**](docs/CiphersApi.md#ciphers_share_put) | **PUT** /ciphers/share | @@ -157,6 +158,7 @@ All URIs are relative to _http://localhost_ | _CollectionsApi_ | [**organizations_org_id_collections_id_users_put**](docs/CollectionsApi.md#organizations_org_id_collections_id_users_put) | **PUT** /organizations/{orgId}/collections/{id}/users | | _CollectionsApi_ | [**organizations_org_id_collections_post**](docs/CollectionsApi.md#organizations_org_id_collections_post) | **POST** /organizations/{orgId}/collections | | _ConfigApi_ | [**config_get**](docs/ConfigApi.md#config_get) | **GET** /config | +| _DevicesApi_ | [**devices_exist_by_types_post**](docs/DevicesApi.md#devices_exist_by_types_post) | **POST** /devices/exist-by-types | | _DevicesApi_ | [**devices_get**](docs/DevicesApi.md#devices_get) | **GET** /devices | | _DevicesApi_ | [**devices_id_delete**](docs/DevicesApi.md#devices_id_delete) | **DELETE** /devices/{id} | | _DevicesApi_ | [**devices_id_delete_post**](docs/DevicesApi.md#devices_id_delete_post) | **POST** /devices/{id}/delete | @@ -168,6 +170,8 @@ All URIs are relative to _http://localhost_ | _DevicesApi_ | [**devices_identifier_identifier_get**](docs/DevicesApi.md#devices_identifier_identifier_get) | **GET** /devices/identifier/{identifier} | | _DevicesApi_ | [**devices_identifier_identifier_token_post**](docs/DevicesApi.md#devices_identifier_identifier_token_post) | **POST** /devices/identifier/{identifier}/token | | _DevicesApi_ | [**devices_identifier_identifier_token_put**](docs/DevicesApi.md#devices_identifier_identifier_token_put) | **PUT** /devices/identifier/{identifier}/token | +| _DevicesApi_ | [**devices_identifier_keys_post**](docs/DevicesApi.md#devices_identifier_keys_post) | **POST** /devices/{identifier}/keys | +| _DevicesApi_ | [**devices_identifier_keys_put**](docs/DevicesApi.md#devices_identifier_keys_put) | **PUT** /devices/{identifier}/keys | | _DevicesApi_ | [**devices_knowndevice_email_identifier_get**](docs/DevicesApi.md#devices_knowndevice_email_identifier_get) | **GET** /devices/knowndevice/{email}/{identifier} | | _DevicesApi_ | [**devices_knowndevice_get**](docs/DevicesApi.md#devices_knowndevice_get) | **GET** /devices/knowndevice | | _DevicesApi_ | [**devices_post**](docs/DevicesApi.md#devices_post) | **POST** /devices | @@ -230,6 +234,9 @@ All URIs are relative to _http://localhost_ | _LicensesApi_ | [**licenses_user_id_get**](docs/LicensesApi.md#licenses_user_id_get) | **GET** /licenses/user/{id} | | _MiscApi_ | [**bitpay_invoice_post**](docs/MiscApi.md#bitpay_invoice_post) | **POST** /bitpay-invoice | | _MiscApi_ | [**setup_payment_post**](docs/MiscApi.md#setup_payment_post) | **POST** /setup-payment | +| _OrganizationAuthRequestsApi_ | [**organizations_org_id_auth_requests_deny_post**](docs/OrganizationAuthRequestsApi.md#organizations_org_id_auth_requests_deny_post) | **POST** /organizations/{orgId}/auth-requests/deny | +| _OrganizationAuthRequestsApi_ | [**organizations_org_id_auth_requests_get**](docs/OrganizationAuthRequestsApi.md#organizations_org_id_auth_requests_get) | **GET** /organizations/{orgId}/auth-requests | +| _OrganizationAuthRequestsApi_ | [**organizations_org_id_auth_requests_request_id_post**](docs/OrganizationAuthRequestsApi.md#organizations_org_id_auth_requests_request_id_post) | **POST** /organizations/{orgId}/auth-requests/{requestId} | | _OrganizationConnectionsApi_ | [**organizations_connections_enabled_get**](docs/OrganizationConnectionsApi.md#organizations_connections_enabled_get) | **GET** /organizations/connections/enabled | | _OrganizationConnectionsApi_ | [**organizations_connections_organization_connection_id_delete**](docs/OrganizationConnectionsApi.md#organizations_connections_organization_connection_id_delete) | **DELETE** /organizations/connections/{organizationConnectionId} | | _OrganizationConnectionsApi_ | [**organizations_connections_organization_connection_id_delete_post**](docs/OrganizationConnectionsApi.md#organizations_connections_organization_connection_id_delete_post) | **POST** /organizations/connections/{organizationConnectionId}/delete | @@ -254,19 +261,13 @@ All URIs are relative to _http://localhost_ | _OrganizationSponsorshipsApi_ | [**organization_sponsorship_sponsoring_organization_id_delete_post**](docs/OrganizationSponsorshipsApi.md#organization_sponsorship_sponsoring_organization_id_delete_post) | **POST** /organization/sponsorship/{sponsoringOrganizationId}/delete | | _OrganizationSponsorshipsApi_ | [**organization_sponsorship_sync_post**](docs/OrganizationSponsorshipsApi.md#organization_sponsorship_sync_post) | **POST** /organization/sponsorship/sync | | _OrganizationSponsorshipsApi_ | [**organization_sponsorship_validate_token_post**](docs/OrganizationSponsorshipsApi.md#organization_sponsorship_validate_token_post) | **POST** /organization/sponsorship/validate-token | -| _OrganizationUsersApi_ | [**organizations_org_id_users_activate_patch**](docs/OrganizationUsersApi.md#organizations_org_id_users_activate_patch) | **PATCH** /organizations/{orgId}/users/activate | -| _OrganizationUsersApi_ | [**organizations_org_id_users_activate_put**](docs/OrganizationUsersApi.md#organizations_org_id_users_activate_put) | **PUT** /organizations/{orgId}/users/activate | | _OrganizationUsersApi_ | [**organizations_org_id_users_confirm_post**](docs/OrganizationUsersApi.md#organizations_org_id_users_confirm_post) | **POST** /organizations/{orgId}/users/confirm | -| _OrganizationUsersApi_ | [**organizations_org_id_users_deactivate_patch**](docs/OrganizationUsersApi.md#organizations_org_id_users_deactivate_patch) | **PATCH** /organizations/{orgId}/users/deactivate | -| _OrganizationUsersApi_ | [**organizations_org_id_users_deactivate_put**](docs/OrganizationUsersApi.md#organizations_org_id_users_deactivate_put) | **PUT** /organizations/{orgId}/users/deactivate | | _OrganizationUsersApi_ | [**organizations_org_id_users_delete**](docs/OrganizationUsersApi.md#organizations_org_id_users_delete) | **DELETE** /organizations/{orgId}/users | | _OrganizationUsersApi_ | [**organizations_org_id_users_delete_post**](docs/OrganizationUsersApi.md#organizations_org_id_users_delete_post) | **POST** /organizations/{orgId}/users/delete | +| _OrganizationUsersApi_ | [**organizations_org_id_users_enable_secrets_manager_patch**](docs/OrganizationUsersApi.md#organizations_org_id_users_enable_secrets_manager_patch) | **PATCH** /organizations/{orgId}/users/enable-secrets-manager | +| _OrganizationUsersApi_ | [**organizations_org_id_users_enable_secrets_manager_put**](docs/OrganizationUsersApi.md#organizations_org_id_users_enable_secrets_manager_put) | **PUT** /organizations/{orgId}/users/enable-secrets-manager | | _OrganizationUsersApi_ | [**organizations_org_id_users_get**](docs/OrganizationUsersApi.md#organizations_org_id_users_get) | **GET** /organizations/{orgId}/users | -| _OrganizationUsersApi_ | [**organizations_org_id_users_id_activate_patch**](docs/OrganizationUsersApi.md#organizations_org_id_users_id_activate_patch) | **PATCH** /organizations/{orgId}/users/{id}/activate | -| _OrganizationUsersApi_ | [**organizations_org_id_users_id_activate_put**](docs/OrganizationUsersApi.md#organizations_org_id_users_id_activate_put) | **PUT** /organizations/{orgId}/users/{id}/activate | | _OrganizationUsersApi_ | [**organizations_org_id_users_id_confirm_post**](docs/OrganizationUsersApi.md#organizations_org_id_users_id_confirm_post) | **POST** /organizations/{orgId}/users/{id}/confirm | -| _OrganizationUsersApi_ | [**organizations_org_id_users_id_deactivate_patch**](docs/OrganizationUsersApi.md#organizations_org_id_users_id_deactivate_patch) | **PATCH** /organizations/{orgId}/users/{id}/deactivate | -| _OrganizationUsersApi_ | [**organizations_org_id_users_id_deactivate_put**](docs/OrganizationUsersApi.md#organizations_org_id_users_id_deactivate_put) | **PUT** /organizations/{orgId}/users/{id}/deactivate | | _OrganizationUsersApi_ | [**organizations_org_id_users_id_delete**](docs/OrganizationUsersApi.md#organizations_org_id_users_id_delete) | **DELETE** /organizations/{orgId}/users/{id} | | _OrganizationUsersApi_ | [**organizations_org_id_users_id_delete_post**](docs/OrganizationUsersApi.md#organizations_org_id_users_id_delete_post) | **POST** /organizations/{orgId}/users/{id}/delete | | _OrganizationUsersApi_ | [**organizations_org_id_users_id_get**](docs/OrganizationUsersApi.md#organizations_org_id_users_id_get) | **GET** /organizations/{orgId}/users/{id} | @@ -312,6 +313,7 @@ All URIs are relative to _http://localhost_ | _OrganizationsApi_ | [**organizations_id_reinstate_post**](docs/OrganizationsApi.md#organizations_id_reinstate_post) | **POST** /organizations/{id}/reinstate | | _OrganizationsApi_ | [**organizations_id_rotate_api_key_post**](docs/OrganizationsApi.md#organizations_id_rotate_api_key_post) | **POST** /organizations/{id}/rotate-api-key | | _OrganizationsApi_ | [**organizations_id_seat_post**](docs/OrganizationsApi.md#organizations_id_seat_post) | **POST** /organizations/{id}/seat | +| _OrganizationsApi_ | [**organizations_id_sm_subscription_post**](docs/OrganizationsApi.md#organizations_id_sm_subscription_post) | **POST** /organizations/{id}/sm-subscription | | _OrganizationsApi_ | [**organizations_id_sso_get**](docs/OrganizationsApi.md#organizations_id_sso_get) | **GET** /organizations/{id}/sso | | _OrganizationsApi_ | [**organizations_id_sso_post**](docs/OrganizationsApi.md#organizations_id_sso_post) | **POST** /organizations/{id}/sso | | _OrganizationsApi_ | [**organizations_id_storage_post**](docs/OrganizationsApi.md#organizations_id_storage_post) | **POST** /organizations/{id}/storage | @@ -323,8 +325,10 @@ All URIs are relative to _http://localhost_ | _OrganizationsApi_ | [**organizations_id_verify_bank_post**](docs/OrganizationsApi.md#organizations_id_verify_bank_post) | **POST** /organizations/{id}/verify-bank | | _OrganizationsApi_ | [**organizations_identifier_auto_enroll_status_get**](docs/OrganizationsApi.md#organizations_identifier_auto_enroll_status_get) | **GET** /organizations/{identifier}/auto-enroll-status | | _OrganizationsApi_ | [**organizations_post**](docs/OrganizationsApi.md#organizations_post) | **POST** /organizations | +| _PlansApi_ | [**plans_all_get**](docs/PlansApi.md#plans_all_get) | **GET** /plans/all | | _PlansApi_ | [**plans_get**](docs/PlansApi.md#plans_get) | **GET** /plans | | _PlansApi_ | [**plans_sales_tax_rates_get**](docs/PlansApi.md#plans_sales_tax_rates_get) | **GET** /plans/sales-tax-rates | +| _PlansApi_ | [**plans_sm_plans_get**](docs/PlansApi.md#plans_sm_plans_get) | **GET** /plans/sm-plans | | _PoliciesApi_ | [**organizations_org_id_policies_get**](docs/PoliciesApi.md#organizations_org_id_policies_get) | **GET** /organizations/{orgId}/policies | | _PoliciesApi_ | [**organizations_org_id_policies_invited_user_get**](docs/PoliciesApi.md#organizations_org_id_policies_invited_user_get) | **GET** /organizations/{orgId}/policies/invited-user | | _PoliciesApi_ | [**organizations_org_id_policies_token_get**](docs/PoliciesApi.md#organizations_org_id_policies_token_get) | **GET** /organizations/{orgId}/policies/token | @@ -368,6 +372,7 @@ All URIs are relative to _http://localhost_ | _SecretsApi_ | [**organizations_organization_id_secrets_post**](docs/SecretsApi.md#organizations_organization_id_secrets_post) | **POST** /organizations/{organizationId}/secrets | | _SecretsApi_ | [**projects_project_id_secrets_get**](docs/SecretsApi.md#projects_project_id_secrets_get) | **GET** /projects/{projectId}/secrets | | _SecretsApi_ | [**secrets_delete_post**](docs/SecretsApi.md#secrets_delete_post) | **POST** /secrets/delete | +| _SecretsApi_ | [**secrets_get_by_ids_post**](docs/SecretsApi.md#secrets_get_by_ids_post) | **POST** /secrets/get-by-ids | | _SecretsApi_ | [**secrets_id_get**](docs/SecretsApi.md#secrets_id_get) | **GET** /secrets/{id} | | _SecretsApi_ | [**secrets_id_put**](docs/SecretsApi.md#secrets_id_put) | **PUT** /secrets/{id} | | _SecretsManagerPortingApi_ | [**sm_organization_id_export_get**](docs/SecretsManagerPortingApi.md#sm_organization_id_export_get) | **GET** /sm/{organizationId}/export | @@ -448,6 +453,7 @@ All URIs are relative to _http://localhost_ - [AccessTokenCreationResponseModel](docs/AccessTokenCreationResponseModel.md) - [AccessTokenResponseModel](docs/AccessTokenResponseModel.md) - [AccessTokenResponseModelListResponseModel](docs/AccessTokenResponseModelListResponseModel.md) +- [AdminAuthRequestUpdateRequestModel](docs/AdminAuthRequestUpdateRequestModel.md) - [ApiKeyResponseModel](docs/ApiKeyResponseModel.md) - [AttachmentRequestModel](docs/AttachmentRequestModel.md) - [AttachmentResponseModel](docs/AttachmentResponseModel.md) @@ -460,6 +466,8 @@ All URIs are relative to _http://localhost_ - [AuthenticationExtensionsClientOutputs](docs/AuthenticationExtensionsClientOutputs.md) - [AuthenticatorAttestationRawResponse](docs/AuthenticatorAttestationRawResponse.md) - [BaseAccessPolicyResponseModel](docs/BaseAccessPolicyResponseModel.md) +- [BaseSecretResponseModel](docs/BaseSecretResponseModel.md) +- [BaseSecretResponseModelListResponseModel](docs/BaseSecretResponseModelListResponseModel.md) - [BillingHistoryResponseModel](docs/BillingHistoryResponseModel.md) - [BillingInvoice](docs/BillingInvoice.md) - [BillingPaymentResponseModel](docs/BillingPaymentResponseModel.md) @@ -470,8 +478,10 @@ All URIs are relative to _http://localhost_ - [BillingSubscriptionUpcomingInvoice](docs/BillingSubscriptionUpcomingInvoice.md) - [BillingTransaction](docs/BillingTransaction.md) - [BitPayInvoiceRequestModel](docs/BitPayInvoiceRequestModel.md) +- [BitwardenProductType](docs/BitwardenProductType.md) - [BulkDeleteResponseModel](docs/BulkDeleteResponseModel.md) - [BulkDeleteResponseModelListResponseModel](docs/BulkDeleteResponseModelListResponseModel.md) +- [BulkDenyAdminAuthRequestRequestModel](docs/BulkDenyAdminAuthRequestRequestModel.md) - [CipherAttachmentModel](docs/CipherAttachmentModel.md) - [CipherBulkDeleteRequestModel](docs/CipherBulkDeleteRequestModel.md) - [CipherBulkMoveRequestModel](docs/CipherBulkMoveRequestModel.md) @@ -489,12 +499,12 @@ All URIs are relative to _http://localhost_ - [CipherMiniDetailsResponseModel](docs/CipherMiniDetailsResponseModel.md) - [CipherMiniDetailsResponseModelListResponseModel](docs/CipherMiniDetailsResponseModelListResponseModel.md) - [CipherMiniResponseModel](docs/CipherMiniResponseModel.md) +- [CipherMiniResponseModelListResponseModel](docs/CipherMiniResponseModelListResponseModel.md) - [CipherPartialRequestModel](docs/CipherPartialRequestModel.md) - [CipherPasswordHistoryModel](docs/CipherPasswordHistoryModel.md) - [CipherRepromptType](docs/CipherRepromptType.md) - [CipherRequestModel](docs/CipherRequestModel.md) - [CipherResponseModel](docs/CipherResponseModel.md) -- [CipherResponseModelListResponseModel](docs/CipherResponseModelListResponseModel.md) - [CipherSecureNoteModel](docs/CipherSecureNoteModel.md) - [CipherShareRequestModel](docs/CipherShareRequestModel.md) - [CipherType](docs/CipherType.md) @@ -510,6 +520,7 @@ All URIs are relative to _http://localhost_ - [CollectionWithIdRequestModel](docs/CollectionWithIdRequestModel.md) - [ConfigResponseModel](docs/ConfigResponseModel.md) - [DeleteRecoverRequestModel](docs/DeleteRecoverRequestModel.md) +- [DeviceKeysRequestModel](docs/DeviceKeysRequestModel.md) - [DeviceRequestModel](docs/DeviceRequestModel.md) - [DeviceResponseModel](docs/DeviceResponseModel.md) - [DeviceResponseModelListResponseModel](docs/DeviceResponseModelListResponseModel.md) @@ -542,6 +553,7 @@ All URIs are relative to _http://localhost_ - [FolderResponseModel](docs/FolderResponseModel.md) - [FolderResponseModelListResponseModel](docs/FolderResponseModelListResponseModel.md) - [FolderWithIdRequestModel](docs/FolderWithIdRequestModel.md) +- [GetSecretsRequestModel](docs/GetSecretsRequestModel.md) - [GlobalDomains](docs/GlobalDomains.md) - [GlobalEquivalentDomainsType](docs/GlobalEquivalentDomainsType.md) - [GrantedAccessPolicyRequest](docs/GrantedAccessPolicyRequest.md) @@ -571,6 +583,7 @@ All URIs are relative to _http://localhost_ - [KeysResponseModel](docs/KeysResponseModel.md) - [LicenseType](docs/LicenseType.md) - [MasterPasswordPolicyResponseModel](docs/MasterPasswordPolicyResponseModel.md) +- [MemberDecryptionType](docs/MemberDecryptionType.md) - [OpenIdConnectRedirectBehavior](docs/OpenIdConnectRedirectBehavior.md) - [OrganizationApiKeyInformation](docs/OrganizationApiKeyInformation.md) - [OrganizationApiKeyInformationListResponseModel](docs/OrganizationApiKeyInformationListResponseModel.md) @@ -632,6 +645,8 @@ All URIs are relative to _http://localhost_ - [PaymentMethodType](docs/PaymentMethodType.md) - [PaymentRequestModel](docs/PaymentRequestModel.md) - [PaymentResponseModel](docs/PaymentResponseModel.md) +- [PendingOrganizationAuthRequestResponseModel](docs/PendingOrganizationAuthRequestResponseModel.md) +- [PendingOrganizationAuthRequestResponseModelListResponseModel](docs/PendingOrganizationAuthRequestResponseModelListResponseModel.md) - [Permissions](docs/Permissions.md) - [PlanResponseModel](docs/PlanResponseModel.md) - [PlanResponseModelListResponseModel](docs/PlanResponseModelListResponseModel.md) @@ -700,6 +715,7 @@ All URIs are relative to _http://localhost_ - [SecretVerificationRequestModel](docs/SecretVerificationRequestModel.md) - [SecretWithProjectsInnerProject](docs/SecretWithProjectsInnerProject.md) - [SecretWithProjectsListResponseModel](docs/SecretWithProjectsListResponseModel.md) +- [SecretsManagerSubscriptionUpdateRequestModel](docs/SecretsManagerSubscriptionUpdateRequestModel.md) - [SecretsWithProjectsInnerSecret](docs/SecretsWithProjectsInnerSecret.md) - [SecureNoteType](docs/SecureNoteType.md) - [SelectionReadOnlyRequestModel](docs/SelectionReadOnlyRequestModel.md) diff --git a/crates/bitwarden-api-api/src/apis/auth_requests_api.rs b/crates/bitwarden-api-api/src/apis/auth_requests_api.rs index f93406215..476a94129 100644 --- a/crates/bitwarden-api-api/src/apis/auth_requests_api.rs +++ b/crates/bitwarden-api-api/src/apis/auth_requests_api.rs @@ -89,7 +89,7 @@ pub async fn auth_requests_get( pub async fn auth_requests_id_get( configuration: &configuration::Configuration, - id: &str, + id: uuid::Uuid, ) -> Result> { let local_var_configuration = configuration; @@ -133,7 +133,7 @@ pub async fn auth_requests_id_get( pub async fn auth_requests_id_put( configuration: &configuration::Configuration, - id: &str, + id: uuid::Uuid, auth_request_update_request_model: Option, ) -> Result> { let local_var_configuration = configuration; @@ -179,7 +179,7 @@ pub async fn auth_requests_id_put( pub async fn auth_requests_id_response_get( configuration: &configuration::Configuration, - id: &str, + id: uuid::Uuid, code: Option<&str>, ) -> Result> { let local_var_configuration = configuration; diff --git a/crates/bitwarden-api-api/src/apis/ciphers_api.rs b/crates/bitwarden-api-api/src/apis/ciphers_api.rs index 4e8fba7fc..4ca7f4969 100644 --- a/crates/bitwarden-api-api/src/apis/ciphers_api.rs +++ b/crates/bitwarden-api-api/src/apis/ciphers_api.rs @@ -363,6 +363,13 @@ pub enum CiphersPurgePostError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`ciphers_restore_admin_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersRestoreAdminPutError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`ciphers_restore_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -2604,10 +2611,58 @@ pub async fn ciphers_purge_post( } } +pub async fn ciphers_restore_admin_put( + configuration: &configuration::Configuration, + cipher_bulk_restore_request_model: Option, +) -> Result< + crate::models::CipherMiniResponseModelListResponseModel, + Error, +> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/restore-admin", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_bulk_restore_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn ciphers_restore_put( configuration: &configuration::Configuration, cipher_bulk_restore_request_model: Option, -) -> Result> { +) -> Result> +{ let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; diff --git a/crates/bitwarden-api-api/src/apis/devices_api.rs b/crates/bitwarden-api-api/src/apis/devices_api.rs index c58b8127e..e7be0685e 100644 --- a/crates/bitwarden-api-api/src/apis/devices_api.rs +++ b/crates/bitwarden-api-api/src/apis/devices_api.rs @@ -13,6 +13,13 @@ use reqwest; use super::{configuration, Error}; use crate::apis::ResponseContent; +/// struct for typed errors of method [`devices_exist_by_types_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DevicesExistByTypesPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`devices_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -90,6 +97,20 @@ pub enum DevicesIdentifierIdentifierTokenPutError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`devices_identifier_keys_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DevicesIdentifierKeysPostError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`devices_identifier_keys_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DevicesIdentifierKeysPutError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`devices_knowndevice_email_identifier_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -111,6 +132,50 @@ pub enum DevicesPostError { UnknownValue(serde_json::Value), } +pub async fn devices_exist_by_types_post( + configuration: &configuration::Configuration, + device_type: Option>, +) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/exist-by-types", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&device_type); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn devices_get( configuration: &configuration::Configuration, ) -> Result> { @@ -598,6 +663,98 @@ pub async fn devices_identifier_identifier_token_put( } } +pub async fn devices_identifier_keys_post( + configuration: &configuration::Configuration, + identifier: &str, + device_keys_request_model: Option, +) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/{identifier}/keys", + local_var_configuration.base_path, + identifier = crate::apis::urlencode(identifier.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&device_keys_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn devices_identifier_keys_put( + configuration: &configuration::Configuration, + identifier: &str, + device_keys_request_model: Option, +) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/{identifier}/keys", + local_var_configuration.base_path, + identifier = crate::apis::urlencode(identifier.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&device_keys_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn devices_knowndevice_email_identifier_get( configuration: &configuration::Configuration, email: &str, diff --git a/crates/bitwarden-api-api/src/apis/mod.rs b/crates/bitwarden-api-api/src/apis/mod.rs index be296aa0e..623d5d0b6 100644 --- a/crates/bitwarden-api-api/src/apis/mod.rs +++ b/crates/bitwarden-api-api/src/apis/mod.rs @@ -1,4 +1,5 @@ -use std::{error, fmt}; +use std::error; +use std::fmt; #[derive(Debug, Clone)] pub struct ResponseContent { @@ -78,6 +79,7 @@ pub mod info_api; pub mod installations_api; pub mod licenses_api; pub mod misc_api; +pub mod organization_auth_requests_api; pub mod organization_connections_api; pub mod organization_domain_api; pub mod organization_export_api; diff --git a/crates/bitwarden-api-api/src/apis/organization_auth_requests_api.rs b/crates/bitwarden-api-api/src/apis/organization_auth_requests_api.rs new file mode 100644 index 000000000..d27be50de --- /dev/null +++ b/crates/bitwarden-api-api/src/apis/organization_auth_requests_api.rs @@ -0,0 +1,180 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::apis::ResponseContent; + +/// struct for typed errors of method [`organizations_org_id_auth_requests_deny_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum OrganizationsOrgIdAuthRequestsDenyPostError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`organizations_org_id_auth_requests_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum OrganizationsOrgIdAuthRequestsGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`organizations_org_id_auth_requests_request_id_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum OrganizationsOrgIdAuthRequestsRequestIdPostError { + UnknownValue(serde_json::Value), +} + +pub async fn organizations_org_id_auth_requests_deny_post( + configuration: &configuration::Configuration, + org_id: uuid::Uuid, + bulk_deny_admin_auth_request_request_model: Option< + crate::models::BulkDenyAdminAuthRequestRequestModel, + >, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/auth-requests/deny", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&bulk_deny_admin_auth_request_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn organizations_org_id_auth_requests_get( + configuration: &configuration::Configuration, + org_id: uuid::Uuid, +) -> Result< + crate::models::PendingOrganizationAuthRequestResponseModelListResponseModel, + Error, +> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/auth-requests", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn organizations_org_id_auth_requests_request_id_post( + configuration: &configuration::Configuration, + org_id: uuid::Uuid, + request_id: uuid::Uuid, + admin_auth_request_update_request_model: Option< + crate::models::AdminAuthRequestUpdateRequestModel, + >, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/auth-requests/{requestId}", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id.to_string()), + requestId = crate::apis::urlencode(request_id.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&admin_auth_request_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/bitwarden-api-api/src/apis/organization_users_api.rs b/crates/bitwarden-api-api/src/apis/organization_users_api.rs index 9fcc814af..f81290a86 100644 --- a/crates/bitwarden-api-api/src/apis/organization_users_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_users_api.rs @@ -13,20 +13,6 @@ use reqwest; use super::{configuration, Error}; use crate::apis::ResponseContent; -/// struct for typed errors of method [`organizations_org_id_users_activate_patch`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdUsersActivatePatchError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`organizations_org_id_users_activate_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdUsersActivatePutError { - UnknownValue(serde_json::Value), -} - /// struct for typed errors of method [`organizations_org_id_users_confirm_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -34,20 +20,6 @@ pub enum OrganizationsOrgIdUsersConfirmPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_deactivate_patch`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdUsersDeactivatePatchError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`organizations_org_id_users_deactivate_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdUsersDeactivatePutError { - UnknownValue(serde_json::Value), -} - /// struct for typed errors of method [`organizations_org_id_users_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -62,24 +34,24 @@ pub enum OrganizationsOrgIdUsersDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_get`] +/// struct for typed errors of method [`organizations_org_id_users_enable_secrets_manager_patch`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum OrganizationsOrgIdUsersGetError { +pub enum OrganizationsOrgIdUsersEnableSecretsManagerPatchError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_activate_patch`] +/// struct for typed errors of method [`organizations_org_id_users_enable_secrets_manager_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum OrganizationsOrgIdUsersIdActivatePatchError { +pub enum OrganizationsOrgIdUsersEnableSecretsManagerPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_activate_put`] +/// struct for typed errors of method [`organizations_org_id_users_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum OrganizationsOrgIdUsersIdActivatePutError { +pub enum OrganizationsOrgIdUsersGetError { UnknownValue(serde_json::Value), } @@ -90,20 +62,6 @@ pub enum OrganizationsOrgIdUsersIdConfirmPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_deactivate_patch`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdUsersIdDeactivatePatchError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`organizations_org_id_users_id_deactivate_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdUsersIdDeactivatePutError { - UnknownValue(serde_json::Value), -} - /// struct for typed errors of method [`organizations_org_id_users_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -279,104 +237,6 @@ pub enum OrganizationsOrgIdUsersUserIdResetPasswordEnrollmentPutError { UnknownValue(serde_json::Value), } -pub async fn organizations_org_id_users_activate_patch( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_bulk_request_model: Option, -) -> Result< - crate::models::OrganizationUserBulkResponseModelListResponseModel, - Error, -> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{orgId}/users/activate", - local_var_configuration.base_path, - orgId = crate::apis::urlencode(org_id.to_string()) - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = - local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); - } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); - }; - local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); - - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; - - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; - - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) - } else { - let local_var_entity: Option = - serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { - status: local_var_status, - content: local_var_content, - entity: local_var_entity, - }; - Err(Error::ResponseError(local_var_error)) - } -} - -pub async fn organizations_org_id_users_activate_put( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_bulk_request_model: Option, -) -> Result< - crate::models::OrganizationUserBulkResponseModelListResponseModel, - Error, -> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{orgId}/users/activate", - local_var_configuration.base_path, - orgId = crate::apis::urlencode(org_id.to_string()) - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = - local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); - } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); - }; - local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); - - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; - - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; - - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) - } else { - let local_var_entity: Option = - serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { - status: local_var_status, - content: local_var_content, - entity: local_var_entity, - }; - Err(Error::ResponseError(local_var_error)) - } -} - pub async fn organizations_org_id_users_confirm_post( configuration: &configuration::Configuration, org_id: &str, @@ -429,25 +289,25 @@ pub async fn organizations_org_id_users_confirm_post( } } -pub async fn organizations_org_id_users_deactivate_patch( +pub async fn organizations_org_id_users_delete( configuration: &configuration::Configuration, - org_id: uuid::Uuid, + org_id: &str, organization_user_bulk_request_model: Option, ) -> Result< crate::models::OrganizationUserBulkResponseModelListResponseModel, - Error, + Error, > { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; let local_var_uri_str = format!( - "{}/organizations/{orgId}/users/deactivate", + "{}/organizations/{orgId}/users", local_var_configuration.base_path, orgId = crate::apis::urlencode(org_id.to_string()) ); let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { local_var_req_builder = @@ -467,7 +327,7 @@ pub async fn organizations_org_id_users_deactivate_patch( if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let local_var_entity: Option = + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, @@ -478,25 +338,25 @@ pub async fn organizations_org_id_users_deactivate_patch( } } -pub async fn organizations_org_id_users_deactivate_put( +pub async fn organizations_org_id_users_delete_post( configuration: &configuration::Configuration, - org_id: uuid::Uuid, + org_id: &str, organization_user_bulk_request_model: Option, ) -> Result< crate::models::OrganizationUserBulkResponseModelListResponseModel, - Error, + Error, > { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; let local_var_uri_str = format!( - "{}/organizations/{orgId}/users/deactivate", + "{}/organizations/{orgId}/users/delete", local_var_configuration.base_path, orgId = crate::apis::urlencode(org_id.to_string()) ); let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { local_var_req_builder = @@ -516,7 +376,7 @@ pub async fn organizations_org_id_users_deactivate_put( if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let local_var_entity: Option = + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, @@ -527,25 +387,25 @@ pub async fn organizations_org_id_users_deactivate_put( } } -pub async fn organizations_org_id_users_delete( +pub async fn organizations_org_id_users_enable_secrets_manager_patch( configuration: &configuration::Configuration, - org_id: &str, + org_id: uuid::Uuid, organization_user_bulk_request_model: Option, ) -> Result< crate::models::OrganizationUserBulkResponseModelListResponseModel, - Error, + Error, > { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; let local_var_uri_str = format!( - "{}/organizations/{orgId}/users", + "{}/organizations/{orgId}/users/enable-secrets-manager", local_var_configuration.base_path, orgId = crate::apis::urlencode(org_id.to_string()) ); let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { local_var_req_builder = @@ -565,7 +425,7 @@ pub async fn organizations_org_id_users_delete( if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let local_var_entity: Option = + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, @@ -576,25 +436,25 @@ pub async fn organizations_org_id_users_delete( } } -pub async fn organizations_org_id_users_delete_post( +pub async fn organizations_org_id_users_enable_secrets_manager_put( configuration: &configuration::Configuration, - org_id: &str, + org_id: uuid::Uuid, organization_user_bulk_request_model: Option, ) -> Result< crate::models::OrganizationUserBulkResponseModelListResponseModel, - Error, + Error, > { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; let local_var_uri_str = format!( - "{}/organizations/{orgId}/users/delete", + "{}/organizations/{orgId}/users/enable-secrets-manager", local_var_configuration.base_path, orgId = crate::apis::urlencode(org_id.to_string()) ); let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { local_var_req_builder = @@ -614,7 +474,7 @@ pub async fn organizations_org_id_users_delete_post( if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let local_var_entity: Option = + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, @@ -682,98 +542,6 @@ pub async fn organizations_org_id_users_get( } } -pub async fn organizations_org_id_users_id_activate_patch( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{orgId}/users/{id}/activate", - local_var_configuration.base_path, - orgId = crate::apis::urlencode(org_id.to_string()), - id = crate::apis::urlencode(id.to_string()) - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = - local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); - } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); - }; - - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; - - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; - - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - Ok(()) - } else { - let local_var_entity: Option = - serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { - status: local_var_status, - content: local_var_content, - entity: local_var_entity, - }; - Err(Error::ResponseError(local_var_error)) - } -} - -pub async fn organizations_org_id_users_id_activate_put( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{orgId}/users/{id}/activate", - local_var_configuration.base_path, - orgId = crate::apis::urlencode(org_id.to_string()), - id = crate::apis::urlencode(id.to_string()) - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = - local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); - } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); - }; - - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; - - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; - - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - Ok(()) - } else { - let local_var_entity: Option = - serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { - status: local_var_status, - content: local_var_content, - entity: local_var_entity, - }; - Err(Error::ResponseError(local_var_error)) - } -} - pub async fn organizations_org_id_users_id_confirm_post( configuration: &configuration::Configuration, org_id: &str, @@ -824,98 +592,6 @@ pub async fn organizations_org_id_users_id_confirm_post( } } -pub async fn organizations_org_id_users_id_deactivate_patch( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{orgId}/users/{id}/deactivate", - local_var_configuration.base_path, - orgId = crate::apis::urlencode(org_id.to_string()), - id = crate::apis::urlencode(id.to_string()) - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = - local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); - } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); - }; - - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; - - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; - - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - Ok(()) - } else { - let local_var_entity: Option = - serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { - status: local_var_status, - content: local_var_content, - entity: local_var_entity, - }; - Err(Error::ResponseError(local_var_error)) - } -} - -pub async fn organizations_org_id_users_id_deactivate_put( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{orgId}/users/{id}/deactivate", - local_var_configuration.base_path, - orgId = crate::apis::urlencode(org_id.to_string()), - id = crate::apis::urlencode(id.to_string()) - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = - local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); - } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); - }; - - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; - - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; - - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - Ok(()) - } else { - let local_var_entity: Option = - serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { - status: local_var_status, - content: local_var_content, - entity: local_var_entity, - }; - Err(Error::ResponseError(local_var_error)) - } -} - pub async fn organizations_org_id_users_id_delete( configuration: &configuration::Configuration, org_id: &str, diff --git a/crates/bitwarden-api-api/src/apis/organizations_api.rs b/crates/bitwarden-api-api/src/apis/organizations_api.rs index 4428d1a00..1cd531b2f 100644 --- a/crates/bitwarden-api-api/src/apis/organizations_api.rs +++ b/crates/bitwarden-api-api/src/apis/organizations_api.rs @@ -153,6 +153,13 @@ pub enum OrganizationsIdSeatPostError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`organizations_id_sm_subscription_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum OrganizationsIdSmSubscriptionPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`organizations_id_sso_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -1140,6 +1147,55 @@ pub async fn organizations_id_seat_post( } } +pub async fn organizations_id_sm_subscription_post( + configuration: &configuration::Configuration, + id: uuid::Uuid, + secrets_manager_subscription_update_request_model: Option< + crate::models::SecretsManagerSubscriptionUpdateRequestModel, + >, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/sm-subscription", + local_var_configuration.base_path, + id = crate::apis::urlencode(id.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&secrets_manager_subscription_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn organizations_id_sso_get( configuration: &configuration::Configuration, id: uuid::Uuid, diff --git a/crates/bitwarden-api-api/src/apis/plans_api.rs b/crates/bitwarden-api-api/src/apis/plans_api.rs index e0430ac66..83a9da2b9 100644 --- a/crates/bitwarden-api-api/src/apis/plans_api.rs +++ b/crates/bitwarden-api-api/src/apis/plans_api.rs @@ -13,6 +13,13 @@ use reqwest; use super::{configuration, Error}; use crate::apis::ResponseContent; +/// struct for typed errors of method [`plans_all_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PlansAllGetError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`plans_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -27,6 +34,52 @@ pub enum PlansSalesTaxRatesGetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`plans_sm_plans_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PlansSmPlansGetError { + UnknownValue(serde_json::Value), +} + +pub async fn plans_all_get( + configuration: &configuration::Configuration, +) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/plans/all", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn plans_get( configuration: &configuration::Configuration, ) -> Result> { @@ -107,3 +160,42 @@ pub async fn plans_sales_tax_rates_get( Err(Error::ResponseError(local_var_error)) } } + +pub async fn plans_sm_plans_get( + configuration: &configuration::Configuration, +) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/plans/sm-plans", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/bitwarden-api-api/src/apis/secrets_api.rs b/crates/bitwarden-api-api/src/apis/secrets_api.rs index b7adb7aa5..7a2f99fb9 100644 --- a/crates/bitwarden-api-api/src/apis/secrets_api.rs +++ b/crates/bitwarden-api-api/src/apis/secrets_api.rs @@ -41,6 +41,13 @@ pub enum SecretsDeletePostError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`secrets_get_by_ids_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SecretsGetByIdsPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`secrets_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -238,6 +245,48 @@ pub async fn secrets_delete_post( } } +pub async fn secrets_get_by_ids_post( + configuration: &configuration::Configuration, + get_secrets_request_model: Option, +) -> Result> +{ + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/secrets/get-by-ids", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&get_secrets_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn secrets_id_get( configuration: &configuration::Configuration, id: uuid::Uuid, diff --git a/crates/bitwarden-api-api/src/models/admin_auth_request_update_request_model.rs b/crates/bitwarden-api-api/src/models/admin_auth_request_update_request_model.rs new file mode 100644 index 000000000..ba7f199ce --- /dev/null +++ b/crates/bitwarden-api-api/src/models/admin_auth_request_update_request_model.rs @@ -0,0 +1,26 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct AdminAuthRequestUpdateRequestModel { + #[serde(rename = "encryptedUserKey", skip_serializing_if = "Option::is_none")] + pub encrypted_user_key: Option, + #[serde(rename = "requestApproved")] + pub request_approved: bool, +} + +impl AdminAuthRequestUpdateRequestModel { + pub fn new(request_approved: bool) -> AdminAuthRequestUpdateRequestModel { + AdminAuthRequestUpdateRequestModel { + encrypted_user_key: None, + request_approved, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/auth_request_type.rs b/crates/bitwarden-api-api/src/models/auth_request_type.rs index 7bbed5cb2..fbcfb8e9f 100644 --- a/crates/bitwarden-api-api/src/models/auth_request_type.rs +++ b/crates/bitwarden-api-api/src/models/auth_request_type.rs @@ -16,6 +16,7 @@ pub enum AuthRequestType { Variant0 = 0, Variant1 = 1, + Variant2 = 2, } impl ToString for AuthRequestType { @@ -23,6 +24,7 @@ impl ToString for AuthRequestType { match self { Self::Variant0 => String::from("0"), Self::Variant1 => String::from("1"), + Self::Variant2 => String::from("2"), } } } diff --git a/crates/bitwarden-api-api/src/models/base_secret_response_model.rs b/crates/bitwarden-api-api/src/models/base_secret_response_model.rs new file mode 100644 index 000000000..d2db29bc7 --- /dev/null +++ b/crates/bitwarden-api-api/src/models/base_secret_response_model.rs @@ -0,0 +1,47 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct BaseSecretResponseModel { + #[serde(rename = "object", skip_serializing_if = "Option::is_none")] + pub object: Option, + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "organizationId", skip_serializing_if = "Option::is_none")] + pub organization_id: Option, + #[serde(rename = "key", skip_serializing_if = "Option::is_none")] + pub key: Option, + #[serde(rename = "value", skip_serializing_if = "Option::is_none")] + pub value: Option, + #[serde(rename = "note", skip_serializing_if = "Option::is_none")] + pub note: Option, + #[serde(rename = "creationDate", skip_serializing_if = "Option::is_none")] + pub creation_date: Option, + #[serde(rename = "revisionDate", skip_serializing_if = "Option::is_none")] + pub revision_date: Option, + #[serde(rename = "projects", skip_serializing_if = "Option::is_none")] + pub projects: Option>, +} + +impl BaseSecretResponseModel { + pub fn new() -> BaseSecretResponseModel { + BaseSecretResponseModel { + object: None, + id: None, + organization_id: None, + key: None, + value: None, + note: None, + creation_date: None, + revision_date: None, + projects: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/base_secret_response_model_list_response_model.rs b/crates/bitwarden-api-api/src/models/base_secret_response_model_list_response_model.rs new file mode 100644 index 000000000..f65cb215d --- /dev/null +++ b/crates/bitwarden-api-api/src/models/base_secret_response_model_list_response_model.rs @@ -0,0 +1,29 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct BaseSecretResponseModelListResponseModel { + #[serde(rename = "object", skip_serializing_if = "Option::is_none")] + pub object: Option, + #[serde(rename = "data", skip_serializing_if = "Option::is_none")] + pub data: Option>, + #[serde(rename = "continuationToken", skip_serializing_if = "Option::is_none")] + pub continuation_token: Option, +} + +impl BaseSecretResponseModelListResponseModel { + pub fn new() -> BaseSecretResponseModelListResponseModel { + BaseSecretResponseModelListResponseModel { + object: None, + data: None, + continuation_token: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/billing_subscription_item.rs b/crates/bitwarden-api-api/src/models/billing_subscription_item.rs index e22878c76..7a9693eb2 100644 --- a/crates/bitwarden-api-api/src/models/billing_subscription_item.rs +++ b/crates/bitwarden-api-api/src/models/billing_subscription_item.rs @@ -23,6 +23,13 @@ pub struct BillingSubscriptionItem { skip_serializing_if = "Option::is_none" )] pub sponsored_subscription_item: Option, + #[serde( + rename = "addonSubscriptionItem", + skip_serializing_if = "Option::is_none" + )] + pub addon_subscription_item: Option, + #[serde(rename = "bitwardenProduct", skip_serializing_if = "Option::is_none")] + pub bitwarden_product: Option, } impl BillingSubscriptionItem { @@ -33,6 +40,8 @@ impl BillingSubscriptionItem { quantity: None, interval: None, sponsored_subscription_item: None, + addon_subscription_item: None, + bitwarden_product: None, } } } diff --git a/crates/bitwarden-api-api/src/models/bitwarden_product_type.rs b/crates/bitwarden-api-api/src/models/bitwarden_product_type.rs new file mode 100644 index 000000000..2224e9781 --- /dev/null +++ b/crates/bitwarden-api-api/src/models/bitwarden_product_type.rs @@ -0,0 +1,34 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +/// +#[repr(i64)] +#[derive( + Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize_repr, Deserialize_repr, +)] +pub enum BitwardenProductType { + Variant0 = 0, + Variant1 = 1, +} + +impl ToString for BitwardenProductType { + fn to_string(&self) -> String { + match self { + Self::Variant0 => String::from("0"), + Self::Variant1 => String::from("1"), + } + } +} + +impl Default for BitwardenProductType { + fn default() -> BitwardenProductType { + Self::Variant0 + } +} diff --git a/crates/bitwarden-api-api/src/models/bulk_deny_admin_auth_request_request_model.rs b/crates/bitwarden-api-api/src/models/bulk_deny_admin_auth_request_request_model.rs new file mode 100644 index 000000000..5108fb419 --- /dev/null +++ b/crates/bitwarden-api-api/src/models/bulk_deny_admin_auth_request_request_model.rs @@ -0,0 +1,21 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct BulkDenyAdminAuthRequestRequestModel { + #[serde(rename = "ids", skip_serializing_if = "Option::is_none")] + pub ids: Option>, +} + +impl BulkDenyAdminAuthRequestRequestModel { + pub fn new() -> BulkDenyAdminAuthRequestRequestModel { + BulkDenyAdminAuthRequestRequestModel { ids: None } + } +} diff --git a/crates/bitwarden-api-api/src/models/cipher_bulk_restore_request_model.rs b/crates/bitwarden-api-api/src/models/cipher_bulk_restore_request_model.rs index 60a6d5c74..9fe99c9ce 100644 --- a/crates/bitwarden-api-api/src/models/cipher_bulk_restore_request_model.rs +++ b/crates/bitwarden-api-api/src/models/cipher_bulk_restore_request_model.rs @@ -12,10 +12,15 @@ pub struct CipherBulkRestoreRequestModel { #[serde(rename = "ids")] pub ids: Vec, + #[serde(rename = "organizationId", skip_serializing_if = "Option::is_none")] + pub organization_id: Option, } impl CipherBulkRestoreRequestModel { pub fn new(ids: Vec) -> CipherBulkRestoreRequestModel { - CipherBulkRestoreRequestModel { ids } + CipherBulkRestoreRequestModel { + ids, + organization_id: None, + } } } diff --git a/crates/bitwarden-api-api/src/models/cipher_mini_response_model_list_response_model.rs b/crates/bitwarden-api-api/src/models/cipher_mini_response_model_list_response_model.rs new file mode 100644 index 000000000..10dbe91ec --- /dev/null +++ b/crates/bitwarden-api-api/src/models/cipher_mini_response_model_list_response_model.rs @@ -0,0 +1,29 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct CipherMiniResponseModelListResponseModel { + #[serde(rename = "object", skip_serializing_if = "Option::is_none")] + pub object: Option, + #[serde(rename = "data", skip_serializing_if = "Option::is_none")] + pub data: Option>, + #[serde(rename = "continuationToken", skip_serializing_if = "Option::is_none")] + pub continuation_token: Option, +} + +impl CipherMiniResponseModelListResponseModel { + pub fn new() -> CipherMiniResponseModelListResponseModel { + CipherMiniResponseModelListResponseModel { + object: None, + data: None, + continuation_token: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/device_keys_request_model.rs b/crates/bitwarden-api-api/src/models/device_keys_request_model.rs new file mode 100644 index 000000000..4b6fdbb69 --- /dev/null +++ b/crates/bitwarden-api-api/src/models/device_keys_request_model.rs @@ -0,0 +1,33 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct DeviceKeysRequestModel { + #[serde(rename = "encryptedUserKey")] + pub encrypted_user_key: String, + #[serde(rename = "encryptedPublicKey")] + pub encrypted_public_key: String, + #[serde(rename = "encryptedPrivateKey")] + pub encrypted_private_key: String, +} + +impl DeviceKeysRequestModel { + pub fn new( + encrypted_user_key: String, + encrypted_public_key: String, + encrypted_private_key: String, + ) -> DeviceKeysRequestModel { + DeviceKeysRequestModel { + encrypted_user_key, + encrypted_public_key, + encrypted_private_key, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/device_response_model.rs b/crates/bitwarden-api-api/src/models/device_response_model.rs index fb570dc07..463d6f104 100644 --- a/crates/bitwarden-api-api/src/models/device_response_model.rs +++ b/crates/bitwarden-api-api/src/models/device_response_model.rs @@ -22,6 +22,15 @@ pub struct DeviceResponseModel { pub identifier: Option, #[serde(rename = "creationDate", skip_serializing_if = "Option::is_none")] pub creation_date: Option, + #[serde(rename = "encryptedUserKey", skip_serializing_if = "Option::is_none")] + pub encrypted_user_key: Option, + #[serde(rename = "encryptedPublicKey", skip_serializing_if = "Option::is_none")] + pub encrypted_public_key: Option, + #[serde( + rename = "encryptedPrivateKey", + skip_serializing_if = "Option::is_none" + )] + pub encrypted_private_key: Option, } impl DeviceResponseModel { @@ -33,6 +42,9 @@ impl DeviceResponseModel { r#type: None, identifier: None, creation_date: None, + encrypted_user_key: None, + encrypted_public_key: None, + encrypted_private_key: None, } } } diff --git a/crates/bitwarden-api-api/src/models/environment_config_response_model.rs b/crates/bitwarden-api-api/src/models/environment_config_response_model.rs index 9075da375..1cceee850 100644 --- a/crates/bitwarden-api-api/src/models/environment_config_response_model.rs +++ b/crates/bitwarden-api-api/src/models/environment_config_response_model.rs @@ -10,6 +10,8 @@ #[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] pub struct EnvironmentConfigResponseModel { + #[serde(rename = "cloudRegion", skip_serializing_if = "Option::is_none")] + pub cloud_region: Option, #[serde(rename = "vault", skip_serializing_if = "Option::is_none")] pub vault: Option, #[serde(rename = "api", skip_serializing_if = "Option::is_none")] @@ -25,6 +27,7 @@ pub struct EnvironmentConfigResponseModel { impl EnvironmentConfigResponseModel { pub fn new() -> EnvironmentConfigResponseModel { EnvironmentConfigResponseModel { + cloud_region: None, vault: None, api: None, identity: None, diff --git a/crates/bitwarden-api-api/src/models/get_secrets_request_model.rs b/crates/bitwarden-api-api/src/models/get_secrets_request_model.rs new file mode 100644 index 000000000..2786d8c9d --- /dev/null +++ b/crates/bitwarden-api-api/src/models/get_secrets_request_model.rs @@ -0,0 +1,21 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct GetSecretsRequestModel { + #[serde(rename = "ids")] + pub ids: Vec, +} + +impl GetSecretsRequestModel { + pub fn new(ids: Vec) -> GetSecretsRequestModel { + GetSecretsRequestModel { ids } + } +} diff --git a/crates/bitwarden-api-api/src/models/global_equivalent_domains_type.rs b/crates/bitwarden-api-api/src/models/global_equivalent_domains_type.rs index fe00411ce..f5e1c3655 100644 --- a/crates/bitwarden-api-api/src/models/global_equivalent_domains_type.rs +++ b/crates/bitwarden-api-api/src/models/global_equivalent_domains_type.rs @@ -104,6 +104,7 @@ pub enum GlobalEquivalentDomainsType { Variant87 = 87, Variant88 = 88, Variant89 = 89, + Variant90 = 90, } impl ToString for GlobalEquivalentDomainsType { @@ -199,6 +200,7 @@ impl ToString for GlobalEquivalentDomainsType { Self::Variant87 => String::from("87"), Self::Variant88 => String::from("88"), Self::Variant89 => String::from("89"), + Self::Variant90 => String::from("90"), } } } diff --git a/crates/bitwarden-api-api/src/models/member_decryption_type.rs b/crates/bitwarden-api-api/src/models/member_decryption_type.rs new file mode 100644 index 000000000..e36344a9f --- /dev/null +++ b/crates/bitwarden-api-api/src/models/member_decryption_type.rs @@ -0,0 +1,36 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +/// +#[repr(i64)] +#[derive( + Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize_repr, Deserialize_repr, +)] +pub enum MemberDecryptionType { + Variant0 = 0, + Variant1 = 1, + Variant2 = 2, +} + +impl ToString for MemberDecryptionType { + fn to_string(&self) -> String { + match self { + Self::Variant0 => String::from("0"), + Self::Variant1 => String::from("1"), + Self::Variant2 => String::from("2"), + } + } +} + +impl Default for MemberDecryptionType { + fn default() -> MemberDecryptionType { + Self::Variant0 + } +} diff --git a/crates/bitwarden-api-api/src/models/mod.rs b/crates/bitwarden-api-api/src/models/mod.rs index eaecf1b09..9d2aa9ae8 100644 --- a/crates/bitwarden-api-api/src/models/mod.rs +++ b/crates/bitwarden-api-api/src/models/mod.rs @@ -12,6 +12,8 @@ pub mod access_token_response_model; pub use self::access_token_response_model::AccessTokenResponseModel; pub mod access_token_response_model_list_response_model; pub use self::access_token_response_model_list_response_model::AccessTokenResponseModelListResponseModel; +pub mod admin_auth_request_update_request_model; +pub use self::admin_auth_request_update_request_model::AdminAuthRequestUpdateRequestModel; pub mod api_key_response_model; pub use self::api_key_response_model::ApiKeyResponseModel; pub mod attachment_request_model; @@ -36,6 +38,10 @@ pub mod authenticator_attestation_raw_response; pub use self::authenticator_attestation_raw_response::AuthenticatorAttestationRawResponse; pub mod base_access_policy_response_model; pub use self::base_access_policy_response_model::BaseAccessPolicyResponseModel; +pub mod base_secret_response_model; +pub use self::base_secret_response_model::BaseSecretResponseModel; +pub mod base_secret_response_model_list_response_model; +pub use self::base_secret_response_model_list_response_model::BaseSecretResponseModelListResponseModel; pub mod billing_history_response_model; pub use self::billing_history_response_model::BillingHistoryResponseModel; pub mod billing_invoice; @@ -56,10 +62,14 @@ pub mod billing_transaction; pub use self::billing_transaction::BillingTransaction; pub mod bit_pay_invoice_request_model; pub use self::bit_pay_invoice_request_model::BitPayInvoiceRequestModel; +pub mod bitwarden_product_type; +pub use self::bitwarden_product_type::BitwardenProductType; pub mod bulk_delete_response_model; pub use self::bulk_delete_response_model::BulkDeleteResponseModel; pub mod bulk_delete_response_model_list_response_model; pub use self::bulk_delete_response_model_list_response_model::BulkDeleteResponseModelListResponseModel; +pub mod bulk_deny_admin_auth_request_request_model; +pub use self::bulk_deny_admin_auth_request_request_model::BulkDenyAdminAuthRequestRequestModel; pub mod cipher_attachment_model; pub use self::cipher_attachment_model::CipherAttachmentModel; pub mod cipher_bulk_delete_request_model; @@ -94,6 +104,8 @@ pub mod cipher_mini_details_response_model_list_response_model; pub use self::cipher_mini_details_response_model_list_response_model::CipherMiniDetailsResponseModelListResponseModel; pub mod cipher_mini_response_model; pub use self::cipher_mini_response_model::CipherMiniResponseModel; +pub mod cipher_mini_response_model_list_response_model; +pub use self::cipher_mini_response_model_list_response_model::CipherMiniResponseModelListResponseModel; pub mod cipher_partial_request_model; pub use self::cipher_partial_request_model::CipherPartialRequestModel; pub mod cipher_password_history_model; @@ -104,8 +116,6 @@ pub mod cipher_request_model; pub use self::cipher_request_model::CipherRequestModel; pub mod cipher_response_model; pub use self::cipher_response_model::CipherResponseModel; -pub mod cipher_response_model_list_response_model; -pub use self::cipher_response_model_list_response_model::CipherResponseModelListResponseModel; pub mod cipher_secure_note_model; pub use self::cipher_secure_note_model::CipherSecureNoteModel; pub mod cipher_share_request_model; @@ -136,6 +146,8 @@ pub mod config_response_model; pub use self::config_response_model::ConfigResponseModel; pub mod delete_recover_request_model; pub use self::delete_recover_request_model::DeleteRecoverRequestModel; +pub mod device_keys_request_model; +pub use self::device_keys_request_model::DeviceKeysRequestModel; pub mod device_request_model; pub use self::device_request_model::DeviceRequestModel; pub mod device_response_model; @@ -200,6 +212,8 @@ pub mod folder_response_model_list_response_model; pub use self::folder_response_model_list_response_model::FolderResponseModelListResponseModel; pub mod folder_with_id_request_model; pub use self::folder_with_id_request_model::FolderWithIdRequestModel; +pub mod get_secrets_request_model; +pub use self::get_secrets_request_model::GetSecretsRequestModel; pub mod global_domains; pub use self::global_domains::GlobalDomains; pub mod global_equivalent_domains_type; @@ -258,6 +272,8 @@ pub mod license_type; pub use self::license_type::LicenseType; pub mod master_password_policy_response_model; pub use self::master_password_policy_response_model::MasterPasswordPolicyResponseModel; +pub mod member_decryption_type; +pub use self::member_decryption_type::MemberDecryptionType; pub mod open_id_connect_redirect_behavior; pub use self::open_id_connect_redirect_behavior::OpenIdConnectRedirectBehavior; pub mod organization_api_key_information; @@ -380,6 +396,10 @@ pub mod payment_request_model; pub use self::payment_request_model::PaymentRequestModel; pub mod payment_response_model; pub use self::payment_response_model::PaymentResponseModel; +pub mod pending_organization_auth_request_response_model; +pub use self::pending_organization_auth_request_response_model::PendingOrganizationAuthRequestResponseModel; +pub mod pending_organization_auth_request_response_model_list_response_model; +pub use self::pending_organization_auth_request_response_model_list_response_model::PendingOrganizationAuthRequestResponseModelListResponseModel; pub mod permissions; pub use self::permissions::Permissions; pub mod plan_response_model; @@ -516,6 +536,8 @@ pub mod secret_with_projects_inner_project; pub use self::secret_with_projects_inner_project::SecretWithProjectsInnerProject; pub mod secret_with_projects_list_response_model; pub use self::secret_with_projects_list_response_model::SecretWithProjectsListResponseModel; +pub mod secrets_manager_subscription_update_request_model; +pub use self::secrets_manager_subscription_update_request_model::SecretsManagerSubscriptionUpdateRequestModel; pub mod secrets_with_projects_inner_secret; pub use self::secrets_with_projects_inner_secret::SecretsWithProjectsInnerSecret; pub mod secure_note_type; diff --git a/crates/bitwarden-api-api/src/models/organization_create_request_model.rs b/crates/bitwarden-api-api/src/models/organization_create_request_model.rs index 3fcbef4fd..493737ccf 100644 --- a/crates/bitwarden-api-api/src/models/organization_create_request_model.rs +++ b/crates/bitwarden-api-api/src/models/organization_create_request_model.rs @@ -68,10 +68,24 @@ pub struct OrganizationCreateRequestModel { pub billing_address_country: Option, #[serde(rename = "maxAutoscaleSeats", skip_serializing_if = "Option::is_none")] pub max_autoscale_seats: Option, + #[serde(rename = "additionalSmSeats", skip_serializing_if = "Option::is_none")] + pub additional_sm_seats: Option, + #[serde( + rename = "additionalServiceAccounts", + skip_serializing_if = "Option::is_none" + )] + pub additional_service_accounts: Option, + #[serde(rename = "useSecretsManager")] + pub use_secrets_manager: bool, } impl OrganizationCreateRequestModel { - pub fn new(name: String, billing_email: String, key: String) -> OrganizationCreateRequestModel { + pub fn new( + name: String, + billing_email: String, + key: String, + use_secrets_manager: bool, + ) -> OrganizationCreateRequestModel { OrganizationCreateRequestModel { name, business_name: None, @@ -93,6 +107,9 @@ impl OrganizationCreateRequestModel { billing_address_postal_code: None, billing_address_country: None, max_autoscale_seats: None, + additional_sm_seats: None, + additional_service_accounts: None, + use_secrets_manager, } } } diff --git a/crates/bitwarden-api-api/src/models/organization_license.rs b/crates/bitwarden-api-api/src/models/organization_license.rs index 1e0d3de6e..b440b8e00 100644 --- a/crates/bitwarden-api-api/src/models/organization_license.rs +++ b/crates/bitwarden-api-api/src/models/organization_license.rs @@ -73,6 +73,11 @@ pub struct OrganizationLicense { pub refresh: Option, #[serde(rename = "expires", skip_serializing_if = "Option::is_none")] pub expires: Option, + #[serde( + rename = "expirationWithoutGracePeriod", + skip_serializing_if = "Option::is_none" + )] + pub expiration_without_grace_period: Option, #[serde(rename = "trial", skip_serializing_if = "Option::is_none")] pub trial: Option, #[serde(rename = "licenseType", skip_serializing_if = "Option::is_none")] @@ -116,6 +121,7 @@ impl OrganizationLicense { issued: None, refresh: None, expires: None, + expiration_without_grace_period: None, trial: None, license_type: None, hash: None, diff --git a/crates/bitwarden-api-api/src/models/organization_response_model.rs b/crates/bitwarden-api-api/src/models/organization_response_model.rs index fc6db4a70..6618b1f79 100644 --- a/crates/bitwarden-api-api/src/models/organization_response_model.rs +++ b/crates/bitwarden-api-api/src/models/organization_response_model.rs @@ -32,6 +32,8 @@ pub struct OrganizationResponseModel { pub billing_email: Option, #[serde(rename = "plan", skip_serializing_if = "Option::is_none")] pub plan: Option>, + #[serde(rename = "secretsManagerPlan", skip_serializing_if = "Option::is_none")] + pub secrets_manager_plan: Option>, #[serde(rename = "planType", skip_serializing_if = "Option::is_none")] pub plan_type: Option, #[serde(rename = "seats", skip_serializing_if = "Option::is_none")] @@ -80,6 +82,22 @@ pub struct OrganizationResponseModel { skip_serializing_if = "Option::is_none" )] pub has_public_and_private_keys: Option, + #[serde(rename = "usePasswordManager", skip_serializing_if = "Option::is_none")] + pub use_password_manager: Option, + #[serde(rename = "smSeats", skip_serializing_if = "Option::is_none")] + pub sm_seats: Option, + #[serde(rename = "smServiceAccounts", skip_serializing_if = "Option::is_none")] + pub sm_service_accounts: Option, + #[serde( + rename = "maxAutoscaleSmSeats", + skip_serializing_if = "Option::is_none" + )] + pub max_autoscale_sm_seats: Option, + #[serde( + rename = "maxAutoscaleSmServiceAccounts", + skip_serializing_if = "Option::is_none" + )] + pub max_autoscale_sm_service_accounts: Option, } impl OrganizationResponseModel { @@ -96,6 +114,7 @@ impl OrganizationResponseModel { business_tax_number: None, billing_email: None, plan: None, + secrets_manager_plan: None, plan_type: None, seats: None, max_autoscale_seats: None, @@ -117,6 +136,11 @@ impl OrganizationResponseModel { use_custom_permissions: None, self_host: None, has_public_and_private_keys: None, + use_password_manager: None, + sm_seats: None, + sm_service_accounts: None, + max_autoscale_sm_seats: None, + max_autoscale_sm_service_accounts: None, } } } diff --git a/crates/bitwarden-api-api/src/models/organization_subscription_response_model.rs b/crates/bitwarden-api-api/src/models/organization_subscription_response_model.rs index 31171a8db..c3789f17a 100644 --- a/crates/bitwarden-api-api/src/models/organization_subscription_response_model.rs +++ b/crates/bitwarden-api-api/src/models/organization_subscription_response_model.rs @@ -32,6 +32,8 @@ pub struct OrganizationSubscriptionResponseModel { pub billing_email: Option, #[serde(rename = "plan", skip_serializing_if = "Option::is_none")] pub plan: Option>, + #[serde(rename = "secretsManagerPlan", skip_serializing_if = "Option::is_none")] + pub secrets_manager_plan: Option>, #[serde(rename = "planType", skip_serializing_if = "Option::is_none")] pub plan_type: Option, #[serde(rename = "seats", skip_serializing_if = "Option::is_none")] @@ -80,6 +82,22 @@ pub struct OrganizationSubscriptionResponseModel { skip_serializing_if = "Option::is_none" )] pub has_public_and_private_keys: Option, + #[serde(rename = "usePasswordManager", skip_serializing_if = "Option::is_none")] + pub use_password_manager: Option, + #[serde(rename = "smSeats", skip_serializing_if = "Option::is_none")] + pub sm_seats: Option, + #[serde(rename = "smServiceAccounts", skip_serializing_if = "Option::is_none")] + pub sm_service_accounts: Option, + #[serde( + rename = "maxAutoscaleSmSeats", + skip_serializing_if = "Option::is_none" + )] + pub max_autoscale_sm_seats: Option, + #[serde( + rename = "maxAutoscaleSmServiceAccounts", + skip_serializing_if = "Option::is_none" + )] + pub max_autoscale_sm_service_accounts: Option, #[serde(rename = "storageName", skip_serializing_if = "Option::is_none")] pub storage_name: Option, #[serde(rename = "storageGb", skip_serializing_if = "Option::is_none")] @@ -88,8 +106,17 @@ pub struct OrganizationSubscriptionResponseModel { pub subscription: Option>, #[serde(rename = "upcomingInvoice", skip_serializing_if = "Option::is_none")] pub upcoming_invoice: Option>, + /// Date when a self-hosted organization's subscription expires, without any grace period. + #[serde( + rename = "expirationWithoutGracePeriod", + skip_serializing_if = "Option::is_none" + )] + pub expiration_without_grace_period: Option, + /// Date when a self-hosted organization expires (includes grace period). #[serde(rename = "expiration", skip_serializing_if = "Option::is_none")] pub expiration: Option, + #[serde(rename = "secretsManagerBeta", skip_serializing_if = "Option::is_none")] + pub secrets_manager_beta: Option, } impl OrganizationSubscriptionResponseModel { @@ -106,6 +133,7 @@ impl OrganizationSubscriptionResponseModel { business_tax_number: None, billing_email: None, plan: None, + secrets_manager_plan: None, plan_type: None, seats: None, max_autoscale_seats: None, @@ -127,11 +155,18 @@ impl OrganizationSubscriptionResponseModel { use_custom_permissions: None, self_host: None, has_public_and_private_keys: None, + use_password_manager: None, + sm_seats: None, + sm_service_accounts: None, + max_autoscale_sm_seats: None, + max_autoscale_sm_service_accounts: None, storage_name: None, storage_gb: None, subscription: None, upcoming_invoice: None, + expiration_without_grace_period: None, expiration: None, + secrets_manager_beta: None, } } } diff --git a/crates/bitwarden-api-api/src/models/organization_upgrade_request_model.rs b/crates/bitwarden-api-api/src/models/organization_upgrade_request_model.rs index a8ae5fe4a..23f605dab 100644 --- a/crates/bitwarden-api-api/src/models/organization_upgrade_request_model.rs +++ b/crates/bitwarden-api-api/src/models/organization_upgrade_request_model.rs @@ -21,6 +21,15 @@ pub struct OrganizationUpgradeRequestModel { skip_serializing_if = "Option::is_none" )] pub additional_storage_gb: Option, + #[serde(rename = "additionalSmSeats", skip_serializing_if = "Option::is_none")] + pub additional_sm_seats: Option, + #[serde( + rename = "additionalServiceAccounts", + skip_serializing_if = "Option::is_none" + )] + pub additional_service_accounts: Option, + #[serde(rename = "useSecretsManager")] + pub use_secrets_manager: bool, #[serde(rename = "premiumAccessAddon", skip_serializing_if = "Option::is_none")] pub premium_access_addon: Option, #[serde( @@ -38,12 +47,15 @@ pub struct OrganizationUpgradeRequestModel { } impl OrganizationUpgradeRequestModel { - pub fn new() -> OrganizationUpgradeRequestModel { + pub fn new(use_secrets_manager: bool) -> OrganizationUpgradeRequestModel { OrganizationUpgradeRequestModel { business_name: None, plan_type: None, additional_seats: None, additional_storage_gb: None, + additional_sm_seats: None, + additional_service_accounts: None, + use_secrets_manager, premium_access_addon: None, billing_address_country: None, billing_address_postal_code: None, diff --git a/crates/bitwarden-api-api/src/models/organization_user_details_response_model.rs b/crates/bitwarden-api-api/src/models/organization_user_details_response_model.rs index d4672811e..179bb4a54 100644 --- a/crates/bitwarden-api-api/src/models/organization_user_details_response_model.rs +++ b/crates/bitwarden-api-api/src/models/organization_user_details_response_model.rs @@ -38,6 +38,8 @@ pub struct OrganizationUserDetailsResponseModel { pub reset_password_enrolled: Option, #[serde(rename = "usesKeyConnector", skip_serializing_if = "Option::is_none")] pub uses_key_connector: Option, + #[serde(rename = "hasMasterPassword", skip_serializing_if = "Option::is_none")] + pub has_master_password: Option, #[serde(rename = "collections", skip_serializing_if = "Option::is_none")] pub collections: Option>, #[serde(rename = "groups", skip_serializing_if = "Option::is_none")] @@ -58,6 +60,7 @@ impl OrganizationUserDetailsResponseModel { permissions: None, reset_password_enrolled: None, uses_key_connector: None, + has_master_password: None, collections: None, groups: None, } diff --git a/crates/bitwarden-api-api/src/models/organization_user_user_details_response_model.rs b/crates/bitwarden-api-api/src/models/organization_user_user_details_response_model.rs index 86eeb602e..96d06ff30 100644 --- a/crates/bitwarden-api-api/src/models/organization_user_user_details_response_model.rs +++ b/crates/bitwarden-api-api/src/models/organization_user_user_details_response_model.rs @@ -38,6 +38,8 @@ pub struct OrganizationUserUserDetailsResponseModel { pub reset_password_enrolled: Option, #[serde(rename = "usesKeyConnector", skip_serializing_if = "Option::is_none")] pub uses_key_connector: Option, + #[serde(rename = "hasMasterPassword", skip_serializing_if = "Option::is_none")] + pub has_master_password: Option, #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, #[serde(rename = "email", skip_serializing_if = "Option::is_none")] @@ -68,6 +70,7 @@ impl OrganizationUserUserDetailsResponseModel { permissions: None, reset_password_enrolled: None, uses_key_connector: None, + has_master_password: None, name: None, email: None, avatar_color: None, diff --git a/crates/bitwarden-api-api/src/models/pending_organization_auth_request_response_model.rs b/crates/bitwarden-api-api/src/models/pending_organization_auth_request_response_model.rs new file mode 100644 index 000000000..fafb94836 --- /dev/null +++ b/crates/bitwarden-api-api/src/models/pending_organization_auth_request_response_model.rs @@ -0,0 +1,53 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct PendingOrganizationAuthRequestResponseModel { + #[serde(rename = "object", skip_serializing_if = "Option::is_none")] + pub object: Option, + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "userId", skip_serializing_if = "Option::is_none")] + pub user_id: Option, + #[serde(rename = "organizationUserId", skip_serializing_if = "Option::is_none")] + pub organization_user_id: Option, + #[serde(rename = "email", skip_serializing_if = "Option::is_none")] + pub email: Option, + #[serde(rename = "publicKey", skip_serializing_if = "Option::is_none")] + pub public_key: Option, + #[serde( + rename = "requestDeviceIdentifier", + skip_serializing_if = "Option::is_none" + )] + pub request_device_identifier: Option, + #[serde(rename = "requestDeviceType", skip_serializing_if = "Option::is_none")] + pub request_device_type: Option, + #[serde(rename = "requestIpAddress", skip_serializing_if = "Option::is_none")] + pub request_ip_address: Option, + #[serde(rename = "creationDate", skip_serializing_if = "Option::is_none")] + pub creation_date: Option, +} + +impl PendingOrganizationAuthRequestResponseModel { + pub fn new() -> PendingOrganizationAuthRequestResponseModel { + PendingOrganizationAuthRequestResponseModel { + object: None, + id: None, + user_id: None, + organization_user_id: None, + email: None, + public_key: None, + request_device_identifier: None, + request_device_type: None, + request_ip_address: None, + creation_date: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/pending_organization_auth_request_response_model_list_response_model.rs b/crates/bitwarden-api-api/src/models/pending_organization_auth_request_response_model_list_response_model.rs new file mode 100644 index 000000000..43b6a9d31 --- /dev/null +++ b/crates/bitwarden-api-api/src/models/pending_organization_auth_request_response_model_list_response_model.rs @@ -0,0 +1,29 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct PendingOrganizationAuthRequestResponseModelListResponseModel { + #[serde(rename = "object", skip_serializing_if = "Option::is_none")] + pub object: Option, + #[serde(rename = "data", skip_serializing_if = "Option::is_none")] + pub data: Option>, + #[serde(rename = "continuationToken", skip_serializing_if = "Option::is_none")] + pub continuation_token: Option, +} + +impl PendingOrganizationAuthRequestResponseModelListResponseModel { + pub fn new() -> PendingOrganizationAuthRequestResponseModelListResponseModel { + PendingOrganizationAuthRequestResponseModelListResponseModel { + object: None, + data: None, + continuation_token: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/plan_response_model.rs b/crates/bitwarden-api-api/src/models/plan_response_model.rs index 0116ed079..17dcb777b 100644 --- a/crates/bitwarden-api-api/src/models/plan_response_model.rs +++ b/crates/bitwarden-api-api/src/models/plan_response_model.rs @@ -125,6 +125,34 @@ pub struct PlanResponseModel { skip_serializing_if = "Option::is_none" )] pub premium_access_option_price: Option, + #[serde( + rename = "stripeServiceAccountPlanId", + skip_serializing_if = "Option::is_none" + )] + pub stripe_service_account_plan_id: Option, + #[serde( + rename = "additionalPricePerServiceAccount", + skip_serializing_if = "Option::is_none" + )] + pub additional_price_per_service_account: Option, + #[serde(rename = "baseServiceAccount", skip_serializing_if = "Option::is_none")] + pub base_service_account: Option, + #[serde(rename = "maxServiceAccounts", skip_serializing_if = "Option::is_none")] + pub max_service_accounts: Option, + #[serde( + rename = "maxAdditionalServiceAccounts", + skip_serializing_if = "Option::is_none" + )] + pub max_additional_service_accounts: Option, + #[serde( + rename = "hasAdditionalServiceAccountOption", + skip_serializing_if = "Option::is_none" + )] + pub has_additional_service_account_option: Option, + #[serde(rename = "maxProjects", skip_serializing_if = "Option::is_none")] + pub max_projects: Option, + #[serde(rename = "bitwardenProduct", skip_serializing_if = "Option::is_none")] + pub bitwarden_product: Option, } impl PlanResponseModel { @@ -171,6 +199,14 @@ impl PlanResponseModel { seat_price: None, additional_storage_price_per_gb: None, premium_access_option_price: None, + stripe_service_account_plan_id: None, + additional_price_per_service_account: None, + base_service_account: None, + max_service_accounts: None, + max_additional_service_accounts: None, + has_additional_service_account_option: None, + max_projects: None, + bitwarden_product: None, } } } diff --git a/crates/bitwarden-api-api/src/models/profile_organization_response_model.rs b/crates/bitwarden-api-api/src/models/profile_organization_response_model.rs index bfc412cde..ec818fb7d 100644 --- a/crates/bitwarden-api-api/src/models/profile_organization_response_model.rs +++ b/crates/bitwarden-api-api/src/models/profile_organization_response_model.rs @@ -40,6 +40,8 @@ pub struct ProfileOrganizationResponseModel { pub use_reset_password: Option, #[serde(rename = "useSecretsManager", skip_serializing_if = "Option::is_none")] pub use_secrets_manager: Option, + #[serde(rename = "usePasswordManager", skip_serializing_if = "Option::is_none")] + pub use_password_manager: Option, #[serde(rename = "usersGetPremium", skip_serializing_if = "Option::is_none")] pub users_get_premium: Option, #[serde( @@ -151,6 +153,7 @@ impl ProfileOrganizationResponseModel { use_api: None, use_reset_password: None, use_secrets_manager: None, + use_password_manager: None, users_get_premium: None, use_custom_permissions: None, use_activate_autofill_policy: None, diff --git a/crates/bitwarden-api-api/src/models/profile_provider_organization_response_model.rs b/crates/bitwarden-api-api/src/models/profile_provider_organization_response_model.rs index 5e5116f46..9f8a03ba9 100644 --- a/crates/bitwarden-api-api/src/models/profile_provider_organization_response_model.rs +++ b/crates/bitwarden-api-api/src/models/profile_provider_organization_response_model.rs @@ -40,6 +40,8 @@ pub struct ProfileProviderOrganizationResponseModel { pub use_reset_password: Option, #[serde(rename = "useSecretsManager", skip_serializing_if = "Option::is_none")] pub use_secrets_manager: Option, + #[serde(rename = "usePasswordManager", skip_serializing_if = "Option::is_none")] + pub use_password_manager: Option, #[serde(rename = "usersGetPremium", skip_serializing_if = "Option::is_none")] pub users_get_premium: Option, #[serde( @@ -151,6 +153,7 @@ impl ProfileProviderOrganizationResponseModel { use_api: None, use_reset_password: None, use_secrets_manager: None, + use_password_manager: None, users_get_premium: None, use_custom_permissions: None, use_activate_autofill_policy: None, diff --git a/crates/bitwarden-api-api/src/models/secrets_manager_subscription_update_request_model.rs b/crates/bitwarden-api-api/src/models/secrets_manager_subscription_update_request_model.rs new file mode 100644 index 000000000..406769bce --- /dev/null +++ b/crates/bitwarden-api-api/src/models/secrets_manager_subscription_update_request_model.rs @@ -0,0 +1,38 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct SecretsManagerSubscriptionUpdateRequestModel { + #[serde(rename = "seatAdjustment")] + pub seat_adjustment: i32, + #[serde(rename = "maxAutoscaleSeats", skip_serializing_if = "Option::is_none")] + pub max_autoscale_seats: Option, + #[serde( + rename = "serviceAccountAdjustment", + skip_serializing_if = "Option::is_none" + )] + pub service_account_adjustment: Option, + #[serde( + rename = "maxAutoscaleServiceAccounts", + skip_serializing_if = "Option::is_none" + )] + pub max_autoscale_service_accounts: Option, +} + +impl SecretsManagerSubscriptionUpdateRequestModel { + pub fn new(seat_adjustment: i32) -> SecretsManagerSubscriptionUpdateRequestModel { + SecretsManagerSubscriptionUpdateRequestModel { + seat_adjustment, + max_autoscale_seats: None, + service_account_adjustment: None, + max_autoscale_service_accounts: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/sso_configuration_data.rs b/crates/bitwarden-api-api/src/models/sso_configuration_data.rs index 21d4fe8e4..0e2890ad9 100644 --- a/crates/bitwarden-api-api/src/models/sso_configuration_data.rs +++ b/crates/bitwarden-api-api/src/models/sso_configuration_data.rs @@ -12,6 +12,12 @@ pub struct SsoConfigurationData { #[serde(rename = "configType", skip_serializing_if = "Option::is_none")] pub config_type: Option, + #[serde( + rename = "memberDecryptionType", + skip_serializing_if = "Option::is_none" + )] + pub member_decryption_type: Option, + /// Legacy property to determine if KeyConnector was enabled. Kept for backwards compatibility with old configs that will not have the new Bit.Core.Auth.Models.Data.SsoConfigurationData.MemberDecryptionType when deserialized from the database. #[serde( rename = "keyConnectorEnabled", skip_serializing_if = "Option::is_none" @@ -129,6 +135,7 @@ impl SsoConfigurationData { pub fn new() -> SsoConfigurationData { SsoConfigurationData { config_type: None, + member_decryption_type: None, key_connector_enabled: None, key_connector_url: None, authority: None, diff --git a/crates/bitwarden-api-api/src/models/sso_configuration_data_request.rs b/crates/bitwarden-api-api/src/models/sso_configuration_data_request.rs index 7a965c6b9..8e6f18ced 100644 --- a/crates/bitwarden-api-api/src/models/sso_configuration_data_request.rs +++ b/crates/bitwarden-api-api/src/models/sso_configuration_data_request.rs @@ -12,6 +12,11 @@ pub struct SsoConfigurationDataRequest { #[serde(rename = "configType")] pub config_type: crate::models::SsoType, + #[serde( + rename = "memberDecryptionType", + skip_serializing_if = "Option::is_none" + )] + pub member_decryption_type: Option, #[serde( rename = "keyConnectorEnabled", skip_serializing_if = "Option::is_none" @@ -129,6 +134,7 @@ impl SsoConfigurationDataRequest { pub fn new(config_type: crate::models::SsoType) -> SsoConfigurationDataRequest { SsoConfigurationDataRequest { config_type, + member_decryption_type: None, key_connector_enabled: None, key_connector_url: None, authority: None, From 76865d9b6857070d7e66f08755c9b02180fe8756 Mon Sep 17 00:00:00 2001 From: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> Date: Mon, 28 Aug 2023 10:38:11 -0500 Subject: [PATCH 02/10] [SM-865] Part 2 Use new get secrets by IDs endpoint (#150) * Add auto generated Api bindings * Expose new endpoint methods in SDK * Use in bws CLI * Expose new command in JSON schemas * restructure and rename response * Expose getByIds in napi * fix cargo check * Add openapi auto generation * Regenerated open api doc * revert back to original binding.js * remove .clone() * Add to changelog * run cargo fmt --- crates/bitwarden-json/src/client.rs | 3 ++ crates/bitwarden-json/src/command.rs | 10 ++++- .../src-ts/bitwarden_client/index.ts | 13 ++++++ crates/bitwarden/CHANGELOG.md | 2 + .../src/secrets_manager/client_secrets.rs | 13 ++++-- .../src/secrets_manager/secrets/get_by_ids.rs | 30 +++++++++++++ .../src/secrets_manager/secrets/mod.rs | 5 ++- .../secrets/secret_response.rs | 43 ++++++++++++++++++- crates/bws/src/main.rs | 14 +++--- crates/sdk-schemas/src/main.rs | 1 + 10 files changed, 120 insertions(+), 14 deletions(-) create mode 100644 crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs diff --git a/crates/bitwarden-json/src/client.rs b/crates/bitwarden-json/src/client.rs index 5cccb456e..0c53064b7 100644 --- a/crates/bitwarden-json/src/client.rs +++ b/crates/bitwarden-json/src/client.rs @@ -62,6 +62,9 @@ impl Client { #[cfg(feature = "secrets")] Command::Secrets(cmd) => match cmd { SecretsCommand::Get(req) => self.0.secrets().get(&req).await.into_string(), + SecretsCommand::GetByIds(req) => { + self.0.secrets().get_by_ids(req).await.into_string() + } SecretsCommand::Create(req) => self.0.secrets().create(&req).await.into_string(), SecretsCommand::List(req) => self.0.secrets().list(&req).await.into_string(), SecretsCommand::Update(req) => self.0.secrets().update(&req).await.into_string(), diff --git a/crates/bitwarden-json/src/command.rs b/crates/bitwarden-json/src/command.rs index a13c571ad..7608df6f0 100644 --- a/crates/bitwarden-json/src/command.rs +++ b/crates/bitwarden-json/src/command.rs @@ -8,7 +8,7 @@ use bitwarden::{ }, secrets::{ SecretCreateRequest, SecretGetRequest, SecretIdentifiersRequest, SecretPutRequest, - SecretsDeleteRequest, + SecretsDeleteRequest, SecretsGetRequest, }, }, }; @@ -97,6 +97,14 @@ pub enum SecretsCommand { /// Get(SecretGetRequest), + /// > Requires Authentication + /// > Requires using an Access Token for login or calling Sync at least once + /// Retrieve secrets by the provided identifiers + /// + /// Returns: [SecretsResponse](bitwarden::secrets_manager::secrets::SecretsResponse) + /// + GetByIds(SecretsGetRequest), + /// > Requires Authentication /// > Requires using an Access Token for login or calling Sync at least once /// Creates a new secret in the provided organization using the given data diff --git a/crates/bitwarden-napi/src-ts/bitwarden_client/index.ts b/crates/bitwarden-napi/src-ts/bitwarden_client/index.ts index 1b8c31f48..9f48fe938 100644 --- a/crates/bitwarden-napi/src-ts/bitwarden_client/index.ts +++ b/crates/bitwarden-napi/src-ts/bitwarden_client/index.ts @@ -8,6 +8,7 @@ import { ResponseForSecretIdentifiersResponse, ResponseForSecretResponse, ResponseForSecretsDeleteResponse, + ResponseForSecretsResponse, } from "./schemas"; export class BitwardenClient { @@ -80,6 +81,18 @@ export class SecretsClient { return Convert.toResponseForSecretResponse(response); } + async getByIds(ids: string[]): Promise { + const response = await this.client.runCommand( + Convert.commandToJson({ + secrets: { + getByIds: { ids }, + }, + }), + ); + + return Convert.toResponseForSecretsResponse(response); + } + async create( key: string, note: string, diff --git a/crates/bitwarden/CHANGELOG.md b/crates/bitwarden/CHANGELOG.md index 51a3dc641..4c99ad091 100644 --- a/crates/bitwarden/CHANGELOG.md +++ b/crates/bitwarden/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `auth::request::AccessTokenLoginRequest` moved to `auth::login::AccessTokenLoginRequest` (#178) +- Support for fetching multiple secrets by ids (#150) + ## [0.3.0] - 2023-07-26 ### Deprecated diff --git a/crates/bitwarden/src/secrets_manager/client_secrets.rs b/crates/bitwarden/src/secrets_manager/client_secrets.rs index 2974e067a..ee85915d4 100644 --- a/crates/bitwarden/src/secrets_manager/client_secrets.rs +++ b/crates/bitwarden/src/secrets_manager/client_secrets.rs @@ -1,10 +1,11 @@ use crate::{ error::Result, secrets_manager::secrets::{ - create_secret, delete_secrets, get_secret, list_secrets, list_secrets_by_project, - update_secret, SecretCreateRequest, SecretGetRequest, SecretIdentifiersByProjectRequest, - SecretIdentifiersRequest, SecretIdentifiersResponse, SecretPutRequest, SecretResponse, - SecretsDeleteRequest, SecretsDeleteResponse, + create_secret, delete_secrets, get_secret, get_secrets_by_ids, list_secrets, + list_secrets_by_project, update_secret, SecretCreateRequest, SecretGetRequest, + SecretIdentifiersByProjectRequest, SecretIdentifiersRequest, SecretIdentifiersResponse, + SecretPutRequest, SecretResponse, SecretsDeleteRequest, SecretsDeleteResponse, + SecretsGetRequest, SecretsResponse, }, Client, }; @@ -18,6 +19,10 @@ impl<'a> ClientSecrets<'a> { get_secret(self.client, input).await } + pub async fn get_by_ids(&mut self, input: SecretsGetRequest) -> Result { + get_secrets_by_ids(self.client, input).await + } + pub async fn create(&mut self, input: &SecretCreateRequest) -> Result { create_secret(self.client, input).await } diff --git a/crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs b/crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs new file mode 100644 index 000000000..032962849 --- /dev/null +++ b/crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs @@ -0,0 +1,30 @@ +use bitwarden_api_api::models::GetSecretsRequestModel; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +use super::SecretsResponse; +use crate::{client::Client, error::Result}; + +#[derive(Serialize, Deserialize, Debug, JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct SecretsGetRequest { + /// IDs of the secrets to retrieve + pub ids: Vec, +} + +pub(crate) async fn get_secrets_by_ids( + client: &mut Client, + input: SecretsGetRequest, +) -> Result { + let request = Some(GetSecretsRequestModel { ids: input.ids }); + + let config = client.get_api_configurations().await; + + let res = + bitwarden_api_api::apis::secrets_api::secrets_get_by_ids_post(&config.api, request).await?; + + let enc = client.get_encryption_settings()?; + + SecretsResponse::process_response(res, enc) +} diff --git a/crates/bitwarden/src/secrets_manager/secrets/mod.rs b/crates/bitwarden/src/secrets_manager/secrets/mod.rs index de628e618..9a367bcb6 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/mod.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/mod.rs @@ -1,6 +1,7 @@ mod create; mod delete; mod get; +mod get_by_ids; mod list; mod secret_response; mod update; @@ -11,10 +12,12 @@ pub(crate) use delete::delete_secrets; pub use delete::{SecretsDeleteRequest, SecretsDeleteResponse}; pub(crate) use get::get_secret; pub use get::SecretGetRequest; +pub(crate) use get_by_ids::get_secrets_by_ids; +pub use get_by_ids::SecretsGetRequest; pub(crate) use list::{list_secrets, list_secrets_by_project}; pub use list::{ SecretIdentifiersByProjectRequest, SecretIdentifiersRequest, SecretIdentifiersResponse, }; -pub use secret_response::SecretResponse; +pub use secret_response::{SecretResponse, SecretsResponse}; pub(crate) use update::update_secret; pub use update::SecretPutRequest; diff --git a/crates/bitwarden/src/secrets_manager/secrets/secret_response.rs b/crates/bitwarden/src/secrets_manager/secrets/secret_response.rs index ddbb52135..635d1e3c0 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/secret_response.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/secret_response.rs @@ -1,4 +1,6 @@ -use bitwarden_api_api::models::SecretResponseModel; +use bitwarden_api_api::models::{ + BaseSecretResponseModel, BaseSecretResponseModelListResponseModel, SecretResponseModel, +}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; @@ -29,6 +31,23 @@ impl SecretResponse { pub(crate) fn process_response( response: SecretResponseModel, enc: &EncryptionSettings, + ) -> Result { + let base = BaseSecretResponseModel { + object: response.object, + id: response.id, + organization_id: response.organization_id, + key: response.key, + value: response.value, + note: response.note, + creation_date: response.creation_date, + revision_date: response.revision_date, + projects: response.projects, + }; + Self::process_base_response(base, enc) + } + pub(crate) fn process_base_response( + response: BaseSecretResponseModel, + enc: &EncryptionSettings, ) -> Result { let org_id = response.organization_id; @@ -67,3 +86,25 @@ impl SecretResponse { }) } } + +#[derive(Serialize, Deserialize, Debug, JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct SecretsResponse { + pub data: Vec, +} + +impl SecretsResponse { + pub(crate) fn process_response( + response: BaseSecretResponseModelListResponseModel, + enc: &EncryptionSettings, + ) -> Result { + Ok(SecretsResponse { + data: response + .data + .unwrap_or_default() + .into_iter() + .map(|r| SecretResponse::process_base_response(r, enc)) + .collect::>()?, + }) + } +} diff --git a/crates/bws/src/main.rs b/crates/bws/src/main.rs index 72c3b2afb..ab0c9afb2 100644 --- a/crates/bws/src/main.rs +++ b/crates/bws/src/main.rs @@ -10,7 +10,7 @@ use bitwarden::{ }, secrets::{ SecretCreateRequest, SecretGetRequest, SecretIdentifiersByProjectRequest, - SecretIdentifiersRequest, SecretPutRequest, SecretsDeleteRequest, + SecretIdentifiersRequest, SecretPutRequest, SecretsDeleteRequest, SecretsGetRequest, }, }, }; @@ -456,12 +456,12 @@ async fn process_commands() -> Result<()> { .await? }; - let mut secrets = Vec::new(); - - for s in res.data { - let secret = client.secrets().get(&SecretGetRequest { id: s.id }).await?; - secrets.push(secret); - } + let secret_ids = res.data.into_iter().map(|e| e.id).collect(); + let secrets = client + .secrets() + .get_by_ids(SecretsGetRequest { ids: secret_ids }) + .await? + .data; serialize_response(secrets, cli.output, color); } diff --git a/crates/sdk-schemas/src/main.rs b/crates/sdk-schemas/src/main.rs index c4f806464..9d7e52a47 100644 --- a/crates/sdk-schemas/src/main.rs +++ b/crates/sdk-schemas/src/main.rs @@ -101,6 +101,7 @@ fn main() -> Result<()> { bitwarden::auth::login::PasswordLoginResponse, bitwarden::secrets_manager::secrets::SecretIdentifiersResponse, bitwarden::secrets_manager::secrets::SecretResponse, + bitwarden::secrets_manager::secrets::SecretsResponse, bitwarden::secrets_manager::secrets::SecretsDeleteResponse, bitwarden::secrets_manager::projects::ProjectResponse, bitwarden::secrets_manager::projects::ProjectsResponse, From 7a0355bf0f1e5ef8319fcdd677123f0d2d33b38b Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 28 Aug 2023 18:11:47 +0200 Subject: [PATCH 03/10] Format imports (#201) --- crates/bitwarden-json/src/client.rs | 5 ++-- crates/bitwarden-json/src/command.rs | 2 -- crates/bitwarden/src/auth/api/request/mod.rs | 3 +-- crates/bitwarden/src/auth/client_auth.rs | 3 +-- crates/bitwarden/src/auth/login/mod.rs | 3 +-- crates/bitwarden/src/auth/login/password.rs | 20 +++++++------- crates/bitwarden/src/auth/login/two_factor.rs | 3 +-- crates/bitwarden/src/client/client.rs | 26 +++++++++---------- .../src/client/encryption_settings.rs | 11 ++++---- crates/bitwarden/src/crypto/aes_opt.rs | 6 +++-- crates/bitwarden/src/crypto/enc_string.rs | 3 +-- crates/bitwarden/src/crypto/mod.rs | 10 +++---- crates/bitwarden/src/mobile/client_crypto.rs | 8 +++--- crates/bitwarden/src/mobile/client_kdf.rs | 4 +-- .../src/mobile/vault/client_ciphers.rs | 3 +-- .../src/mobile/vault/client_collection.rs | 3 +-- .../src/mobile/vault/client_folders.rs | 3 +-- .../mobile/vault/client_password_history.rs | 3 +-- .../src/platform/generate_fingerprint.rs | 3 +-- crates/bitwarden/src/tool/client_generator.rs | 7 +++-- crates/bitwarden/src/vault/cipher/cipher.rs | 11 ++++---- crates/bitwarden/src/vault/cipher/field.rs | 3 +-- 22 files changed, 63 insertions(+), 80 deletions(-) diff --git a/crates/bitwarden-json/src/client.rs b/crates/bitwarden-json/src/client.rs index 0c53064b7..f771a5ce4 100644 --- a/crates/bitwarden-json/src/client.rs +++ b/crates/bitwarden-json/src/client.rs @@ -1,13 +1,12 @@ use bitwarden::client::client_settings::ClientSettings; +#[cfg(feature = "secrets")] +use crate::command::{ProjectsCommand, SecretsCommand}; use crate::{ command::Command, response::{Response, ResponseIntoString}, }; -#[cfg(feature = "secrets")] -use crate::command::{ProjectsCommand, SecretsCommand}; - pub struct Client(bitwarden::Client); impl Client { diff --git a/crates/bitwarden-json/src/command.rs b/crates/bitwarden-json/src/command.rs index 7608df6f0..855a30399 100644 --- a/crates/bitwarden-json/src/command.rs +++ b/crates/bitwarden-json/src/command.rs @@ -12,13 +12,11 @@ use bitwarden::{ }, }, }; - #[cfg(feature = "internal")] use bitwarden::{ auth::login::{ApiKeyLoginRequest, PasswordLoginRequest}, platform::{FingerprintRequest, SecretVerificationRequest, SyncRequest}, }; - use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/crates/bitwarden/src/auth/api/request/mod.rs b/crates/bitwarden/src/auth/api/request/mod.rs index 44d2e8ab6..1277fa969 100644 --- a/crates/bitwarden/src/auth/api/request/mod.rs +++ b/crates/bitwarden/src/auth/api/request/mod.rs @@ -9,13 +9,12 @@ mod renew_token_request; pub(crate) use access_token_request::*; #[cfg(feature = "internal")] pub(crate) use api_token_request::*; +use base64::Engine; #[cfg(feature = "internal")] pub(crate) use password_token_request::*; #[cfg(feature = "internal")] pub(crate) use renew_token_request::*; -use base64::Engine; - use crate::{ auth::api::response::{parse_identity_response, IdentityTokenResponse}, client::ApiConfigurations, diff --git a/crates/bitwarden/src/auth/client_auth.rs b/crates/bitwarden/src/auth/client_auth.rs index ef4215271..086ce2752 100644 --- a/crates/bitwarden/src/auth/client_auth.rs +++ b/crates/bitwarden/src/auth/client_auth.rs @@ -1,6 +1,5 @@ -use crate::Client; - use super::password::{password_strength, satisfies_policy, MasterPasswordPolicyOptions}; +use crate::Client; pub struct ClientAuth<'a> { pub(crate) _client: &'a crate::Client, diff --git a/crates/bitwarden/src/auth/login/mod.rs b/crates/bitwarden/src/auth/login/mod.rs index 28a1aa540..b1ab54ecf 100644 --- a/crates/bitwarden/src/auth/login/mod.rs +++ b/crates/bitwarden/src/auth/login/mod.rs @@ -13,12 +13,11 @@ use { pub mod response; mod password; -pub use password::PasswordLoginResponse; - #[cfg(feature = "internal")] pub(crate) use password::password_login; #[cfg(feature = "internal")] pub use password::PasswordLoginRequest; +pub use password::PasswordLoginResponse; #[cfg(feature = "internal")] mod two_factor; #[cfg(feature = "internal")] diff --git a/crates/bitwarden/src/auth/login/password.rs b/crates/bitwarden/src/auth/login/password.rs index f5e144d19..0101f2ce1 100644 --- a/crates/bitwarden/src/auth/login/password.rs +++ b/crates/bitwarden/src/auth/login/password.rs @@ -1,17 +1,10 @@ +#[cfg(feature = "internal")] +use std::str::FromStr; + #[cfg(feature = "internal")] use log::{debug, info}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -#[cfg(feature = "internal")] -use std::str::FromStr; - -use crate::{ - auth::{ - api::response::IdentityTokenResponse, - login::response::{captcha_response::CaptchaResponse, two_factor::TwoFactorProviders}, - }, - error::Result, -}; #[cfg(feature = "internal")] use crate::{ @@ -23,6 +16,13 @@ use crate::{ crypto::EncString, Client, }; +use crate::{ + auth::{ + api::response::IdentityTokenResponse, + login::response::{captcha_response::CaptchaResponse, two_factor::TwoFactorProviders}, + }, + error::Result, +}; #[cfg(feature = "internal")] pub(crate) async fn password_login( diff --git a/crates/bitwarden/src/auth/login/two_factor.rs b/crates/bitwarden/src/auth/login/two_factor.rs index 7c7fa17de..6b49332e5 100644 --- a/crates/bitwarden/src/auth/login/two_factor.rs +++ b/crates/bitwarden/src/auth/login/two_factor.rs @@ -3,9 +3,8 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; -use crate::{error::Result, Client}; - use super::determine_password_hash; +use crate::{error::Result, Client}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] diff --git a/crates/bitwarden/src/client/client.rs b/crates/bitwarden/src/client/client.rs index b8ecd16a7..357b13aa1 100644 --- a/crates/bitwarden/src/client/client.rs +++ b/crates/bitwarden/src/client/client.rs @@ -2,20 +2,6 @@ use std::time::{Duration, Instant}; use reqwest::header::{self}; use uuid::Uuid; - -use crate::{ - auth::renew::renew_token, - client::{ - client_settings::{ClientSettings, DeviceType}, - encryption_settings::EncryptionSettings, - }, - crypto::SymmetricCryptoKey, - error::{Error, Result}, -}; - -#[cfg(feature = "secrets")] -use crate::auth::login::{access_token_login, AccessTokenLoginRequest, AccessTokenLoginResponse}; - #[cfg(feature = "internal")] use { crate::{ @@ -34,6 +20,18 @@ use { log::debug, }; +#[cfg(feature = "secrets")] +use crate::auth::login::{access_token_login, AccessTokenLoginRequest, AccessTokenLoginResponse}; +use crate::{ + auth::renew::renew_token, + client::{ + client_settings::{ClientSettings, DeviceType}, + encryption_settings::EncryptionSettings, + }, + crypto::SymmetricCryptoKey, + error::{Error, Result}, +}; + #[derive(Debug)] pub(crate) struct ApiConfigurations { pub identity: bitwarden_api_identity::apis::configuration::Configuration, diff --git a/crates/bitwarden/src/client/encryption_settings.rs b/crates/bitwarden/src/client/encryption_settings.rs index d1ff16e05..29fd38b42 100644 --- a/crates/bitwarden/src/client/encryption_settings.rs +++ b/crates/bitwarden/src/client/encryption_settings.rs @@ -2,18 +2,17 @@ use std::collections::HashMap; use rsa::RsaPrivateKey; use uuid::Uuid; - -use crate::{ - crypto::{encrypt_aes256, EncString, SymmetricCryptoKey}, - error::{CryptoError, Result}, -}; - #[cfg(feature = "internal")] use { crate::client::auth_settings::AuthSettings, rsa::{pkcs8::DecodePrivateKey, Oaep}, }; +use crate::{ + crypto::{encrypt_aes256, EncString, SymmetricCryptoKey}, + error::{CryptoError, Result}, +}; + pub struct EncryptionSettings { user_key: SymmetricCryptoKey, private_key: Option, diff --git a/crates/bitwarden/src/crypto/aes_opt.rs b/crates/bitwarden/src/crypto/aes_opt.rs index f950ef18f..109deac4f 100644 --- a/crates/bitwarden/src/crypto/aes_opt.rs +++ b/crates/bitwarden/src/crypto/aes_opt.rs @@ -1,4 +1,3 @@ -use crate::error::{CryptoError, Result}; use aes::cipher::{ block_padding::Pkcs7, generic_array::GenericArray, typenum::U32, BlockDecryptMut, BlockEncryptMut, KeyIvInit, @@ -6,7 +5,10 @@ use aes::cipher::{ use hmac::Mac; use rand::RngCore; -use super::{EncString, PbkdfSha256Hmac, PBKDF_SHA256_HMAC_OUT_SIZE}; +use crate::{ + crypto::{EncString, PbkdfSha256Hmac, PBKDF_SHA256_HMAC_OUT_SIZE}, + error::{CryptoError, Result}, +}; pub fn decrypt_aes256( iv: &[u8; 16], diff --git a/crates/bitwarden/src/crypto/enc_string.rs b/crates/bitwarden/src/crypto/enc_string.rs index c166d59c0..dc5da81b1 100644 --- a/crates/bitwarden/src/crypto/enc_string.rs +++ b/crates/bitwarden/src/crypto/enc_string.rs @@ -6,12 +6,11 @@ use uuid::Uuid; use crate::{ client::encryption_settings::EncryptionSettings, + crypto::{decrypt_aes256, Decryptable, Encryptable, SymmetricCryptoKey}, error::{CryptoError, EncStringParseError, Error, Result}, util::BASE64_ENGINE, }; -use super::{decrypt_aes256, Decryptable, Encryptable, SymmetricCryptoKey}; - #[derive(Clone)] #[allow(unused, non_camel_case_types)] pub enum EncString { diff --git a/crates/bitwarden/src/crypto/mod.rs b/crates/bitwarden/src/crypto/mod.rs index c5ed8d140..c1d1a985d 100644 --- a/crates/bitwarden/src/crypto/mod.rs +++ b/crates/bitwarden/src/crypto/mod.rs @@ -1,11 +1,9 @@ //! Cryptographic primitives used in the SDK -use aes::cipher::{generic_array::GenericArray, typenum::U64, Unsigned}; -use hmac::digest::OutputSizeUser; - #[cfg(feature = "internal")] use aes::cipher::typenum::U32; - +use aes::cipher::{generic_array::GenericArray, typenum::U64, Unsigned}; +use hmac::digest::OutputSizeUser; #[cfg(any(feature = "internal", feature = "mobile"))] use { crate::{client::auth_settings::Kdf, error::Result}, @@ -116,14 +114,14 @@ pub(crate) fn stretch_key(secret: [u8; 16], name: &str, info: Option<&str>) -> S #[cfg(test)] mod tests { - use super::stretch_key; - #[cfg(feature = "internal")] use { crate::{client::auth_settings::Kdf, crypto::stretch_key_password}, std::num::NonZeroU32, }; + use super::stretch_key; + #[test] fn test_key_stretch() { let key = stretch_key(*b"&/$%F1a895g67HlX", "test_key", None); diff --git a/crates/bitwarden/src/mobile/client_crypto.rs b/crates/bitwarden/src/mobile/client_crypto.rs index ffac2d275..67f69d8f1 100644 --- a/crates/bitwarden/src/mobile/client_crypto.rs +++ b/crates/bitwarden/src/mobile/client_crypto.rs @@ -1,9 +1,9 @@ -#[cfg(feature = "internal")] -use crate::error::Result; use crate::Client; - #[cfg(feature = "internal")] -use super::crypto::{initialize_crypto, InitCryptoRequest}; +use crate::{ + error::Result, + mobile::crypto::{initialize_crypto, InitCryptoRequest}, +}; pub struct ClientCrypto<'a> { pub(crate) client: &'a mut crate::Client, diff --git a/crates/bitwarden/src/mobile/client_kdf.rs b/crates/bitwarden/src/mobile/client_kdf.rs index 236a4655c..92d226b59 100644 --- a/crates/bitwarden/src/mobile/client_kdf.rs +++ b/crates/bitwarden/src/mobile/client_kdf.rs @@ -1,6 +1,4 @@ -use crate::{client::auth_settings::Kdf, error::Result, Client}; - -use super::kdf::hash_password; +use crate::{client::auth_settings::Kdf, error::Result, mobile::kdf::hash_password, Client}; pub struct ClientKdf<'a> { pub(crate) client: &'a crate::Client, diff --git a/crates/bitwarden/src/mobile/vault/client_ciphers.rs b/crates/bitwarden/src/mobile/vault/client_ciphers.rs index 9fdaec5d0..87b77cfd5 100644 --- a/crates/bitwarden/src/mobile/vault/client_ciphers.rs +++ b/crates/bitwarden/src/mobile/vault/client_ciphers.rs @@ -1,3 +1,4 @@ +use super::client_vault::ClientVault; use crate::{ crypto::{Decryptable, Encryptable}, error::Result, @@ -5,8 +6,6 @@ use crate::{ Client, }; -use super::client_vault::ClientVault; - pub struct ClientCiphers<'a> { pub(crate) client: &'a Client, } diff --git a/crates/bitwarden/src/mobile/vault/client_collection.rs b/crates/bitwarden/src/mobile/vault/client_collection.rs index c10bf259a..80535406c 100644 --- a/crates/bitwarden/src/mobile/vault/client_collection.rs +++ b/crates/bitwarden/src/mobile/vault/client_collection.rs @@ -1,3 +1,4 @@ +use super::client_vault::ClientVault; use crate::{ crypto::Decryptable, error::Result, @@ -5,8 +6,6 @@ use crate::{ Client, }; -use super::client_vault::ClientVault; - pub struct ClientCollections<'a> { pub(crate) client: &'a Client, } diff --git a/crates/bitwarden/src/mobile/vault/client_folders.rs b/crates/bitwarden/src/mobile/vault/client_folders.rs index dfe5961d6..b6f6a72f4 100644 --- a/crates/bitwarden/src/mobile/vault/client_folders.rs +++ b/crates/bitwarden/src/mobile/vault/client_folders.rs @@ -1,3 +1,4 @@ +use super::client_vault::ClientVault; use crate::{ crypto::{Decryptable, Encryptable}, error::Result, @@ -5,8 +6,6 @@ use crate::{ Client, }; -use super::client_vault::ClientVault; - pub struct ClientFolders<'a> { pub(crate) client: &'a Client, } diff --git a/crates/bitwarden/src/mobile/vault/client_password_history.rs b/crates/bitwarden/src/mobile/vault/client_password_history.rs index df4ed50d2..d873f8dfc 100644 --- a/crates/bitwarden/src/mobile/vault/client_password_history.rs +++ b/crates/bitwarden/src/mobile/vault/client_password_history.rs @@ -1,3 +1,4 @@ +use super::client_vault::ClientVault; use crate::{ crypto::{Decryptable, Encryptable}, error::Result, @@ -5,8 +6,6 @@ use crate::{ Client, }; -use super::client_vault::ClientVault; - pub struct ClientPasswordHistory<'a> { pub(crate) client: &'a Client, } diff --git a/crates/bitwarden/src/platform/generate_fingerprint.rs b/crates/bitwarden/src/platform/generate_fingerprint.rs index 60c5eb6ac..800d6e847 100644 --- a/crates/bitwarden/src/platform/generate_fingerprint.rs +++ b/crates/bitwarden/src/platform/generate_fingerprint.rs @@ -3,8 +3,7 @@ use log::{debug, info}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::util::BASE64_ENGINE; -use crate::{crypto::fingerprint, error::Result}; +use crate::{crypto::fingerprint, error::Result, util::BASE64_ENGINE}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] diff --git a/crates/bitwarden/src/tool/client_generator.rs b/crates/bitwarden/src/tool/client_generator.rs index 24cab1741..55d1acbba 100644 --- a/crates/bitwarden/src/tool/client_generator.rs +++ b/crates/bitwarden/src/tool/client_generator.rs @@ -1,5 +1,8 @@ -use super::password::{PassphraseGeneratorRequest, PasswordGeneratorRequest}; -use crate::{error::Result, Client}; +use crate::{ + error::Result, + tool::password::{PassphraseGeneratorRequest, PasswordGeneratorRequest}, + Client, +}; pub struct ClientGenerator<'a> { pub(crate) _client: &'a crate::Client, diff --git a/crates/bitwarden/src/vault/cipher/cipher.rs b/crates/bitwarden/src/vault/cipher/cipher.rs index 6efbba544..c32f39c30 100644 --- a/crates/bitwarden/src/vault/cipher/cipher.rs +++ b/crates/bitwarden/src/vault/cipher/cipher.rs @@ -4,6 +4,11 @@ use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use uuid::Uuid; +use super::{ + attachment, card, field, identity, + local_data::{LocalData, LocalDataView}, + login, secure_note, +}; use crate::{ client::encryption_settings::EncryptionSettings, crypto::{Decryptable, EncString, Encryptable}, @@ -11,12 +16,6 @@ use crate::{ vault::password_history, }; -use super::{ - attachment, card, field, identity, - local_data::{LocalData, LocalDataView}, - login, secure_note, -}; - #[derive(Clone, Copy, Serialize_repr, Deserialize_repr, Debug, JsonSchema)] #[repr(u8)] #[cfg_attr(feature = "mobile", derive(uniffi::Enum))] diff --git a/crates/bitwarden/src/vault/cipher/field.rs b/crates/bitwarden/src/vault/cipher/field.rs index f8aa41c46..df492eac6 100644 --- a/crates/bitwarden/src/vault/cipher/field.rs +++ b/crates/bitwarden/src/vault/cipher/field.rs @@ -3,14 +3,13 @@ use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use uuid::Uuid; +use super::linked_id::LinkedIdType; use crate::{ client::encryption_settings::EncryptionSettings, crypto::{Decryptable, EncString, Encryptable}, error::Result, }; -use super::linked_id::LinkedIdType; - #[derive(Clone, Copy, Serialize_repr, Deserialize_repr, Debug, JsonSchema)] #[repr(u8)] #[cfg_attr(feature = "mobile", derive(uniffi::Enum))] From e0dfafbcdd4795d2fa4dca5449d9607f3311581c Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 28 Aug 2023 18:12:47 +0200 Subject: [PATCH 04/10] Add x86_64-apple-ios (#196) * Add x86_64-apple-ios * Build a universal binary since it's required --- languages/swift/README.md | 2 ++ languages/swift/build.sh | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/languages/swift/README.md b/languages/swift/README.md index fba455aac..09e618666 100644 --- a/languages/swift/README.md +++ b/languages/swift/README.md @@ -4,6 +4,8 @@ Ensure the necessary targets are installed. ```bash rustup target install aarch64-apple-ios-sim +rustup target install aarch64-apple-ios +rustup target install x86_64-apple-ios ``` ## Build diff --git a/languages/swift/build.sh b/languages/swift/build.sh index 7ec2274d6..655a49ebf 100755 --- a/languages/swift/build.sh +++ b/languages/swift/build.sh @@ -5,10 +5,17 @@ rm -r BitwardenFFI.xcframework rm -r tmp mkdir tmp +mkdir -p tmp/target/universal-ios-sim/release # Build native library cargo build --package bitwarden-uniffi --target aarch64-apple-ios-sim --release cargo build --package bitwarden-uniffi --target aarch64-apple-ios --release +cargo build --package bitwarden-uniffi --target x86_64-apple-ios --release + +# Create universal libraries +lipo -create ../../target/aarch64-apple-ios-sim/release/libbitwarden_uniffi.dylib \ + ../../target/x86_64-apple-ios/release/libbitwarden_uniffi.dylib \ + -output ./tmp/target/universal-ios-sim/release/libbitwarden_uniffi.dylib # Generate swift bindings cargo run -p uniffi-bindgen generate \ @@ -30,10 +37,10 @@ cat ./tmp/bindings/BitwardenFFI.modulemap ./tmp/bindings/BitwardenCoreFFI.module # Build xcframework xcodebuild -create-xcframework \ - -library ../../target/aarch64-apple-ios-sim/release/libbitwarden_uniffi.dylib \ - -headers ./tmp/Headers \ -library ../../target/aarch64-apple-ios/release/libbitwarden_uniffi.dylib \ -headers ./tmp/Headers \ + -library ./tmp/target/universal-ios-sim/release/libbitwarden_uniffi.dylib \ + -headers ./tmp/Headers \ -output ./BitwardenFFI.xcframework # Cleanup temporary files From f770623f599a2fe316a92a7b6c9098633f5dc5af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Mon, 28 Aug 2023 18:54:56 +0200 Subject: [PATCH 05/10] Decrypt list of Sends (#202) --- .../src/mobile/vault/client_sends.rs | 10 ++++- crates/bitwarden/src/vault/mod.rs | 2 +- crates/bitwarden/src/vault/send.rs | 42 +++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/crates/bitwarden/src/mobile/vault/client_sends.rs b/crates/bitwarden/src/mobile/vault/client_sends.rs index 824ece905..62410e168 100644 --- a/crates/bitwarden/src/mobile/vault/client_sends.rs +++ b/crates/bitwarden/src/mobile/vault/client_sends.rs @@ -4,7 +4,7 @@ use crate::{ client::encryption_settings::EncryptionSettings, crypto::{Decryptable, EncString}, error::Result, - vault::{Send, SendView}, + vault::{Send, SendListView, SendView}, Client, }; @@ -23,6 +23,14 @@ impl<'a> ClientSends<'a> { Ok(send_view) } + pub async fn decrypt_list(&self, sends: Vec) -> Result> { + let enc = self.client.get_encryption_settings()?; + + let send_views = sends.decrypt(enc, &None)?; + + Ok(send_views) + } + pub async fn decrypt_file( &self, send: Send, diff --git a/crates/bitwarden/src/vault/mod.rs b/crates/bitwarden/src/vault/mod.rs index bcbdd8dcd..9eecd6620 100644 --- a/crates/bitwarden/src/vault/mod.rs +++ b/crates/bitwarden/src/vault/mod.rs @@ -8,4 +8,4 @@ pub use cipher::{Cipher, CipherListView, CipherView}; pub use collection::{Collection, CollectionView}; pub use folder::{Folder, FolderView}; pub use password_history::{PasswordHistory, PasswordHistoryView}; -pub use send::{Send, SendView}; +pub use send::{Send, SendListView, SendView}; diff --git a/crates/bitwarden/src/vault/send.rs b/crates/bitwarden/src/vault/send.rs index e049c79a4..df22a16a8 100644 --- a/crates/bitwarden/src/vault/send.rs +++ b/crates/bitwarden/src/vault/send.rs @@ -108,6 +108,23 @@ pub struct SendView { pub expiration_date: Option>, } +#[derive(Serialize, Deserialize, Debug, JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[cfg_attr(feature = "mobile", derive(uniffi::Record))] +pub struct SendListView { + pub id: Uuid, + pub access_id: String, + + pub name: String, + + pub r#type: SendType, + pub disabled: bool, + + pub revision_date: DateTime, + pub deletion_date: DateTime, + pub expiration_date: Option>, +} + impl Send { pub(crate) fn get_key( key: &EncString, @@ -174,6 +191,31 @@ impl Decryptable for Send { } } +impl Decryptable for Send { + fn decrypt(&self, enc: &EncryptionSettings, org_id: &Option) -> Result { + // For sends, we first decrypt the send key with the user key, and stretch it to it's full size + let key = Send::get_key(&self.key, enc, org_id)?; + let enc_owned = EncryptionSettings::new_single_key(key); + + // For the rest of the fields, we ignore the provided EncryptionSettings and use a new one with the stretched key + let enc = &enc_owned; + + Ok(SendListView { + id: self.id, + access_id: self.access_id.clone(), + + name: self.name.decrypt(enc, org_id)?, + r#type: self.r#type, + + disabled: self.disabled, + + revision_date: self.revision_date, + deletion_date: self.deletion_date, + expiration_date: self.expiration_date, + }) + } +} + #[cfg(test)] mod tests { use crate::client::{ From f22db8744fa924d1cb0c1a0cb8b4ef68a6d9fa28 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 29 Aug 2023 22:23:02 +0200 Subject: [PATCH 06/10] Make helper method for hkdf_expand (#210) --- crates/bitwarden/src/crypto/mod.rs | 38 ++++++++++++++---------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/crates/bitwarden/src/crypto/mod.rs b/crates/bitwarden/src/crypto/mod.rs index c1d1a985d..5d5223c08 100644 --- a/crates/bitwarden/src/crypto/mod.rs +++ b/crates/bitwarden/src/crypto/mod.rs @@ -2,13 +2,12 @@ #[cfg(feature = "internal")] use aes::cipher::typenum::U32; -use aes::cipher::{generic_array::GenericArray, typenum::U64, Unsigned}; +use aes::cipher::{generic_array::GenericArray, typenum::U64, ArrayLength, Unsigned}; use hmac::digest::OutputSizeUser; #[cfg(any(feature = "internal", feature = "mobile"))] -use { - crate::{client::auth_settings::Kdf, error::Result}, - sha2::Digest, -}; +use {crate::client::auth_settings::Kdf, sha2::Digest}; + +use crate::error::{Error, Result}; mod enc_string; pub use enc_string::EncString; @@ -76,15 +75,8 @@ pub(crate) fn stretch_key_password( ) -> Result<(GenericArray, GenericArray)> { let master_key: [u8; 32] = hash_kdf(secret, salt, kdf)?; - let hkdf = hkdf::Hkdf::::from_prk(&master_key) - .expect("Input is a valid fixed size hash"); - - let mut key = GenericArray::::default(); - hkdf.expand("enc".as_bytes(), &mut key) - .expect("key is a valid fixed size buffer"); - let mut mac_key = GenericArray::::default(); - hkdf.expand("mac".as_bytes(), &mut mac_key) - .expect("mac_key is a valid fixed size buffer"); + let key: GenericArray = hkdf_expand(&master_key, Some("enc"))?; + let mac_key: GenericArray = hkdf_expand(&master_key, Some("mac"))?; Ok((key, mac_key)) } @@ -100,16 +92,22 @@ pub(crate) fn stretch_key(secret: [u8; 16], name: &str, info: Option<&str>) -> S .finalize() .into_bytes(); - let hkdf = hkdf::Hkdf::::from_prk(&res).unwrap(); + let key: GenericArray = hkdf_expand(&res, info).unwrap(); + + SymmetricCryptoKey::try_from(key.as_slice()).unwrap() +} - let mut key = GenericArray::::default(); +/// RFC5869 HKDF-Expand operation +fn hkdf_expand>(prk: &[u8], info: Option<&str>) -> Result> { + let hkdf = hkdf::Hkdf::::from_prk(prk) + .map_err(|_| Error::Internal("invalid prk length"))?; + let mut key = GenericArray::::default(); - // TODO: Should we have a default value for info? - // Should it be required? let i = info.map(|i| i.as_bytes()).unwrap_or(&[]); - hkdf.expand(i, &mut key).unwrap(); + hkdf.expand(i, &mut key) + .map_err(|_| Error::Internal("invalid length"))?; - SymmetricCryptoKey::try_from(key.as_slice()).unwrap() + Ok(key) } #[cfg(test)] From 7b4bd934cd138022ef214a9c1de8fbad2fadb607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Wed, 30 Aug 2023 11:38:49 +0200 Subject: [PATCH 07/10] Lock generated API crates to the specified version (#208) --- crates/bitwarden/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bitwarden/Cargo.toml b/crates/bitwarden/Cargo.toml index 337535ab3..345b1f9cb 100644 --- a/crates/bitwarden/Cargo.toml +++ b/crates/bitwarden/Cargo.toml @@ -55,8 +55,8 @@ uniffi = { version = "=0.24.1", optional = true } # We don't use this directly (it's used by rand), but we need it here to enable WASM support getrandom = { version = ">=0.2.9", features = ["js"] } -bitwarden-api-identity = { path = "../bitwarden-api-identity", version = "0.2.1" } -bitwarden-api-api = { path = "../bitwarden-api-api", version = "0.2.1" } +bitwarden-api-identity = { path = "../bitwarden-api-identity", version = "=0.2.1" } +bitwarden-api-api = { path = "../bitwarden-api-api", version = "=0.2.1" } [dev-dependencies] tokio = { version = "1.28.2", features = ["rt", "macros"] } From b7a7b81f320a1b80f52d286609c5e5fde2bec888 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 31 Aug 2023 14:07:13 +0200 Subject: [PATCH 08/10] Move crypto/mod.rs to separate files (#205) --- .../src/crypto/{aes_opt.rs => aes_ops.rs} | 0 crates/bitwarden/src/crypto/master_key.rs | 128 ++++++++++++++ crates/bitwarden/src/crypto/mod.rs | 165 ++---------------- crates/bitwarden/src/crypto/shareable_key.rs | 33 ++++ 4 files changed, 171 insertions(+), 155 deletions(-) rename crates/bitwarden/src/crypto/{aes_opt.rs => aes_ops.rs} (100%) create mode 100644 crates/bitwarden/src/crypto/master_key.rs create mode 100644 crates/bitwarden/src/crypto/shareable_key.rs diff --git a/crates/bitwarden/src/crypto/aes_opt.rs b/crates/bitwarden/src/crypto/aes_ops.rs similarity index 100% rename from crates/bitwarden/src/crypto/aes_opt.rs rename to crates/bitwarden/src/crypto/aes_ops.rs diff --git a/crates/bitwarden/src/crypto/master_key.rs b/crates/bitwarden/src/crypto/master_key.rs new file mode 100644 index 000000000..f2df690f9 --- /dev/null +++ b/crates/bitwarden/src/crypto/master_key.rs @@ -0,0 +1,128 @@ +use aes::cipher::typenum::U32; + +use super::hkdf_expand; +use { + crate::{client::auth_settings::Kdf, error::Result}, + aes::cipher::generic_array::GenericArray, + sha2::Digest, +}; + +pub(crate) fn hash_kdf(secret: &[u8], salt: &[u8], kdf: &Kdf) -> Result<[u8; 32]> { + use crate::crypto::PBKDF_SHA256_HMAC_OUT_SIZE; + + use super::PbkdfSha256Hmac; + + let hash = match kdf { + Kdf::PBKDF2 { iterations } => pbkdf2::pbkdf2_array::< + PbkdfSha256Hmac, + PBKDF_SHA256_HMAC_OUT_SIZE, + >(secret, salt, iterations.get()) + .unwrap(), + + Kdf::Argon2id { + iterations, + memory, + parallelism, + } => { + use argon2::*; + + let argon = Argon2::new( + Algorithm::Argon2id, + Version::V0x13, + Params::new( + memory.get() * 1024, // Convert MiB to KiB + iterations.get(), + parallelism.get(), + Some(32), + ) + .unwrap(), + ); + + let salt_sha = sha2::Sha256::new().chain_update(salt).finalize(); + + let mut hash = [0u8; 32]; + argon + .hash_password_into(secret, &salt_sha, &mut hash) + .unwrap(); + hash + } + }; + Ok(hash) +} + +pub(crate) fn stretch_key_password( + secret: &[u8], + salt: &[u8], + kdf: &Kdf, +) -> Result<(GenericArray, GenericArray)> { + let master_key: [u8; 32] = hash_kdf(secret, salt, kdf)?; + + let key: GenericArray = hkdf_expand(&master_key, Some("enc"))?; + let mac_key: GenericArray = hkdf_expand(&master_key, Some("mac"))?; + + Ok((key, mac_key)) +} + +#[cfg(test)] +mod tests { + use { + crate::{client::auth_settings::Kdf, crypto::stretch_key_password}, + std::num::NonZeroU32, + }; + + #[test] + fn test_key_stretch_password_pbkdf2() { + let (key, mac) = stretch_key_password( + &b"67t9b5g67$%Dh89n"[..], + "test_key".as_bytes(), + &Kdf::PBKDF2 { + iterations: NonZeroU32::new(10000).unwrap(), + }, + ) + .unwrap(); + + assert_eq!( + key.as_slice(), + [ + 111, 31, 178, 45, 238, 152, 37, 114, 143, 215, 124, 83, 135, 173, 195, 23, 142, + 134, 120, 249, 61, 132, 163, 182, 113, 197, 189, 204, 188, 21, 237, 96 + ] + ); + assert_eq!( + mac.as_slice(), + [ + 221, 127, 206, 234, 101, 27, 202, 38, 86, 52, 34, 28, 78, 28, 185, 16, 48, 61, 127, + 166, 209, 247, 194, 87, 232, 26, 48, 85, 193, 249, 179, 155 + ] + ); + } + + #[test] + fn test_key_stretch_password_argon2() { + let (key, mac) = stretch_key_password( + &b"67t9b5g67$%Dh89n"[..], + "test_key".as_bytes(), + &Kdf::Argon2id { + iterations: NonZeroU32::new(4).unwrap(), + memory: NonZeroU32::new(32).unwrap(), + parallelism: NonZeroU32::new(2).unwrap(), + }, + ) + .unwrap(); + + assert_eq!( + key.as_slice(), + [ + 236, 253, 166, 121, 207, 124, 98, 149, 42, 141, 97, 226, 207, 71, 173, 60, 10, 0, + 184, 255, 252, 87, 62, 32, 188, 166, 173, 223, 146, 159, 222, 219 + ] + ); + assert_eq!( + mac.as_slice(), + [ + 214, 144, 76, 173, 225, 106, 132, 131, 173, 56, 134, 241, 223, 227, 165, 161, 146, + 37, 111, 206, 155, 24, 224, 151, 134, 189, 202, 0, 27, 149, 131, 21 + ] + ); + } +} diff --git a/crates/bitwarden/src/crypto/mod.rs b/crates/bitwarden/src/crypto/mod.rs index 5d5223c08..582937bf3 100644 --- a/crates/bitwarden/src/crypto/mod.rs +++ b/crates/bitwarden/src/crypto/mod.rs @@ -1,11 +1,7 @@ //! Cryptographic primitives used in the SDK -#[cfg(feature = "internal")] -use aes::cipher::typenum::U32; -use aes::cipher::{generic_array::GenericArray, typenum::U64, ArrayLength, Unsigned}; +use aes::cipher::{generic_array::GenericArray, ArrayLength, Unsigned}; use hmac::digest::OutputSizeUser; -#[cfg(any(feature = "internal", feature = "mobile"))] -use {crate::client::auth_settings::Kdf, sha2::Digest}; use crate::error::{Error, Result}; @@ -13,10 +9,17 @@ mod enc_string; pub use enc_string::EncString; mod encryptable; pub use encryptable::{Decryptable, Encryptable}; -mod aes_opt; -pub use aes_opt::{decrypt_aes256, encrypt_aes256}; +mod aes_ops; +pub use aes_ops::{decrypt_aes256, encrypt_aes256}; mod symmetric_crypto_key; pub use symmetric_crypto_key::SymmetricCryptoKey; +mod shareable_key; +pub(crate) use shareable_key::stretch_key; + +#[cfg(feature = "internal")] +mod master_key; +#[cfg(feature = "internal")] +pub(crate) use master_key::{hash_kdf, stretch_key_password}; #[cfg(feature = "internal")] mod fingerprint; @@ -27,76 +30,6 @@ pub(crate) type PbkdfSha256Hmac = hmac::Hmac; pub(crate) const PBKDF_SHA256_HMAC_OUT_SIZE: usize = <::OutputSize as Unsigned>::USIZE; -#[cfg(any(feature = "internal", feature = "mobile"))] -pub(crate) fn hash_kdf(secret: &[u8], salt: &[u8], kdf: &Kdf) -> Result<[u8; 32]> { - let hash = match kdf { - Kdf::PBKDF2 { iterations } => pbkdf2::pbkdf2_array::< - PbkdfSha256Hmac, - PBKDF_SHA256_HMAC_OUT_SIZE, - >(secret, salt, iterations.get()) - .unwrap(), - - Kdf::Argon2id { - iterations, - memory, - parallelism, - } => { - use argon2::*; - - let argon = Argon2::new( - Algorithm::Argon2id, - Version::V0x13, - Params::new( - memory.get() * 1024, // Convert MiB to KiB - iterations.get(), - parallelism.get(), - Some(32), - ) - .unwrap(), - ); - - let salt_sha = sha2::Sha256::new().chain_update(salt).finalize(); - - let mut hash = [0u8; 32]; - argon - .hash_password_into(secret, &salt_sha, &mut hash) - .unwrap(); - hash - } - }; - Ok(hash) -} - -#[cfg(feature = "internal")] -pub(crate) fn stretch_key_password( - secret: &[u8], - salt: &[u8], - kdf: &Kdf, -) -> Result<(GenericArray, GenericArray)> { - let master_key: [u8; 32] = hash_kdf(secret, salt, kdf)?; - - let key: GenericArray = hkdf_expand(&master_key, Some("enc"))?; - let mac_key: GenericArray = hkdf_expand(&master_key, Some("mac"))?; - - Ok((key, mac_key)) -} - -pub(crate) fn stretch_key(secret: [u8; 16], name: &str, info: Option<&str>) -> SymmetricCryptoKey { - use hmac::{Hmac, Mac}; - // Because all inputs are fixed size, we can unwrap all errors here without issue - - // TODO: Are these the final `key` and `info` parameters or should we change them? I followed the pattern used for sends - let res = Hmac::::new_from_slice(format!("bitwarden-{}", name).as_bytes()) - .unwrap() - .chain_update(secret) - .finalize() - .into_bytes(); - - let key: GenericArray = hkdf_expand(&res, info).unwrap(); - - SymmetricCryptoKey::try_from(key.as_slice()).unwrap() -} - /// RFC5869 HKDF-Expand operation fn hkdf_expand>(prk: &[u8], info: Option<&str>) -> Result> { let hkdf = hkdf::Hkdf::::from_prk(prk) @@ -109,81 +42,3 @@ fn hkdf_expand>(prk: &[u8], info: Option<&str>) -> Result) -> SymmetricCryptoKey { + use hmac::{Hmac, Mac}; + // Because all inputs are fixed size, we can unwrap all errors here without issue + + // TODO: Are these the final `key` and `info` parameters or should we change them? I followed the pattern used for sends + let res = Hmac::::new_from_slice(format!("bitwarden-{}", name).as_bytes()) + .unwrap() + .chain_update(secret) + .finalize() + .into_bytes(); + + let key: GenericArray = hkdf_expand(&res, info).unwrap(); + + SymmetricCryptoKey::try_from(key.as_slice()).unwrap() +} + +#[cfg(test)] +mod tests { + use super::stretch_key; + + #[test] + fn test_key_stretch() { + let key = stretch_key(*b"&/$%F1a895g67HlX", "test_key", None); + assert_eq!(key.to_base64(), "4PV6+PcmF2w7YHRatvyMcVQtI7zvCyssv/wFWmzjiH6Iv9altjmDkuBD1aagLVaLezbthbSe+ktR+U6qswxNnQ=="); + + let key = stretch_key(*b"67t9b5g67$%Dh89n", "test_key", Some("test")); + assert_eq!(key.to_base64(), "F9jVQmrACGx9VUPjuzfMYDjr726JtL300Y3Yg+VYUnVQtQ1s8oImJ5xtp1KALC9h2nav04++1LDW4iFD+infng=="); + } +} From e10753b721c0bd79fe1a5b39c9d76d07f4cfd73a Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 31 Aug 2023 17:09:27 +0200 Subject: [PATCH 09/10] Rename stretch_key to derive_shareable_key (#206) --- crates/bitwarden/src/client/access_token.rs | 8 +++++-- crates/bitwarden/src/crypto/mod.rs | 22 +++++++++++++++++-- crates/bitwarden/src/crypto/shareable_key.rs | 20 ++++++++++++----- .../src/crypto/symmetric_crypto_key.rs | 3 ++- crates/bitwarden/src/vault/send.rs | 7 +++--- 5 files changed, 45 insertions(+), 15 deletions(-) diff --git a/crates/bitwarden/src/client/access_token.rs b/crates/bitwarden/src/client/access_token.rs index 3fdea7f1d..b68d78572 100644 --- a/crates/bitwarden/src/client/access_token.rs +++ b/crates/bitwarden/src/client/access_token.rs @@ -3,7 +3,11 @@ use std::str::FromStr; use base64::Engine; use uuid::Uuid; -use crate::{crypto::SymmetricCryptoKey, error::AccessTokenInvalidError, util::BASE64_ENGINE}; +use crate::{ + crypto::{derive_shareable_key, SymmetricCryptoKey}, + error::AccessTokenInvalidError, + util::BASE64_ENGINE, +}; pub struct AccessToken { pub service_account_id: Uuid, @@ -42,7 +46,7 @@ impl FromStr for AccessToken { } })?; let encryption_key = - crate::crypto::stretch_key(encryption_key, "accesstoken", Some("sm-access-token")); + derive_shareable_key(encryption_key, "accesstoken", Some("sm-access-token")); Ok(AccessToken { service_account_id, diff --git a/crates/bitwarden/src/crypto/mod.rs b/crates/bitwarden/src/crypto/mod.rs index 582937bf3..1172c9dfb 100644 --- a/crates/bitwarden/src/crypto/mod.rs +++ b/crates/bitwarden/src/crypto/mod.rs @@ -1,4 +1,22 @@ -//! Cryptographic primitives used in the SDK +//! # Cryptographic primitives +//! +//! This module contains the cryptographic primitives used throughout the SDK. The module makes a +//! best effort to abstract away cryptographic concepts into concepts such as +//! [`EncString`][EncString] and [`SymmetricCryptoKey`][SymmetricCryptoKey]. +//! +//! ## Conventions: +//! +//! - Pure Functions that deterministically "derive" keys from input are prefixed with `derive_`. +//! +//! ## Differences from [`clients`](https://github.com/bitwarden/clients) +//! +//! There are some noteworthy differences compared to the other Bitwarden clients. These changes +//! are made in an effort to introduce conventions in how we name things, improve best practices +//! and abstracting away internal complexity. +//! +//! - `CryptoService.makeSendKey` & `AccessService.createAccessToken` are replaced by the generic +//! `derive_shareable_key` +//! use aes::cipher::{generic_array::GenericArray, ArrayLength, Unsigned}; use hmac::digest::OutputSizeUser; @@ -14,7 +32,7 @@ pub use aes_ops::{decrypt_aes256, encrypt_aes256}; mod symmetric_crypto_key; pub use symmetric_crypto_key::SymmetricCryptoKey; mod shareable_key; -pub(crate) use shareable_key::stretch_key; +pub(crate) use shareable_key::derive_shareable_key; #[cfg(feature = "internal")] mod master_key; diff --git a/crates/bitwarden/src/crypto/shareable_key.rs b/crates/bitwarden/src/crypto/shareable_key.rs index fce5da3b0..4127b0712 100644 --- a/crates/bitwarden/src/crypto/shareable_key.rs +++ b/crates/bitwarden/src/crypto/shareable_key.rs @@ -1,9 +1,17 @@ use aes::cipher::{generic_array::GenericArray, typenum::U64}; +use hmac::{Hmac, Mac}; use crate::crypto::{hkdf_expand, SymmetricCryptoKey}; -pub(crate) fn stretch_key(secret: [u8; 16], name: &str, info: Option<&str>) -> SymmetricCryptoKey { - use hmac::{Hmac, Mac}; +/// Derive a shareable key using hkdf from secret and name. +/// +/// A specialized variant of this function was called `CryptoService.makeSendKey` in the Bitwarden +/// `clients` repository. +pub(crate) fn derive_shareable_key( + secret: [u8; 16], + name: &str, + info: Option<&str>, +) -> SymmetricCryptoKey { // Because all inputs are fixed size, we can unwrap all errors here without issue // TODO: Are these the final `key` and `info` parameters or should we change them? I followed the pattern used for sends @@ -20,14 +28,14 @@ pub(crate) fn stretch_key(secret: [u8; 16], name: &str, info: Option<&str>) -> S #[cfg(test)] mod tests { - use super::stretch_key; + use super::derive_shareable_key; #[test] - fn test_key_stretch() { - let key = stretch_key(*b"&/$%F1a895g67HlX", "test_key", None); + fn test_derive_shareable_key() { + let key = derive_shareable_key(*b"&/$%F1a895g67HlX", "test_key", None); assert_eq!(key.to_base64(), "4PV6+PcmF2w7YHRatvyMcVQtI7zvCyssv/wFWmzjiH6Iv9altjmDkuBD1aagLVaLezbthbSe+ktR+U6qswxNnQ=="); - let key = stretch_key(*b"67t9b5g67$%Dh89n", "test_key", Some("test")); + let key = derive_shareable_key(*b"67t9b5g67$%Dh89n", "test_key", Some("test")); assert_eq!(key.to_base64(), "F9jVQmrACGx9VUPjuzfMYDjr726JtL300Y3Yg+VYUnVQtQ1s8oImJ5xtp1KALC9h2nav04++1LDW4iFD+infng=="); } } diff --git a/crates/bitwarden/src/crypto/symmetric_crypto_key.rs b/crates/bitwarden/src/crypto/symmetric_crypto_key.rs index 75e79918f..4d0f573d9 100644 --- a/crates/bitwarden/src/crypto/symmetric_crypto_key.rs +++ b/crates/bitwarden/src/crypto/symmetric_crypto_key.rs @@ -4,6 +4,7 @@ use aes::cipher::{generic_array::GenericArray, typenum::U32}; use base64::Engine; use crate::{ + crypto::derive_shareable_key, error::{CryptoError, Error}, util::BASE64_ENGINE, }; @@ -20,7 +21,7 @@ impl SymmetricCryptoKey { pub fn generate(name: &str) -> Self { use rand::Rng; let secret: [u8; 16] = rand::thread_rng().gen(); - crate::crypto::stretch_key(secret, name, None) + derive_shareable_key(secret, name, None) } pub fn to_base64(&self) -> String { diff --git a/crates/bitwarden/src/vault/send.rs b/crates/bitwarden/src/vault/send.rs index df22a16a8..a8d7872fe 100644 --- a/crates/bitwarden/src/vault/send.rs +++ b/crates/bitwarden/src/vault/send.rs @@ -6,7 +6,7 @@ use uuid::Uuid; use crate::{ client::encryption_settings::EncryptionSettings, - crypto::{stretch_key, Decryptable, EncString, SymmetricCryptoKey}, + crypto::{derive_shareable_key, Decryptable, EncString, SymmetricCryptoKey}, error::Result, }; @@ -132,7 +132,7 @@ impl Send { org_id: &Option, ) -> Result { let key: Vec = enc.decrypt_bytes(key, org_id)?; - let key = stretch_key(key.try_into().unwrap(), "send", Some("send")); + let key = derive_shareable_key(key.try_into().unwrap(), "send", Some("send")); Ok(key) } } @@ -218,13 +218,12 @@ impl Decryptable for Send { #[cfg(test)] mod tests { + use super::Send; use crate::client::{ auth_settings::{AuthSettings, Kdf}, encryption_settings::EncryptionSettings, }; - use super::Send; - #[test] fn test_get_send_key() { // Initialize user encryption with some test data From 265588cb5a29bc71709fd6129e30ce98c030b55f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Fri, 1 Sep 2023 14:33:20 +0200 Subject: [PATCH 10/10] [PM-3138] Send encryption (#211) * Send encryption * Add tests * Create get_encryption helper * Reduce visibility of get_key --- crates/bitwarden/src/crypto/enc_string.rs | 48 ++++++++++++ .../src/mobile/vault/client_sends.rs | 34 ++++++++- crates/bitwarden/src/vault/send.rs | 73 +++++++++++++++++-- 3 files changed, 145 insertions(+), 10 deletions(-) diff --git a/crates/bitwarden/src/crypto/enc_string.rs b/crates/bitwarden/src/crypto/enc_string.rs index dc5da81b1..571806846 100644 --- a/crates/bitwarden/src/crypto/enc_string.rs +++ b/crates/bitwarden/src/crypto/enc_string.rs @@ -155,6 +155,31 @@ impl EncString { .into()), } } + + #[cfg(feature = "mobile")] + pub(crate) fn to_buffer(&self) -> Result> { + let mut buf; + + match self { + EncString::AesCbc256_B64 { iv, data } => { + buf = Vec::with_capacity(1 + 16 + data.len()); + buf.push(self.enc_type()); + buf.extend_from_slice(iv); + buf.extend_from_slice(data); + } + EncString::AesCbc128_HmacSha256_B64 { iv, mac, data } + | EncString::AesCbc256_HmacSha256_B64 { iv, mac, data } => { + buf = Vec::with_capacity(1 + 16 + 32 + data.len()); + buf.push(self.enc_type()); + buf.extend_from_slice(iv); + buf.extend_from_slice(mac); + buf.extend_from_slice(data); + } + _ => todo!(), + } + + Ok(buf) + } } impl Display for EncString { @@ -302,4 +327,27 @@ mod tests { assert_eq!(t.key.to_string(), cipher); assert_eq!(serde_json::to_string(&t).unwrap(), serialized); } + + #[cfg(feature = "mobile")] + #[test] + fn test_enc_from_to_buffer() { + let enc_str: &str = "2.pMS6/icTQABtulw52pq2lg==|XXbxKxDTh+mWiN1HjH2N1w==|Q6PkuT+KX/axrgN9ubD5Ajk2YNwxQkgs3WJM0S0wtG8="; + let enc_string: EncString = enc_str.parse().unwrap(); + + let enc_buf = enc_string.to_buffer().unwrap(); + + assert_eq!( + enc_buf, + vec![ + 2, 164, 196, 186, 254, 39, 19, 64, 0, 109, 186, 92, 57, 218, 154, 182, 150, 67, + 163, 228, 185, 63, 138, 95, 246, 177, 174, 3, 125, 185, 176, 249, 2, 57, 54, 96, + 220, 49, 66, 72, 44, 221, 98, 76, 209, 45, 48, 180, 111, 93, 118, 241, 43, 16, 211, + 135, 233, 150, 136, 221, 71, 140, 125, 141, 215 + ] + ); + + let enc_string_new = EncString::from_buffer(&enc_buf).unwrap(); + + assert_eq!(enc_string_new.to_string(), enc_str) + } } diff --git a/crates/bitwarden/src/mobile/vault/client_sends.rs b/crates/bitwarden/src/mobile/vault/client_sends.rs index 62410e168..91efc3603 100644 --- a/crates/bitwarden/src/mobile/vault/client_sends.rs +++ b/crates/bitwarden/src/mobile/vault/client_sends.rs @@ -1,8 +1,7 @@ use std::path::Path; use crate::{ - client::encryption_settings::EncryptionSettings, - crypto::{Decryptable, EncString}, + crypto::{Decryptable, EncString, Encryptable}, error::Result, vault::{Send, SendListView, SendView}, Client, @@ -45,13 +44,40 @@ impl<'a> ClientSends<'a> { pub async fn decrypt_buffer(&self, send: Send, encrypted_buffer: &[u8]) -> Result> { let enc = self.client.get_encryption_settings()?; - let key = Send::get_key(&send.key, enc, &None)?; - let enc = EncryptionSettings::new_single_key(key); + let enc = Send::get_encryption(&send.key, enc, &None)?; let buf = EncString::from_buffer(encrypted_buffer)?; enc.decrypt_bytes(&buf, &None) } + + pub async fn encrypt(&self, send_view: SendView) -> Result { + let enc = self.client.get_encryption_settings()?; + + let send = send_view.encrypt(enc, &None)?; + + Ok(send) + } + + pub async fn encrypt_file( + &self, + send: Send, + decrypted_file_path: &Path, + encrypted_file_path: &Path, + ) -> Result<()> { + let data = std::fs::read(decrypted_file_path).unwrap(); + let encrypted = self.encrypt_buffer(send, &data).await?; + std::fs::write(encrypted_file_path, encrypted)?; + Ok(()) + } + + pub async fn encrypt_buffer(&self, send: Send, buffer: &[u8]) -> Result> { + let enc = self.client.get_encryption_settings()?; + let enc = Send::get_encryption(&send.key, enc, &None)?; + + let enc = enc.encrypt(buffer, &None)?; + enc.to_buffer() + } } impl<'a> ClientVault<'a> { diff --git a/crates/bitwarden/src/vault/send.rs b/crates/bitwarden/src/vault/send.rs index a8d7872fe..7c9360e0f 100644 --- a/crates/bitwarden/src/vault/send.rs +++ b/crates/bitwarden/src/vault/send.rs @@ -6,7 +6,7 @@ use uuid::Uuid; use crate::{ client::encryption_settings::EncryptionSettings, - crypto::{derive_shareable_key, Decryptable, EncString, SymmetricCryptoKey}, + crypto::{derive_shareable_key, Decryptable, EncString, Encryptable, SymmetricCryptoKey}, error::Result, }; @@ -126,7 +126,7 @@ pub struct SendListView { } impl Send { - pub(crate) fn get_key( + fn get_key( key: &EncString, enc: &EncryptionSettings, org_id: &Option, @@ -135,6 +135,15 @@ impl Send { let key = derive_shareable_key(key.try_into().unwrap(), "send", Some("send")); Ok(key) } + + pub(crate) fn get_encryption( + key: &EncString, + enc: &EncryptionSettings, + org_id: &Option, + ) -> Result { + let key = Send::get_key(key, enc, org_id)?; + Ok(EncryptionSettings::new_single_key(key)) + } } impl Decryptable for SendText { @@ -146,6 +155,15 @@ impl Decryptable for SendText { } } +impl Encryptable for SendTextView { + fn encrypt(self, enc: &EncryptionSettings, org_id: &Option) -> Result { + Ok(SendText { + text: self.text.encrypt(enc, org_id)?, + hidden: self.hidden, + }) + } +} + impl Decryptable for SendFile { fn decrypt(&self, enc: &EncryptionSettings, org_id: &Option) -> Result { Ok(SendFileView { @@ -157,11 +175,21 @@ impl Decryptable for SendFile { } } +impl Encryptable for SendFileView { + fn encrypt(self, enc: &EncryptionSettings, org_id: &Option) -> Result { + Ok(SendFile { + id: self.id.clone(), + file_name: self.file_name.encrypt(enc, org_id)?, + size: self.size.clone(), + size_name: self.size_name.clone(), + }) + } +} + impl Decryptable for Send { fn decrypt(&self, enc: &EncryptionSettings, org_id: &Option) -> Result { // For sends, we first decrypt the send key with the user key, and stretch it to it's full size - let key = Send::get_key(&self.key, enc, org_id)?; - let enc_owned = EncryptionSettings::new_single_key(key); + let enc_owned = Send::get_encryption(&self.key, enc, org_id)?; // For the rest of the fields, we ignore the provided EncryptionSettings and use a new one with the stretched key let enc = &enc_owned; @@ -194,8 +222,7 @@ impl Decryptable for Send { impl Decryptable for Send { fn decrypt(&self, enc: &EncryptionSettings, org_id: &Option) -> Result { // For sends, we first decrypt the send key with the user key, and stretch it to it's full size - let key = Send::get_key(&self.key, enc, org_id)?; - let enc_owned = EncryptionSettings::new_single_key(key); + let enc_owned = Send::get_encryption(&self.key, enc, org_id)?; // For the rest of the fields, we ignore the provided EncryptionSettings and use a new one with the stretched key let enc = &enc_owned; @@ -216,6 +243,40 @@ impl Decryptable for Send { } } +impl Encryptable for SendView { + fn encrypt(self, enc: &EncryptionSettings, org_id: &Option) -> Result { + // For sends, we first decrypt the send key with the user key, and stretch it to it's full size + let key = Send::get_key(&self.key, enc, org_id)?; + let enc_owned = EncryptionSettings::new_single_key(key); + + // For the rest of the fields, we ignore the provided EncryptionSettings and use a new one with the stretched key + let enc = &enc_owned; + + Ok(Send { + id: self.id, + access_id: self.access_id, + + name: self.name.encrypt(enc, org_id)?, + notes: self.notes.encrypt(enc, org_id)?, + key: self.key.clone(), + password: self.password.clone(), + + r#type: self.r#type, + file: self.file.encrypt(enc, org_id)?, + text: self.text.encrypt(enc, org_id)?, + + max_access_count: self.max_access_count, + access_count: self.access_count, + disabled: self.disabled, + hide_email: self.hide_email, + + revision_date: self.revision_date, + deletion_date: self.deletion_date, + expiration_date: self.expiration_date, + }) + } +} + #[cfg(test)] mod tests { use super::Send;