From ce94c024236700956adbcb675c6f5db1089f4ee9 Mon Sep 17 00:00:00 2001 From: Dawn Pattison Date: Wed, 29 May 2024 11:20:44 -0500 Subject: [PATCH] Isolate Served Notice V2 (#4910) Separate LastServedNoticeV2 so it no longer inherits from shared mixins with other privacy preference related models. This table is now deprecated and will be removed on a future date. --- CHANGELOG.md | 1 + src/fides/api/db/base.py | 1 - src/fides/api/models/privacy_preference.py | 52 +++++++++++++++++++--- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21856348ea..d8dc7ba17a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The types of changes are: ## [Unreleased](https://github.com/ethyca/fides/compare/2.37.0...main) ### Added +- Deprecate LastServedNotice (lastservednoticev2) table [#4910](https://github.com/ethyca/fides/pull/4910) - Added erasure support to the Recurly integration [#4891](https://github.com/ethyca/fides/pull/4891) ### Changed diff --git a/src/fides/api/db/base.py b/src/fides/api/db/base.py index 553b5b8781..6f304c8340 100644 --- a/src/fides/api/db/base.py +++ b/src/fides/api/db/base.py @@ -36,7 +36,6 @@ ) from fides.api.models.privacy_preference import ( CurrentPrivacyPreference, - LastServedNotice, PrivacyPreferenceHistory, ServedNoticeHistory, ) diff --git a/src/fides/api/models/privacy_preference.py b/src/fides/api/models/privacy_preference.py index 6c1d8077f9..dd5e6cbeb3 100644 --- a/src/fides/api/models/privacy_preference.py +++ b/src/fides/api/models/privacy_preference.py @@ -176,10 +176,12 @@ def __tablename__(self) -> str: ) -class LastServedNotice(ConsentIdentitiesMixin, Base): - """Stores the latest served notices for a given user +class LastServedNotice(Base): + """ + DEPRECATED. DO NOT UPDATE THIS TABLE. This will soon be removed. - Email/device id/phone must be unique in this table. + This table consolidates every notice a user has been served, (analogous to CurrentPrivacyPreference + but it is being removed). Backend is not writing to this any longer. """ @declared_attr @@ -215,6 +217,45 @@ def __tablename__(self) -> str: ), ) + email = Column( + StringEncryptedType( + type_in=String(), + key=CONFIG.security.app_encryption_key, + engine=AesGcmEngine, + padding="pkcs5", + ), + ) # Encrypted email + + fides_user_device = Column( + StringEncryptedType( + type_in=String(), + key=CONFIG.security.app_encryption_key, + engine=AesGcmEngine, + padding="pkcs5", + ), + ) # Encrypted fides user device + + phone_number = Column( + StringEncryptedType( + type_in=String(), + key=CONFIG.security.app_encryption_key, + engine=AesGcmEngine, + padding="pkcs5", + ), + ) # Encrypted phone number + + hashed_email = Column( + String, + index=True, + ) # For exact match searches + + hashed_fides_user_device = Column(String, index=True) # For exact match searches + + hashed_phone_number = Column( + String, + index=True, + ) # For exact match searches + @classmethod def generate_served_notice_history_id(cls) -> str: """Generate a served notice history id @@ -324,9 +365,8 @@ def __tablename__(self) -> str: serving_component = Column(EnumColumn(ServingComponent), nullable=False, index=True) - # Identifier generated when a LastServedNotice is created and returned in the response. - # This is saved on all corresponding ServedNoticeHistory records and can be used to link - # PrivacyPreferenceHistory records. + # Generated identifier for the ServedNoticeHistory, used to link a ServedNoticeHistory and PrivacyPreferenceHistory + # record together served_notice_history_id = Column(String, index=True) tcf_served = Column(