Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HA-399 deprecate cookies #27

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ The types of changes are:

## [Unreleased](https://github.com/ethyca/fideslang/compare/3.0.9...main)

### Deprecated
- Deprecated `Cookies` model and `.cookies` property on `System` and `PrivacyDeclaration` [#199](https://github.com/IABTechLab/fideslang/pull/199)

## [3.0.9](https://github.com/ethyca/fideslang/compare/3.0.8...3.0.9)

### Added
Expand Down
40 changes: 38 additions & 2 deletions src/fideslang/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from datetime import datetime
from enum import Enum
from typing import Annotated, Dict, List, Optional, Union, Any
from warnings import warn

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, how does this work? have we tested how this actually manifests in application use?

i don't think we use this builtin anywhere else, so it'd just be good to verify that it surfaces in the way you'd want/expect.

i think the two things to test would be specifying a cookies attribute on an API call to the /systems endpoint, and using the CLI to push/pull a system definition with cookies


from packaging.version import InvalidVersion, Version
from pydantic import (
Expand Down Expand Up @@ -284,13 +285,24 @@ class DataCategory(FidesModel, DefaultModel):


class Cookies(BaseModel):
"""The Cookies resource model"""
"""
DEPRECATED.
The Cookies resource model
"""

name: str
path: Optional[str] = None
domain: Optional[str] = None
model_config = ConfigDict(from_attributes=True)

@model_validator(mode="after")
def validate_cookies(self, _: ValidationInfo) -> Cookies:
"""
Validate that the `cookies` field is deprecated and warn that it should not be used.
"""
warn("The 'cookies' field is deprecated and should not be used.")
return self


class DataSubjectRights(BaseModel):
"""
Expand Down Expand Up @@ -881,10 +893,22 @@ class PrivacyDeclaration(BaseModel):
)
cookies: Optional[List[Cookies]] = Field(
default=None,
description="Cookies associated with this data use to deliver services and functionality",
description="DEPRECATED. Cookies associated with this data use to deliver services and functionality",
)
model_config = ConfigDict(from_attributes=True)

@field_validator("cookies")
@classmethod
def validate_cookies(
cls, value: Optional[List[Cookies]]
) -> Optional[List[Cookies]]:
"""
Validate that the `cookies` field is deprecated and warn that it should not be used.
"""
if value is not None:
warn("The 'cookies' field is deprecated and should not be used.")
return value


class SystemMetadata(BaseModel):
"""
Expand Down Expand Up @@ -1134,6 +1158,18 @@ def privacy_declarations_reference_data_flows(

return self

@field_validator("cookies")
@classmethod
def validate_cookies(
cls, value: Optional[List[Cookies]]
) -> Optional[List[Cookies]]:
"""
Validate that the `cookies` field is deprecated and warn that it should not be used.
"""
if value is not None:
warn("The 'cookies' field is deprecated and should not be used.")
return value

model_config = ConfigDict(use_enum_values=True)


Expand Down
Loading