rejson is a utility for managing a collection of secrets in source control. The secrets are encrypted using
public key, elliptic curve cryptography (NaClBox: Curve25519 + Salsa20 + Poly1305-AES). Secrets are
collected in a JSON file, in which all the string values are encrypted. Public keys are embedded in the file, and
the decrypter looks up the corresponding private key from its local filesystem.
This is a rust port of EJSON with a few extra bells and whistles. Full credit should go to the team that made EJSON. No innovation here other than needing Rust bindings and wanting a few extra features I'm not sure belonged upstream.
From Releases
curl-fsSLhttps://github.com/pseudomuto/rejson/releases/download/v0.2.0/rejson_0.2.0_$(uname-s)_$(uname-m).tar.gz|tarxzf-With Cargo
cargo install rejson
Since this is a drop-in replacement for ejson you can add alias ejson="rejson" if you like. The expectation is that
this is 100% compatible with ejson and it only additive. If that's not the case, it's a bug, and I'd appreciate you
filing an issue.
- A
--strip-keyflag ondecryptwhich will remove_public_keyfrom the result. envcommand which will export all keys under the top-levelenvironmentkey.kube-secretscommand which will output K8s secret manifests for values under thekuberneteskey.
See rejson -h or (cargo run -- -h) for usage details.
AcommandlineutilityformanagingsecretsUsage:rejson<COMMAND>Commands:encryptEncryptoneormoreEJSONfilesdecryptDecryptanEJSONfilekeygenGenerateanewEJSONkeypairenvExporttheallscalarvaluesunderthe"environment"keyhelpPrintthismessageorthehelpofthegivensubcommand(s)Options:-h,--helpPrinthelp-V,--versionPrintversionTo export all environment values in the environment key, run eval $(rejson env secrets.ejson).
{"_public_key":"...","environment":{"SOME_KEY":"SOME_VALUE"}}A docker image is published for each release of rEJSON. Usage is similar to using the binary, only the /keys and
/files volumes are required for encrypt/decrypt functionality.
# generate a new key pairdockerrun--rm-itrejsonkeygen# encrypt a file to diskdockerrun--rm-it \
-v$(pwd)/keys:/keys \
-v$(pwd)/secrets:/files \
rejsonencrypt /files/secrets.ejson# decrypt a file to stdoutdockerrun--rm-it \
-v$(pwd)/keys:/keys \
-v$(pwd)/secrets:/files \
rejsondecrypt /files/secrets.ejsonuse std::fs;use rejson::{KeyPair,SecretsFile};fnmain() -> Result<(),Box<dyn std::error::Error>>{let file = "examples/data/secrets.ejson";letmut secrets_file = SecretsFile::load(file).expect("failed to load file");
secrets_file.transform(rejson::compact()?)?;
secrets_file.transform(rejson::encrypt(&secrets_file)?)?;let json = secrets_file.to_string();let data = json.as_bytes();
fs::write(file, data)?;println!("Wrote {} bytes to {}", data.len(), file);Ok(())}See the examples directory for more.
- Make sure you have the nightly toolchain (used for rustfmt only)
- Add pre-commit to avoid committing malformatted code
ln-sf../../build/pre-commit.git/hooks/pre-commitRun build/release <new_version>. This will:
- Update version in Cargo.toml
- Create a new commit with the message "Release v"
git tag -sm "Release v<version" v<version>git push --tags
Once the release pipeline has finished and published the crate, run the following to create the GitHub release with attached binaries, etc.
taskreleaseAdd archives to the GitHub release and publish it.