All Projects → sinsoku → Rails Env Credentials

sinsoku / Rails Env Credentials

Licence: mit
Enhances Rails credentials for multiple environments

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Rails Env Credentials

Yabeda Rails
Yabeda plugin to collect basic metrics for Rails applications
Stars: ✭ 99 (-5.71%)
Mutual labels:  rails
Activerecord Clean Db Structure
Automatic cleanup for the Rails db/structure.sql file (ActiveRecord/PostgreSQL)
Stars: ✭ 101 (-3.81%)
Mutual labels:  rails
Activestorage Aliyun
Wraps the Aliyun OSS as an Active Storage service.
Stars: ✭ 103 (-1.9%)
Mutual labels:  rails
Splits Io
a speedrunning data store, analysis engine, and racing platform
Stars: ✭ 99 (-5.71%)
Mutual labels:  rails
Material design lite Sass
Google's Material Design Lite with Material Icons and Roboto font for Ruby applications
Stars: ✭ 100 (-4.76%)
Mutual labels:  rails
Pong
Two player Pong reinvented using Vue.js and Rails w/ Action Cable
Stars: ✭ 101 (-3.81%)
Mutual labels:  rails
Sr mini
A single file Rails app that will have you running a StimulusReflex and CableReady demo in just 2 steps.
Stars: ✭ 98 (-6.67%)
Mutual labels:  rails
Counter culture
Turbo-charged counter caches for your Rails app.
Stars: ✭ 1,397 (+1230.48%)
Mutual labels:  rails
Graphql devise
GraphQL interface on top devise_token_auth
Stars: ✭ 100 (-4.76%)
Mutual labels:  rails
Coding further
"Coding further" is made for my students who graduated from Le Wagon coding bootcamp and are just now exploring the world of programming.
Stars: ✭ 103 (-1.9%)
Mutual labels:  rails
Simpacker
Use modern JavaScript build system in Rails.
Stars: ✭ 100 (-4.76%)
Mutual labels:  rails
Test track
Server app for the TestTrack multi-platform split-testing and feature-gating system
Stars: ✭ 100 (-4.76%)
Mutual labels:  rails
React Activestorage Provider
A React component that allows easy file upload using ActiveStorage
Stars: ✭ 102 (-2.86%)
Mutual labels:  rails
Lol dba
lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts.
Stars: ✭ 1,363 (+1198.1%)
Mutual labels:  rails
Ruby Getting Started
Getting Started with Ruby on Heroku
Stars: ✭ 103 (-1.9%)
Mutual labels:  rails
Comfy Blog
Blog Engine for ComfortableMexicanSofa (Rails 5.2+)
Stars: ✭ 98 (-6.67%)
Mutual labels:  rails
Simple recommender
A simple recommendation engine for Rails/Postgres
Stars: ✭ 101 (-3.81%)
Mutual labels:  rails
Rails Doubletap Rce
RCE on Rails 5.2.2 using a path traversal (CVE-2019-5418) and a deserialization of Ruby objects (CVE-2019-5420)
Stars: ✭ 105 (+0%)
Mutual labels:  rails
Rails Letsencrypt
The Let's Encrypt certificate manager for rails
Stars: ✭ 104 (-0.95%)
Mutual labels:  rails
Premailer Rails
CSS styled emails without the hassle.
Stars: ✭ 1,382 (+1216.19%)
Mutual labels:  rails

Gem Version Build Status

RailsEnvCredentials

It enhances the Credentials feature introduced by Rails v5.2.0.

Installation

Add this line to your Rails application's Gemfile:

group :development, :test do
  gem 'rails-env-credentials'
end

And then execute:

$ bundle

Usage

RailsEnvCredentials manages credentials and key pairs with the following:

config/credentials-development.yml.enc
config/credentials-test.yml.enc
config/credentials.yml.enc
master-development.key
master-test.key
master.key

It also manages environment variables for each env.

RAILS_MASTER_KEY_DEVELOPMENT
RAILS_MASTER_KEY_TEST
RAILS_MASTER_KEY

You can use appropriate credentials depending on Rails.env.

$ rails env_credentials:show -e development
# config/credentials-development.yml.enc
aws:
  bucket: foo-dev

$ rails env_credentials:show -e production
# config/credentials.yml.enc
aws:
  bucket: foo-prod

$ rails runner -e development 'pp Rails.application.credentials.aws.bucket'
"foo-dev"
$ rails runner -e production 'pp Rails.application.credentials.aws.bucket'
"foo-prod"

Generating secrets and a master key

It automatically generate encrypted file and the master key when you starts editing credentials at first:

$ rails env_credentials:edit -e development

Show secrets

You want to see decrypted contents, use env_credentials:show:

$ rails env_credentials:show -e development

Additional information

Other environments support

For example, if the config/environments/staging.rb exists, you will generate config/credentials-staging.yml.enc.

$ rails env_credentials:edit -e staging

Display a diff

You can’t directly compare encrypted files between two versions, but it turns out you can see a diff using Git attributes.

Put the following line in your .gitattributes file:

config/credentials*.yml.enc diff=env_credentials

Then configure Git to use env_credentials:show:

$ git config diff.env_credentials.textconv 'rails env_credentials:show --file'

This tells Git that encrypted files should decrypt by the env_credentials:show task when you try to display a diff.

Why make this gem?

Credentials is a good feature, but we cannot use it on development and test environment.

DHH wrote as follow in the pull request for initial implementation:

It's only in production (and derivative environments, like exposed betas) where the secret actually needs to be secret.

refs: https://github.com/rails/rails/pull/30067

However, I have to manage secrets and a master key different from production for testing in the staging environment.

I do not have the confidence to explain explicit use cases to Rails team, so I implemented as a gem.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sinsoku/rails-env-credentials. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Rails::Env::Credentials project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].