MyNixOS website logo
Description

Please see the README on GitHub at https://github.com/CollegeVine/confcrypt#readme.

Please see the README on GitHub at https://github.com/CollegeVine/confcrypt#readme

confcrypt

As soon as an application is deployed or built on more than a single machine, you tend to start worrying about managing the configuration. There are a number of ways to approach this problem, but ultimately there's a need to protect sensitive information like database passwords and api tokens. While you can always store those directly in a config management system like AWS' Parameter Store, doing so means you can't track configuration changes in source control. This application provides yet another simple and straightforward means of hiding config information within source control.

CircleCI

Installing confcrypt

Mac OSX via Brew

brew tap collegevine/brew
brew cask install confcrypt

Windows, Linux, & OSX native

  1. If you don't have Haskell installed and working already, you'll need it. Install stack from haskellstack.org.
  2. At the root of this repo, run stack install. (Takes 10-15 minutes.)

Using confcrypt

  • create a config confcrypt create <filename> creates a new empty confcrypt config named <filename>.econf. Internally, it looks like this:

    # confcrypt schema
    # Configuration parameters may be either a String, Int, or Boolean
    # Parameter schema take the following shape:
    # schema := [term | value | comment]
    #   term := confname : type
    #   confname := [a-z,A-Z,_,0-9]
    #   type := String | Int | Boolean
    #   value := confname = String
    #   comment := # String
    #
    # For example:
    # DB_CONN_STR : String
    # DB_CONN_STR = Connection String
    # USE_SSL : Boolean
    # USE_SSL = True
    # TIMEOUT_MS : Int
    # TIMEOUT_MS = 300
    
  • read a config confcrypt rsa read --key <filename> <filename> This command reads in the provided file, decrypts the configuration variables using the provided key, then prints them to stdout. This allows you to pipe the results to other utilities. Returns 0 on success.

  • add a parameter confcrypt rsa add --key <filename> --name <String> --type <SchemaType> --vaue <String> <filename> Adds a new confguration parameter to the file. --nameand--valueare required, while--typeis optional. If--type` is provided, the schema record will be added immediately before the config variable. In total this adds two lines to the file. Returns 0 on sccess.

  • remove a parameter confcrypt delete --name <filename> Removes an existing config parameter & associated schema. Returns 0 on success or 1 if the parameter is not found in the file.

  • edit a parameter in-place confcrypt rsa edit --key <filename> --name <String> --value <String> --type <SchemaType> <filename> Modifies an existing configuration parameter in place, leaving all other lines unchanged. While this isn't how it's actually implemented, this operation is equivalent to piping confcrypt read to a new file, editing the parameter, then reencrypting it.

  • validate a config confcrypt rsa validate --key <filename> <filename> Checks that each config parameter matches the type of its schema. All errors are accumulated and returned at the end, with a response code equal to the number of failures.

  • Using Amazon KMS instead of a local key The rsa command tree exists under aws, which changes the behavior of the --key parameter to represent a KMS key id rather than an on-disk rsa key file. The otherwise the semantics of the commands are identical between rsa and kms branches.

The confcrypt file format

```
# confcrypt schema
# Configuration parameters may be either a String, Int, or Boolean
# Parameter schema take the following shape:
# schema := [term | value | comment]
#   term := confname : type
#   confname := [a-z,A-Z,_,0-9]
#   type := String | Int | Boolean
#   value := confname = String
#   comment := # String
#
# For example:
# DB_CONN_STR : String
# DB_CONN_STR = Connection String
# USE_SSL : Boolean
# USE_SSL = True
# TIMEOUT_MS : Int
# TIMEOUT_MS = 300
```

*Note* confcrypt files must end with a trailing newline.

While the default config created via `confcrypt new ...` places the schema on line `n` and parameters on `n+1`, there's no required ordering for the file. In fact, you can choose to entirely omit the schema and only store configuration paraemters in an `econf` file, but this will cause `confcrypt validate` to fail.
Metadata

Version

0.2.3.3

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows