secrets

Encrypted credentials management system, based on Rails/secrets

secrets.cr

Build Status

Encrypted credentials management system, largely based on Rails/secrets

Offers a command line interface with secrets-cli

Installation

  1. Add the dependency to your shard.yml:
dependencies:
  secrets:
    github: HCLarsen/secrets
  1. 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

  1. Fork it (https://github.com/HCLarsen/secrets/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

secrets

Owner
Statistic
  • 0
  • 0
  • 0
  • 2
  • 1
  • about 1 year ago
  • September 24, 2023
License

MIT License

Links
Synced at

Mon, 18 Nov 2024 06:06:24 GMT

Languages