-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use config.credentials.* in credentials commands
This commit changes the credentials commands (e.g. `bin/rails credentials:edit`) to respect `config.credentials.content_path` and `config.credentials.key_path` when set in `config/application.rb`. Before this commit: * Unlike other `bin/rails` commands, `bin/rails credentials:edit` ignored `RAILS_ENV`, and would always edit `config/credentials.yml.enc`. * `bin/rails credentials:edit --environment foo` would create and edit `config/credentials/foo.yml.enc`. * If `config.credentials.content_path` or `config.credentials.key_path` was set, `bin/rails credentials:edit` could not be used to edit the credentials. Editing credentials required using `bin/rails encrypted:edit path/to/credentials --key path/to/key`. After this commit: * `bin/rails credentials:edit` will edit the credentials file that the app would load for the current `RAILS_ENV`. * `bin/rails credentials:edit` respects `config.credentials.content_path` and `config.credentials.key_path` when set in `config/application.rb`. Using `RAILS_ENV`, environment-specific paths can be set, such as: ```ruby # config/application.rb module MyCoolApp class Application < Rails::Application config.credentials.content_path = "my_credentials/#{Rails.env}.yml.enc" config.credentials.key_path = "path/to/production.key" if Rails.env.production? end end ``` * `bin/rails credentials:edit --environment foo` will create and edit `config/credentials/foo.yml.enc` _if_ `config.credentials.content_path` has not been set for the `foo` environment. Ultimately, it will edit the credentials file that the app would load for the `foo` environment. Note that the credentials commands do not run initializers. Therefore, they will not, for example, attempt to connect to the database of the specified environment. Fixes #37631. Fixes #41830. Fixes #46884. Closes #46904. Co-authored-by: Alex Ghiculescu <alex@tanda.co>
- Loading branch information
1 parent
2fc46f9
commit 1068945
Showing
6 changed files
with
134 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters