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

Get API key out of embed codebase #16

Merged
merged 2 commits into from
Aug 22, 2023
Merged

Get API key out of embed codebase #16

merged 2 commits into from
Aug 22, 2023

Conversation

oyamauchi
Copy link
Member

@oyamauchi oyamauchi commented Aug 17, 2023

Description

We're almost certainly going to open-source this codebase at some
point, so let's get the API key out of it, since it's technically a
secret.

In the end this is a little pointless as a matter of security, since
anyone could just inspect the embed site and see the key sitting there.
But this will at least prevent people from just cloning this repo
and using our key.

Test Plan

Run locally and make sure the calculator works.

Run locally with an incorrect key in .env.local and make sure it
results in "Authorization failed".

Vercel build to be tested as part of this PR process.

Next Steps

After deploying this change with a new key set in Vercel, make sure
the old key isn't being used elsewhere (i.e. the first-party
calculator), then revoke it.

## Description

We're almost certainly going to open-source this codebase at some
point, so let's get the API key out of it, since it's technically a
secret.

## Test Plan

Run locally and make sure the calculator works.

Run locally with an incorrect key in `.env.local` and make sure it
results in "Authorization failed".

Vercel build to be tested as part of this PR process.

## Next Steps

After deploying this change with a new key set in Vercel, make sure
the old key isn't being used elsewhere (i.e. the first-party
calculator), then revoke it.
@vercel
Copy link

vercel bot commented Aug 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
embed-rewiringamerica-org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 18, 2023 4:22pm

@oyamauchi
Copy link
Member Author

oyamauchi commented Aug 17, 2023

I set the environment variable in the Vercel project (a new key, not the one I deleted from the code), and now that works. (I inspected source on the Vercel preview to make sure it's got the new key.) However, Cypress has to do its own build, and now that's failing. Will look into that, but for now: do you think this is a reasonable path?

@oyamauchi
Copy link
Member Author

Cypress build is fixed (I added a line to the GH action config, and added the key to this repo's secrets)

@@ -2850,7 +2871,7 @@ posthtml-render@^3.0.0:
dependencies:
is-json "^2.0.1"

posthtml@^0.16.4, posthtml@^0.16.5:
posthtml@^0.16.4, posthtml@^0.16.5, posthtml@^0.16.6:
Copy link
Member

Choose a reason for hiding this comment

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

The blessings and the curses of npm.

I don't think it's worth optimizing these for server side - but I'm assuming they don't all get bundled client side?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is in devDependencies, so irrelevant for client side.

Also, what this is saying is that all three version specs are satisfied by the same actual version of posthtml, so this isn't actually adding new code anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Ah good point, thanks. OK so in this case it's working. I was dimly recalling some pathological cases in the past where I had many revisions of the same library live at the same time. Thanks for correction!

Copy link
Member

@RandomEtc RandomEtc left a comment

Choose a reason for hiding this comment

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

Neato, I wondered if we could do that. I was limited by Github Pages before, or by my own understanding of it - it did run a build step, I didn't click that the build step could inject the key. Thanks for doing this!

@oyamauchi oyamauchi merged commit 09afa7e into main Aug 22, 2023
2 checks passed
@oyamauchi oyamauchi deleted the owen/rm-keys branch August 22, 2023 20:52
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.

2 participants