-
Notifications
You must be signed in to change notification settings - Fork 838
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
Clean up API key config in config/initalizers/production.rb #1380
Comments
Ref: lobsters#1380 - I see little point in using a core extension for this. - It's only used in one place. - The implementation itself can be simplified a lot. Not 100% why but fixing this caused the `scripts/*.rb` to start failing to load. But they were using a non-standard way to load the application, so I simply cleaned them up too and the issue disapeared, probably not worth on digging up the root cause.
Could you expand a bit? Looking at your pointers, I see you are basically forcing eager loading of |
If I may. There is config/initializers/production.rb.sample file that you should rename to I thought about splitting that initializer into a separate class(es?), move them to same I hope it gives a bit more context on the issue. |
After sleeping on it a couple days, I'm pretty sure the root cause is our pattern of having utility classes that an initializer sets class variables on. That starts this whole contention of whether the utility class is loaded before the initializer, which was compounded by not using the Maybe the better fix would be to have the utility classes (GitHub, Mastodon, Pushover, DiffBot) load their api keys directly from ENV vars? I do like keeping them together in one list, but maybe providing a |
@byroot Thanks for your two PRs cleaning up At this point it seems pretty likely that |
I was reading up on gmem's PR for Action Mailbox (#1285) and ran across mention of the rails credentials store, which is the feature we predate that we should probably adopt for to replace all this: https://edgeguides.rubyonrails.org/security.html#custom-credentials |
Personally, I find Rails Personally I prefer the ergonomics of https://github.com/Shopify/ejson-rails |
Do you prefer it because you're pulling from some kind of enterprisey shared secret store? I'm not very familiar, but |
No, I prefer it because while the secrets are encrypted, the structure is still in clear text, so it's much easier to know which keys actually exist etc. Less important for Lobsters, it also allows users to add encrypted secrets without having access to the decryption key, only the public key is needed. But I was just mentioning it in passing, you operate the server, that's totally on you to chose whatever seem most convenient to you. |
Ref: lobsters#1380 - I see little point in using a core extension for this. - It's only used in one place. - The implementation itself can be simplified a lot. Not 100% why but fixing this caused the `scripts/*.rb` to start failing to load. But they were using a non-standard way to load the application, so I simply cleaned them up too and the issue disapeared, probably not worth on digging up the root cause.
I migrated us to the Of course, this broke the build. I'll add a workaround for the workaround for the incomplete rails feature when I'm less exasperated. |
I’ve deployed this without hassle. |
The build is green, I’m closing this. On the off chance that anyone sees this, the missing functionality from credentials is the ability to provide an initial template for the credentials file, and revise it so that devs + sites get clear messages about config changes rather than obscure NameErrors when the code tries to access missing keys. It doesn’t rise to the level of importance that I am willing to put up with That Guy. |
Following #1246
We have
config/initializers/production.rb
for setting API keys and site settings (seeconfig/application.rb
for theclass Lobsters
setup) that vary between the sister sites, but Rails style has long-since changed and I think there's a few new styles for better managing those.To my comment we should look at reimplementing this config so that Lobsters and sister sites use a single way that plays well with deploying to a VPS, PaaS, and Kamal, and doesn't end up with
require
statements to kludge around zeitwerk.It would be especially nice if this cleanup didn't break prod for us or sister sites! And removed the kludge in
config/initializers/00_zeitwerk.rb
.(Maybe this is the kind of plumbing issue I can nerdsnipe @byroot into?)
The text was updated successfully, but these errors were encountered: