Project

secretfile

0.0
Low commit activity in last 3 years
No release in over a year
Define secret mapping in a Secretfile, pulling from either ENV or Hashicorp Vault.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
 Project Readme

Secretfile

A standard way to bring secrets into your app.

# Secretfile
SECRET1 not/in/vault:set_in_env
SECRET2 secret/test:value
SECRET3 not/in/vault:expected_to_raise

Depends on Hashicorp Vault. Used in production at Faraday.

Differences from secret_garden

The initial implementation of Secretfile in ruby was secret_garden.

What secret_garden (other gem) secretfile (this gem)
Caches secrets in memory? Yes - an instance variable held secrets gotten from Vault, etc. No - always checks ENV and then calls out to vault.
Configurable backends? Yes - you require 'secret_garden/vault' etc. No - you only get vault, and it's required by default
Supports dynamic vault secrets (e.g. Amazon STS)? No - they are never refreshed Yes - they are pulled together, but not cached. Use Secretfile.group { Secretfile.get(x); Secretfile.get(y) }.

Installation

Add this line to your application's Gemfile:

gem 'secretfile'

And then execute:

$ bundle

Or install it yourself as:

$ gem install secretfile

Usage

In your Secretfile:

DATABASE_URL secrets/$VAULT_ENV/database:url
AWS_ACCESS_KEY_ID aws/sts/myrole:access_key
AWS_SECRET_ACCESS_KEY aws/sts/myrole:secret_key
AWS_SESSION_TOKEN aws/sts/myrole:security_token

Then you call

Secretfile.get('DATABASE_URL') # looks for ENV['DATABASE_URL'], falling back to secrets/$VAULT_ENV/database:url

To use dynamic creds like Amazon STS with the Vault AWS Secrets engine, do this:

Secretfile.group do
  akid = Secretfile.get('AWS_ACCESS_KEY_ID')
  sk = Secretfile.get('AWS_SECRET_ACCESS_KEY')
  st = Secretfile.get('AWS_SESSION_TOKEN')
end

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/faradayio/secretfile_ruby. 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 Secretfile project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Sponsor

Faraday logo

We use secretfile for B2C customer lifecycle optimization at Faraday.

Copyright

Copyright 2019 Faraday