Blog
How to read Rails credentials from anywhere without loading Rails
How to read Rails credentials from anywhere without Rails
Jun 07, 2023
· security, ruby-on-rails, ruby, credentials
Advanced usage of Rails Credentials to read it from anywhere Why ? Why would you want to access Rails credentials without initializing Rails? That’s a good question. The answer is not as straightforward. Even within a Rails application, there are situations where you need to run code without initializing Rails. One common scenario I often come across is when using Capistrano, a deployment automation tool, to perform deployments. After a successful deployment, I may need to send an email to stakeholders of the application, informing them about the deployment status. To achieve this, I need to access SMTP credentials, but I don’t want to hardcode them into a file. Instead, I want to leverage Rails’ native capability of storing credentials and secrets and use that to load the SMTP credentials into the relevant Capistrano files where Rails is not initialized. This is just one example, and...
The full article is published on Medium.
Read on Medium