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

PROD-1389 for TCF, any consent pref that is not defined on cookie should be assumed opt-out #4430

Merged
merged 4 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -17,6 +17,9 @@ The types of changes are:

## [Unreleased](https://github.com/ethyca/fides/compare/2.24.0...main)

### Changed
- Updates default consent preference to opt-out for TCF when fides_string override is provided [#4430](https://github.com/ethyca/fides/pull/4430)


## [2.24.0](https://github.com/ethyca/fides/compare/2.23.3...2.24.0)

Expand Down
6 changes: 4 additions & 2 deletions clients/fides-js/src/lib/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,10 @@ export const buildTcfEntitiesFromCookie = (
Boolean(cookieConsent[item.id]),
ConsentMechanism.OPT_IN
)
: // if experience contains a tcf entity not defined by tcfEntities, we override experience current pref with the default pref
item.default_preference;
: // If experience contains a tcf entity not defined by tcfEntities, this means either:
// A) Most commonly, user has opted out, and opt-outs are not tracked by TC string. It's safe to assume this case.
// B) There is a new tcf entity that requires consent. In this case we would just resurface the banner
ConsentMechanism.OPT_OUT;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we only want this for the fides string override case. in other words, I think this change would break this flow:

  • No fides string override
  • User opts out of all purposes
  • A new legint purpose is added
  • On load, the new legint purpose would be opted out, even though in this case, because we have the cookie key consent, we actually know the user has not opted out.

I think this could be fixed with...

const defaultPreference = cookie.fides_string ? ConsentMechanism.OPT_OUT : item.default_preference;
const preference = Object.hasOwn(cookieConsent, item.id) 
                 ? transformConsentToFidesUserPreference(
                      Boolean(cookieConsent[item.id]),
                      ConsentMechanism.OPT_IN
                    )
                 : defaultPreference;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah this makes more sense, thanks @allisonking !

return { ...item, current_preference: preference };
});
});
Expand Down
50 changes: 25 additions & 25 deletions clients/privacy-center/cypress/e2e/consent-banner-tcf.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1634,14 +1634,14 @@ describe("Fides-js TCF", () => {
});
cy.getByTestId(`toggle-${PURPOSE_9.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is false
// it should use false as the default
cy.get("input").should("not.be.checked");
});
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${PURPOSE_2.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
cy.get("input").should("be.checked");
// it should use false as the default
cy.get("input").should("not.be.checked");
});
// Features
cy.get("#fides-tab-Features").click();
Expand All @@ -1650,15 +1650,15 @@ describe("Fides-js TCF", () => {
});
// Vendors
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
// it should use false as the default
cy.get("#fides-tab-Vendors").click();
cy.getByTestId(`toggle-${VENDOR_1.name}`).within(() => {
cy.get("input").should("not.be.checked");
});
cy.get("#fides-panel-Vendors").within(() => {
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${SYSTEM_1.name}`).within(() => {
cy.get("input").should("be.checked");
cy.get("input").should("not.be.checked");
});
});

Expand Down Expand Up @@ -1729,14 +1729,14 @@ describe("Fides-js TCF", () => {
});
cy.getByTestId(`toggle-${PURPOSE_9.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is false
// it should use false as the default
cy.get("input").should("not.be.checked");
});
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${PURPOSE_2.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
cy.get("input").should("be.checked");
// it should use false as the default
cy.get("input").should("not.be.checked");
});
// Features
cy.get("#fides-tab-Features").click();
Expand All @@ -1745,15 +1745,15 @@ describe("Fides-js TCF", () => {
});
// Vendors
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
// it should use false as the default
cy.get("#fides-tab-Vendors").click();
cy.getByTestId(`toggle-${VENDOR_1.name}`).within(() => {
cy.get("input").should("not.be.checked");
});
cy.get("#fides-panel-Vendors").within(() => {
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${SYSTEM_1.name}`).within(() => {
cy.get("input").should("be.checked");
cy.get("input").should("not.be.checked");
});
});

Expand Down Expand Up @@ -1865,14 +1865,14 @@ describe("Fides-js TCF", () => {
});
cy.getByTestId(`toggle-${PURPOSE_9.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is false
// it should use false as the default
cy.get("input").should("not.be.checked");
});
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${PURPOSE_2.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
cy.get("input").should("be.checked");
// it should use false as the default
cy.get("input").should("not.be.checked");
});
// Features
cy.get("#fides-tab-Features").click();
Expand All @@ -1881,15 +1881,15 @@ describe("Fides-js TCF", () => {
});
// Vendors
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
// it should use false as the default
cy.get("#fides-tab-Vendors").click();
cy.getByTestId(`toggle-${VENDOR_1.name}`).within(() => {
cy.get("input").should("not.be.checked");
});
cy.get("#fides-panel-Vendors").within(() => {
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${SYSTEM_1.name}`).within(() => {
cy.get("input").should("be.checked");
cy.get("input").should("not.be.checked");
});
});

Expand Down Expand Up @@ -2047,14 +2047,14 @@ describe("Fides-js TCF", () => {
});
cy.getByTestId(`toggle-${PURPOSE_9.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is false
// it should use false as the default
cy.get("input").should("not.be.checked");
});
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${PURPOSE_2.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
cy.get("input").should("be.checked");
// it should use false as the default
cy.get("input").should("not.be.checked");
});
// Features
cy.get("#fides-tab-Features").click();
Expand All @@ -2070,9 +2070,9 @@ describe("Fides-js TCF", () => {
cy.get("button").contains("Legitimate interest").click();
});
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
// it should use false as the default
cy.getByTestId(`toggle-${SYSTEM_1.name}`).within(() => {
cy.get("input").should("be.checked");
cy.get("input").should("not.be.checked");
});

// verify CMP API
Expand Down Expand Up @@ -2166,14 +2166,14 @@ describe("Fides-js TCF", () => {
});
cy.getByTestId(`toggle-${PURPOSE_9.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is false
// it should use false as the default
cy.get("input").should("not.be.checked");
});
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${PURPOSE_2.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
cy.get("input").should("be.checked");
// it should use false as the default
cy.get("input").should("not.be.checked");
});
// Features
cy.get("#fides-tab-Features").click();
Expand All @@ -2182,7 +2182,7 @@ describe("Fides-js TCF", () => {
});
// Vendors
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
// it should use false as the default
cy.get("#fides-tab-Vendors").click();
cy.getByTestId(`toggle-${VENDOR_1.name}`).within(() => {
cy.get("input").should("not.be.checked");
Expand All @@ -2191,7 +2191,7 @@ describe("Fides-js TCF", () => {
cy.get("button").contains("Legitimate interest").click();
});
cy.getByTestId(`toggle-${SYSTEM_1.name}`).within(() => {
cy.get("input").should("be.checked");
cy.get("input").should("not.be.checked");
});

// verify CMP API
Expand Down
Loading