feat: encrypt PII fields before saving it in the database (#1043)

Co-authored-by: Nishant Joshi <nishant.joshi@juspay.in>
This commit is contained in:
Kartikeya Hegde
2023-05-30 13:43:17 +05:30
committed by GitHub
parent 77e60c82fa
commit fa392c40a8
107 changed files with 3818 additions and 1267 deletions

View File

@ -1,4 +1,4 @@
use common_utils::{consts, custom_serde, pii};
use common_utils::{consts, crypto, custom_serde, pii};
use masking::Secret;
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
@ -16,7 +16,7 @@ pub struct CustomerRequest {
pub merchant_id: String,
/// The customer's name
#[schema(max_length = 255, example = "Jon Test")]
pub name: Option<String>,
pub name: Option<Secret<String>>,
/// The customer's email address
#[schema(value_type = Option<String>,max_length = 255, example = "JonTest@test.com")]
pub email: Option<pii::Email>,
@ -56,13 +56,13 @@ pub struct CustomerResponse {
pub customer_id: String,
/// The customer's name
#[schema(max_length = 255, example = "Jon Test")]
pub name: Option<String>,
pub name: crypto::OptionalEncryptableName,
/// The customer's email address
#[schema(value_type = Option<String>,max_length = 255, example = "JonTest@test.com")]
pub email: Option<pii::Email>,
pub email: crypto::OptionalEncryptableEmail,
/// The customer's phone number
#[schema(value_type = Option<String>,max_length = 255, example = "9999999999")]
pub phone: Option<Secret<String>>,
pub phone: crypto::OptionalEncryptablePhone,
/// The country code for the customer phone number
#[schema(max_length = 255, example = "+65")]
pub phone_country_code: Option<String>,