mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 09:38:33 +08:00
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:
@ -11,9 +11,10 @@ use diesel::{
|
||||
sql_types, AsExpression,
|
||||
};
|
||||
use error_stack::{IntoReport, ResultExt};
|
||||
use masking::{Secret, Strategy, WithType};
|
||||
use masking::{ExposeInterface, Secret, Strategy, WithType};
|
||||
|
||||
use crate::{
|
||||
crypto::Encryptable,
|
||||
errors::{self, ValidationError},
|
||||
validation::validate_email,
|
||||
};
|
||||
@ -107,6 +108,18 @@ where
|
||||
#[serde(try_from = "String")]
|
||||
pub struct Email(Secret<String, EmailStrategy>);
|
||||
|
||||
impl From<Encryptable<Secret<String, EmailStrategy>>> for Email {
|
||||
fn from(item: Encryptable<Secret<String, EmailStrategy>>) -> Self {
|
||||
Self(item.into_inner())
|
||||
}
|
||||
}
|
||||
|
||||
impl ExposeInterface<Secret<String, EmailStrategy>> for Email {
|
||||
fn expose(self) -> Secret<String, EmailStrategy> {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<String> for Email {
|
||||
type Error = error_stack::Report<errors::ParsingError>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user