secrets
secrets.cr
Encrypted credentials management system, largely based on Rails/secrets
Offers a command line interface with secrets-cli
Installation
- Add the dependency to your
shard.yml
:
dependencies:
secrets:
github: HCLarsen/secrets
- Run
shards install
Usage
When the Secrets
class is instantiated, it loads the data from an encoded YAML file. The key used to decode the data can either come from a local key file, or an environment variable named SECRETS_KEY.
require "secrets"
secrets = Secrets.new
Unlike similar libraries, the Secrets
class isn't a singleton. This allows the dev to have separate files for different environments, such as development, testing, and production.
If unspecified, the default name for the secrets file is secrets.yml.enc
, and the location is the current directory. If a specific name/location are required, then they can be specified during the initialization:
require "secrets"
secrets = Secrets.new("./config/production.yml.enc")
OR:
require "secrets"
secrets = Secrets.load("./config/production.yml.enc")
Secrets are presented as a Hash
of type String => YAML::Any
.
require "secrets"
secrets = Secrets.load
secrets["API_KEY"].as_s #=> "RANDOM_KEY"
secrets["API2"]["EMAIL"].as_s #=> "random@example.org"
secrets["API2"]["PASSWORD"].as_s #=> "DontUseACommonPassword"
Development
TODO: Write development instructions here
Contributing
- Fork it (https://github.com/HCLarsen/secrets/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Chris Larsen - creator and maintainer
secrets
- 0
- 0
- 0
- 2
- 1
- about 1 year ago
- September 24, 2023
MIT License
Mon, 18 Nov 2024 06:06:24 GMT