secrets

Version, currently main branch1 version
  • main branchlatestSep 24, 2023

gitlab.com/HCLarsen/secrets

Encrypted credentials management system, based on Rails/secrets

0 stars
1 dependent
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  secrets:
    gitlab: HCLarsen/secrets
    branch: main

main is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
>= 0.36.0, < 2.0.0
License
MIT
Author
Chris Larsen
Target
  • secrets from src/secrets.cr

Dependencies

Development Dependencies

  • minitest0.5.1github: ysbaddaden/minitest.crdev

README

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