GSA-TTS / tts.gsa.gov

Making the website work for people who make websites work
https://federalist-a2423046-fe43-4e75-a2ef-2651e5e123ca.sites.pages.cloud.gov/preview/gsa-tts/tts.gsa.gov/staging/
Other
6 stars 4 forks source link

Parameterize Search.gov and DAP configuration #256

Closed wesley-dean-gsa closed 1 week ago

wesley-dean-gsa commented 2 weeks ago

Currently, the API key for Search.gov is stored in _data/site.yml. Even though they API key is public, including credentials like this is generally seen as a bad practice.

Therefore, so that the API key can be passed as an environment variable, create a file at _data/searchGov.js that will extrapolate from the environment the API key (apiKey) and affiliate (affiliate) and make them available via the data cascade.

It appears that the API key is a Base64-encoded hash, so an extended regex that would match an API key would be ^([[:alnum:]+/=]+)$

The affiliate value, so an extended regex that would match it would be ^([[:lower:][:digit:]-]+)$

The values would include sensible defaults that would not cause the build to break in the event that the values were not provided.

We would then be able to use searchGov.apiKey and searchGov.affiliate in the _data/site.yaml

https://www.11ty.dev/docs/data-js/#example-exposing-environment-variables

wesley-dean-gsa commented 2 weeks ago

conversation via Slack