0.0
No commit activity in last 3 years
No release in over 3 years
A simple wrapper for reading sensitive information stored in files to support the pattern of storing secrets in external files outside of a project's code.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 3.0
 Project Readme

FileSecrets

This gem provides a simple method to support the pattern of reading sensitive information that is stored in files that is deployed separately from the code that needs them.

The basic pattern is to deploy your sensitive information into a directory structure like:

/srv
|-- /secrets
    |--/api
       |-- secret_key
       |-- token

You could then read your secrets with FileSecrets:

  secrets = FileSecrets.new("/srv/secrets")
  secrets["api/secret_key"]
  secrets["api/token"]

If the file doesn't exist, nil will be returned.

Each FileSecrets object will have a base directory where it will locate the files from. If this is not provided in the initializer, it will be set from the FILE_SECRETS_BASE environment variable. If that isn't set, then it will be set to the current working directory.

There is also a handy class level accessor that you can use either if you want to use the default base path:

  ENV["FILE_SECRETS_BASE"] = "/srv/secrets"
  FileSecrets["api/secret_key"]
  FileSecrets["api/token"]

The paths passed to get the file values are virtual paths using the / character as a file separator. So, you would pass the same keys on Windows that you would on Linux.