-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
Use Rails.application.secret_key_base directly #3043
Conversation
Port of #2417 to the main branch
Code Climate has analyzed commit c084954 and detected 0 issues on this pull request. View more on Code Climate. |
Thank you for the contribution @jpawlyn! What if
Let's add a rescue, which generates a random key on production just to keep the app running and show an error on development. |
|
||
raise "Unable to fetch secret key base. Please set it in your credentials or environment variables\n" \ | ||
"For more information check https://docs.avohq.io/3.0/encryption-service.html#secret-key-base" | ||
Rails.application.secret_key_base[0..31] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rails.application.secret_key_base[0..31] | |
Rails.application.secret_key_base[0..31] | |
rescue | |
# Avoid breaking in production | |
# All features relying on encryption will not work properly without a configured secret key base | |
return SecureRandom.random_bytes(32) if Rails.env.production? | |
raise "Unable to fetch secret key base. Please set it in your credentials or environment variables\n" \ | |
"For more information check https://docs.avohq.io/3.0/encryption-service.html#secret-key-base" |
Looks like Rails takes care of this scenario - please see https://github.com/rails/rails/blob/a17aa6376d7974e38af90a2fe28e548b201baa63/railties/lib/rails/application/configuration.rb#L529 And when I ran my Rails 7.1.3.4 app server in production mode without a secret key base configured, puma never started due to the error:
|
Looks great! Thanks @jpawlyn! |
Description
Port of #2417 to the main branch
Fixes # (issue)
Removes the deprecation message output when running tests:
Checklist:
Screenshots & recording
Manual review steps