navapbc / template-application-rails

Ruby on Rails with USWDS template, including CI/CD, for teams building web applications
Apache License 2.0
1 stars 1 forks source link

Spike to investigate impact of switching from env vars to rails credentials #11

Open rocketnova opened 3 months ago

rocketnova commented 3 months ago

The current strategy for providing secrets is to use environment variables. When hosting in AWS, the secrets are passed as secured environment variables from Parameter Store.

Rails supports providing secrets as encrypted credentials instead of environment variables or environment files. This issue is for doing a spike to investigate:

Possible references:

Tasks:

lorenyu commented 3 months ago

What's the advantage of doing this? Seems less 12factor-y

rocketnova commented 3 months ago

Yeah, this spike should include that evaluation. At first glance, I think one benefit is encryption.

lorenyu commented 3 months ago

I'm not sure I understand the benefit of encryption. I would imagine that having an encrypted secrets file in source control is still less secure than not having secrets stored in source control at all. Since it's in source control it'd be in git history, so the secrets would have to be ones that are revokable, otherwise a future hacker can still hack an old version of the encrypted file (I forget what that type of attack is called)

SammySteiner commented 2 months ago

I'll take the ticket.

@rocketnova I want to structure the doc more like an ADR comparing the two approaches (pros and cons of each) and explaining why we went with .env vars. I'll also include a section on how to back out of this config if the folks using the template prefer to use Rails Credentials anyway. Does that work for you for this ticket?

@lorenyu I agree generally that env is a better approach than rails credentials (security, 12 factor-y, consistent with other Nava templates and repos, not to mention I was getting late night infomercial vibes from the thoughtbot article with their description of trying to set up a repo only to discover that you don't have the env vars <scareQuotes>Has this happened to you?</scareQuotes>). But I like the idea of having an ADR in the codebase for other engineers about why we're not doing it the Rails way in our Rails template.

lorenyu commented 2 months ago

if i had to guess, rails does it this way because it's convenient and requires minimal infrastructure. you just need one environment variable which you could do manually rather than a infra pattern for how to inject env vars into your app dynamically. if we do have that infra pattern though, i don't see the benefit of it.

rocketnova commented 2 months ago

@SammySteiner Thank you for outlining your approach to this ticket. It looks great. I would like to see an assessment of the options, an ADR for why we picked what we picked, and directions to support people who want to use the template with a different approach than the one we picked. I'll update the ticket with these tasks. Thanks!