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

Parse ac string from fides string #4308

Merged
merged 8 commits into from
Oct 25, 2023

Conversation

allisonking
Copy link
Contributor

@allisonking allisonking commented Oct 19, 2023

Closes #4263

Description Of Changes

We are able to take a custom fides string and initialize the tcf_consent portion of the cookie. This PR allows us to take a fides string that has an AC string attached, and initialize the AC values on our cookie as well.

Code Changes

  • Util functions to parse fidesString and get IDs from AC strings
  • Unit tests for these functions
  • Call these functions and initialize vendor_consents based on AC string
  • Cypress test

Steps to Confirm

  • Set up TCF with some AC vendors (for example, Facebook)
  • Opt out of everything in your overlay. Examine your cookie, and you should see under fides_string an entry like CPz5G8APz5G8AGXABBENAWEAAACAAEIAAAAAAAAKhgAgKhAA.IJawBAABAD-AVCBLUAAA,1~. The first part might differ, but it should end in ,1~. This is because there are no AC vendors opted in.
  • Make a note of the vendor ID for the AC vendor you added (Facebook is gacp.89)
  • Now tack on a query parameter fides_string=CPz5G8APz5G8AGXABBENAWEAAACAAEIAAAAAAAAKhgAgKhAA.IJawBAABAD-AVCBLUAAA,1~89 to your URL, i.e. http://localhost:3001/fides-js-demo.html?geolocation=fi-18&fides_string=CPz5G8APz5G8AGXABBENAWEAAACAAEIAAAAAAAAKhgAgKhAA.IJawBAABAD-AVCBLUAAA,1~89. This passes in the fides string as a query parameter for initialization. Replace the 89 with the AC vendor ID you added
  • Now when you visit the page and click on the Vendors tab, you should see Facebook opted in

Pre-Merge Checklist

  • All CI Pipelines Succeeded
  • Issue Requirements are Met
  • Update CHANGELOG.md

@cypress
Copy link

cypress bot commented Oct 19, 2023

Passing run #4817 ↗︎

0 4 0 0 Flakiness 0
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

Merge b61faf7 into 344b85b...
Project: fides Commit: 20f19d14af ℹ️
Status: Passed Duration: 00:49 💡
Started: Oct 25, 2023 7:30 PM Ended: Oct 25, 2023 7:30 PM

Review all test suite changes for PR #4308 ↗︎

@pattisdr
Copy link
Contributor

Here's some nuances around how the backend works around both returning AC systems and building AC strings

Copy link
Contributor

@eastandwestwind eastandwestwind left a comment

Choose a reason for hiding this comment

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

looks great, just a Q and a small nit, nothing blocking.

/**
* Given an AC string, return a list of its ids, encoded
*
* @example 1~1.2.3 --> [gacp.1, gacp.2, gacp.3]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! What does the @example annotation do exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh heh I think I had just seen it around before, but only just looked up the documentation: https://jsdoc.app/tags-example.html

so it actually looks like it should be in the format of calling the function to show it being used as an example... I'll update the docstring, but basically it formats the following line to look like code

image

export const idsFromAcString = (acString: string) => {
const isValidAc = /\d~/;
if (!isValidAc.test(acString)) {
return [];
Copy link
Contributor

Choose a reason for hiding this comment

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

can we debug log if we have an invalid AC str?


export const transformFidesStringToCookieKeys = (
fidesString: string,
debug: boolean
): TcfCookieConsent => {
// Defer: to fully support AC string, we need to split out TC from AC string https://github.com/ethyca/fides/issues/4263
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

@allisonking
Copy link
Contributor Author

@allisonking allisonking merged commit 30bfb30 into main Oct 25, 2023
9 of 11 checks passed
@allisonking allisonking deleted the aking/prod-1166/parse-ac-string-from-fides-string branch October 25, 2023 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need to be able to take a custom composite fides_tc_string and parse out TC and AC strings
4 participants