├── .gitignore ├── .rspec ├── .travis.yml ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── bin ├── console └── setup ├── envkey.gemspec ├── ext ├── envkey-fetch_1.2.9_darwin_amd64 │ ├── LICENSE │ ├── README.md │ └── envkey-fetch ├── envkey-fetch_1.2.9_darwin_arm64 │ ├── LICENSE │ ├── README.md │ └── envkey-fetch ├── envkey-fetch_1.2.9_freebsd_amd64 │ ├── LICENSE │ ├── README.md │ └── envkey-fetch ├── envkey-fetch_1.2.9_linux_amd64 │ ├── LICENSE │ ├── README.md │ └── envkey-fetch ├── envkey-fetch_1.2.9_linux_arm64 │ ├── LICENSE │ ├── README.md │ └── envkey-fetch └── envkey-fetch_1.2.9_windows_amd64 │ ├── LICENSE │ ├── README.md │ └── envkey-fetch.exe ├── lib ├── envkey.rb └── envkey │ ├── core.rb │ ├── fetch.rb │ ├── platform.rb │ ├── rails.rb │ └── version.rb └── spec ├── envkey_spec.rb └── spec_helper.rb /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | *.gem 11 | .byebug_history -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: ruby 3 | rvm: 4 | - 2.3.1 5 | before_install: gem install bundler -v 1.13.6 6 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in envkey.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2021 Envkey Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # envkey gem 2 | 3 | Integrate [EnvKey](https://www.envkey.com) with your Ruby or Ruby On Rails projects to keep api keys, credentials, and other configuration securely and automatically in sync for developers and servers. 4 | 5 | # v2 6 | 7 | Now that [EnvKey v2](https://v2.envkey.com) has been released, you can find version 2 of this gem in [a subdirectory of the EnvKey v2 monorepo](https://github.com/envkey/envkey/tree/main/public/sdks/languages-and-frameworks/ruby). Using v2 requires an EnvKey v2 organization (it won't work with ENVKEYs generated in a v1 org). 8 | 9 | [Here's a guide on migrating from v1 to v2.](https://docs-v2.envkey.com/docs/migrating-from-v1) 10 | 11 | To continue using version 1 of this gem, make sure you specify `~> 1.0.0` in your Gemfile so that you don't accidentally install v2. 12 | 13 | ## Installation 14 | 15 | In your Gemfile: 16 | 17 | ```ruby 18 | gem 'envkey', '~> 1.0.0' 19 | ``` 20 | 21 | If you're using Rails, that's all you need. In plain Ruby, you need to require envkey at the entry point of your application. 22 | 23 | ```ruby 24 | require 'envkey' 25 | ``` 26 | 27 | ## Usage 28 | 29 | Generate an `ENVKEY` in the [EnvKey App](https://github.com/envkey/envkey-app). Then set `ENVKEY=...`, either in a gitignored `.env` file in the root of your project (in development) or in an environment variable (on servers). 30 | 31 | Now all your EnvKey variables will be available on `ENV`. 32 | 33 | ### Errors 34 | 35 | The gem will throw an error if an `ENVKEY` is missing or invalid. 36 | 37 | ### Example 38 | 39 | Assume you have `STRIPE_SECRET_KEY` set to `sk_test_2a33b045e998d2ef60c7861d2ac22ea8` for the `development` environment in the EnvKey App. You generate a local development `ENVKEY`. 40 | 41 | In your project's **gitignored** `.env` file: 42 | 43 | ```bash 44 | # .env 45 | ENVKEY=GsL8zC74DWchdpvssa9z-nk7humd7hJmAqNoA 46 | ``` 47 | 48 | In `config/initializers/stripe.rb`: 49 | 50 | ```ruby 51 | Stripe.api_key = ENV.fetch("STRIPE_SECRET_KEY") 52 | ``` 53 | 54 | Now `STRIPE_SECRET_KEY` will stay automatically in sync for all the developers on your team. 55 | 56 | For a server, generate a server `ENVKEY` in the EnvKey App, then set the `ENVKEY` as an environment variable instead of putting it in a `.env` file. 57 | 58 | Now your servers will stay in sync as well. If you need to rotate your `STRIPE_SECRET_KEY` you can do it in a few seconds in the EnvKey App, restart your servers, and you're good to go. All your team's developers and all your servers will have the new value. 59 | 60 | ### Overriding Vars 61 | 62 | The envkey gem will not overwrite existing environment variables or additional variables set in a `.env` file. This can be convenient for customizing environments that otherwise share the same configuration. You can also use [sub-environments](https://blog.envkey.com/development-staging-production-and-beyond-85f26f65edd6) in the EnvKey app for this purpose. 63 | 64 | ### Working Offline 65 | 66 | The envkey gem caches your encrypted config in development so that you can still use it while offline. Your config will still be available (though possibly not up-to-date) the next time you lose your internet connection. If you do have a connection available, envkey will always load the latest config. Your cached encrypted config is stored in `$HOME/.envkey/cache` 67 | 68 | For caching purposes, the gem assumes you're in development mode if either `ENV["RAILS_ENV"]` or `ENV["RACK_ENV"]` is `"development"` or `"test"`. If you aren't using Rails or Rack, then it's assumed you're in development mode when a `.env` file exists in the root of your project. 69 | 70 | ## envkey-fetch binaries 71 | 72 | If you look in the `ext` directory of this gem, you'll find a number of `envkey-fetch` binaries for various platforms and architectures. These are output by the [envkey-fetch Go library](https://github.com/envkey/envkey-fetch). It contains EnvKey's core cross-platform fetching, decryption, verification, web of trust, redundancy, and caching logic. It is completely open source. 73 | 74 | ## x509 error / ca-certificates 75 | 76 | On a stripped down OS like Alpine Linux, you may get an `x509: certificate signed by unknown authority` error when the envkey gem attempts to load your config. [envkey-fetch](https://github.com/envkey/envkey-fetch) tries to handle this by including its own set of trusted CAs via [gocertifi](https://github.com/certifi/gocertifi), but if you're getting this error anyway, you can fix it by ensuring that the `ca-certificates` dependency is installed. On Alpine you'll want to run: 77 | ``` 78 | apk add --no-cache ca-certificates 79 | ``` 80 | 81 | ## Further Reading 82 | 83 | For more on EnvKey in general: 84 | 85 | Read the [docs](https://docs.envkey.com). 86 | 87 | Read the [integration quickstart](https://docs.envkey.com/integration-quickstart.html). 88 | 89 | Read the [security and cryptography overview](https://security.envkey.com). 90 | 91 | ## Need help? Have questions, feedback, or ideas? 92 | 93 | Post an [issue](https://github.com/envkey/envkey-ruby/issues) or email us: [support@envkey.com](mailto:support@envkey.com). 94 | 95 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rspec/core/rake_task" 3 | 4 | RSpec::Core::RakeTask.new(:spec) 5 | 6 | task :default => :spec 7 | -------------------------------------------------------------------------------- /bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "bundler/setup" 4 | require "envkey" 5 | 6 | # You can add fixtures and/or initialization code here to make experimenting 7 | # with your gem easier. You can also use a different console, if you like. 8 | 9 | # (If you use this, don't forget to add pry to your Gemfile!) 10 | # require "pry" 11 | # Pry.start 12 | 13 | require "irb" 14 | IRB.start 15 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | set -vx 5 | 6 | bundle install 7 | 8 | # Do any other automated setup that you need to do here 9 | -------------------------------------------------------------------------------- /envkey.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'envkey/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "envkey" 8 | spec.version = Envkey::VERSION 9 | spec.authors = ["Dane Schneider"] 10 | spec.email = ["dane@envkey.com"] 11 | 12 | spec.summary = "Envkey secures and simplifies app secrets and config." 13 | spec.homepage = "https://www.envkey.com" 14 | spec.license = "MIT" 15 | 16 | # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' 17 | # to allow pushing to a single host or delete this section to allow pushing to any host. 18 | if spec.respond_to?(:metadata) 19 | spec.metadata['allowed_push_host'] = "https://rubygems.org" 20 | else 21 | raise "RubyGems 2.0 or newer is required to protect against " \ 22 | "public gem pushes." 23 | end 24 | 25 | spec.files = `git ls-files -z`.split("\x0").reject do |f| 26 | f.match(%r{^(test|spec|features)/}) 27 | end 28 | spec.bindir = "exe" 29 | spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } 30 | spec.require_paths = ["lib"] 31 | 32 | spec.add_development_dependency "bundler", "~> 1.13" 33 | spec.add_development_dependency "rake", "~> 10.0" 34 | spec.add_development_dependency "rspec", "~> 3.0" 35 | 36 | spec.add_runtime_dependency "dotenv", "~> 2.0" 37 | end 38 | -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_darwin_amd64/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2021 Envkey Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_darwin_amd64/README.md: -------------------------------------------------------------------------------- 1 | # envkey-fetch 2 | 3 | This library contains [EnvKey](https://www.envkey.com)'s core cross-platform fetching, decryption, verification, web of trust, redundancy, and caching logic. It accepts an `ENVKEY` generated by the [EnvKey App](https://www.github.com/envkey/envkey-app) and returns decrypted configuration for a specific app environment as json. 4 | 5 | It is used by EnvKey's various Client Libraries, including [envkey-source](https://github.com/envkey/envkey-source) for bash, [envkey-ruby](https://github.com/envkey/envkey-ruby) for Ruby and Rails, [envkey-python](https://github.com/envkey/envkey-python) for Python, [envkey-node](https://github.com/envkey/envkey-node) for Node.js, and [envkeygo](https://github.com/envkey/envkeygo) for Go. 6 | 7 | If you want to build an EnvKey library in a language that isn't yet officially supported, build some other type of integration, or simply play around with EnvKey on the command line, envkey-fetch is the library for you. If you just want to integrate EnvKey with your project, check out one of the aforementioned higher level libraries. 8 | 9 | ## Installation 10 | 11 | envkey-fetch compiles into a simple static binary with no dependencies, which makes installation a simple matter of fetching the right binary for your platform and putting it in your `PATH`. An `install.sh` script is available to simplify this, as well as a [homebrew tap](https://github.com/envkey/homebrew-envkey).. 12 | 13 | **Install via bash:** 14 | 15 | ```bash 16 | curl -s https://raw.githubusercontent.com/envkey/envkey-fetch/master/install.sh | bash 17 | ``` 18 | 19 | **Install manually:** 20 | 21 | Find the [release](https://github.com/envkey/envkey-fetch/releases) for your platform and architecture, and stick the appropriate binary somewhere in your `PATH` (or wherever you like really). 22 | 23 | **Install from source:** 24 | 25 | With Go installed, clone the project into your `GOPATH`. `cd` into the directory and run `go get` and `go build`. 26 | 27 | **Cross-compile from source:** 28 | 29 | To compile cross-platform binaries, make sure Go is installed, then install [goreleaser](https://goreleaser.com/) - follow instructions in the docs to do so. 30 | 31 | Then to cross-compile, run: 32 | 33 | `goreleaser` 34 | 35 | Binaries for each platform will be output to the `dist` folder. 36 | 37 | ## Usage 38 | 39 | ```bash 40 | envkey-fetch YOUR-ENVKEY [flags] 41 | ``` 42 | 43 | This will either write your the app environment's configuration associated with your `ENVKEY` as json to stdout or write an error message beginning with `error:` to stdout. 44 | 45 | ### Example json output 46 | 47 | ```json 48 | {"TEST":"it","TEST_2":"works!"} 49 | ``` 50 | 51 | ### Example error output 52 | 53 | ```text 54 | error: ENVKEY invalid 55 | ``` 56 | 57 | ### Flags 58 | 59 | ```text 60 | --cache cache encrypted config as a local backup (default is false) 61 | --cache-dir string cache directory (default is $HOME/.envkey/cache) 62 | --client-name string calling client library name (default is none) 63 | --client-version string calling client library version (default is none) 64 | -h, --help help for envkey-fetch 65 | --retries uint8 number of times to retry requests on failure (default 3) 66 | --retryBackoff float retry backoff factor: {retryBackoff} * (2 ^ {retries - 1}) (default 1) 67 | --timeout float timeout in seconds for http requests (default 10) 68 | --verbose print verbose output (default is false) 69 | -v, --version prints the version 70 | ``` 71 | 72 | ## x509 error / ca-certificates 73 | 74 | On a stripped down OS like Alpine Linux, you may get an `x509: certificate signed by unknown authority` error when `envkey-fetch` attempts to load your config. `envkey-fetch` tries to handle this by including its own set of trusted CAs via [gocertifi](https://github.com/certifi/gocertifi), but if you're getting this error anyway, you can fix it by ensuring that the `ca-certificates` dependency is installed. On Alpine you'll want to run: 75 | ``` 76 | apk add --no-cache ca-certificates 77 | ``` 78 | 79 | ## Further Reading 80 | 81 | For more on EnvKey in general: 82 | 83 | Read the [docs](https://docs.envkey.com). 84 | 85 | Read the [integration quickstart](https://docs.envkey.com/integration-quickstart.html). 86 | 87 | Read the [security and cryptography overview](https://security.envkey.com). 88 | 89 | ## Need help? Have questions, feedback, or ideas? 90 | 91 | Post an [issue](https://github.com/envkey/envkey-fetch/issues) or email us: [support@envkey.com](mailto:support@envkey.com). 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_darwin_amd64/envkey-fetch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envkey/envkey-ruby/0ebecfd9b8daa91d7e607c5684dd628a25b8ff2f/ext/envkey-fetch_1.2.9_darwin_amd64/envkey-fetch -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_darwin_arm64/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2021 Envkey Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_darwin_arm64/README.md: -------------------------------------------------------------------------------- 1 | # envkey-fetch 2 | 3 | This library contains [EnvKey](https://www.envkey.com)'s core cross-platform fetching, decryption, verification, web of trust, redundancy, and caching logic. It accepts an `ENVKEY` generated by the [EnvKey App](https://www.github.com/envkey/envkey-app) and returns decrypted configuration for a specific app environment as json. 4 | 5 | It is used by EnvKey's various Client Libraries, including [envkey-source](https://github.com/envkey/envkey-source) for bash, [envkey-ruby](https://github.com/envkey/envkey-ruby) for Ruby and Rails, [envkey-python](https://github.com/envkey/envkey-python) for Python, [envkey-node](https://github.com/envkey/envkey-node) for Node.js, and [envkeygo](https://github.com/envkey/envkeygo) for Go. 6 | 7 | If you want to build an EnvKey library in a language that isn't yet officially supported, build some other type of integration, or simply play around with EnvKey on the command line, envkey-fetch is the library for you. If you just want to integrate EnvKey with your project, check out one of the aforementioned higher level libraries. 8 | 9 | ## Installation 10 | 11 | envkey-fetch compiles into a simple static binary with no dependencies, which makes installation a simple matter of fetching the right binary for your platform and putting it in your `PATH`. An `install.sh` script is available to simplify this, as well as a [homebrew tap](https://github.com/envkey/homebrew-envkey).. 12 | 13 | **Install via bash:** 14 | 15 | ```bash 16 | curl -s https://raw.githubusercontent.com/envkey/envkey-fetch/master/install.sh | bash 17 | ``` 18 | 19 | **Install manually:** 20 | 21 | Find the [release](https://github.com/envkey/envkey-fetch/releases) for your platform and architecture, and stick the appropriate binary somewhere in your `PATH` (or wherever you like really). 22 | 23 | **Install from source:** 24 | 25 | With Go installed, clone the project into your `GOPATH`. `cd` into the directory and run `go get` and `go build`. 26 | 27 | **Cross-compile from source:** 28 | 29 | To compile cross-platform binaries, make sure Go is installed, then install [goreleaser](https://goreleaser.com/) - follow instructions in the docs to do so. 30 | 31 | Then to cross-compile, run: 32 | 33 | `goreleaser` 34 | 35 | Binaries for each platform will be output to the `dist` folder. 36 | 37 | ## Usage 38 | 39 | ```bash 40 | envkey-fetch YOUR-ENVKEY [flags] 41 | ``` 42 | 43 | This will either write your the app environment's configuration associated with your `ENVKEY` as json to stdout or write an error message beginning with `error:` to stdout. 44 | 45 | ### Example json output 46 | 47 | ```json 48 | {"TEST":"it","TEST_2":"works!"} 49 | ``` 50 | 51 | ### Example error output 52 | 53 | ```text 54 | error: ENVKEY invalid 55 | ``` 56 | 57 | ### Flags 58 | 59 | ```text 60 | --cache cache encrypted config as a local backup (default is false) 61 | --cache-dir string cache directory (default is $HOME/.envkey/cache) 62 | --client-name string calling client library name (default is none) 63 | --client-version string calling client library version (default is none) 64 | -h, --help help for envkey-fetch 65 | --retries uint8 number of times to retry requests on failure (default 3) 66 | --retryBackoff float retry backoff factor: {retryBackoff} * (2 ^ {retries - 1}) (default 1) 67 | --timeout float timeout in seconds for http requests (default 10) 68 | --verbose print verbose output (default is false) 69 | -v, --version prints the version 70 | ``` 71 | 72 | ## x509 error / ca-certificates 73 | 74 | On a stripped down OS like Alpine Linux, you may get an `x509: certificate signed by unknown authority` error when `envkey-fetch` attempts to load your config. `envkey-fetch` tries to handle this by including its own set of trusted CAs via [gocertifi](https://github.com/certifi/gocertifi), but if you're getting this error anyway, you can fix it by ensuring that the `ca-certificates` dependency is installed. On Alpine you'll want to run: 75 | ``` 76 | apk add --no-cache ca-certificates 77 | ``` 78 | 79 | ## Further Reading 80 | 81 | For more on EnvKey in general: 82 | 83 | Read the [docs](https://docs.envkey.com). 84 | 85 | Read the [integration quickstart](https://docs.envkey.com/integration-quickstart.html). 86 | 87 | Read the [security and cryptography overview](https://security.envkey.com). 88 | 89 | ## Need help? Have questions, feedback, or ideas? 90 | 91 | Post an [issue](https://github.com/envkey/envkey-fetch/issues) or email us: [support@envkey.com](mailto:support@envkey.com). 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_darwin_arm64/envkey-fetch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envkey/envkey-ruby/0ebecfd9b8daa91d7e607c5684dd628a25b8ff2f/ext/envkey-fetch_1.2.9_darwin_arm64/envkey-fetch -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_freebsd_amd64/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2021 Envkey Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_freebsd_amd64/README.md: -------------------------------------------------------------------------------- 1 | # envkey-fetch 2 | 3 | This library contains [EnvKey](https://www.envkey.com)'s core cross-platform fetching, decryption, verification, web of trust, redundancy, and caching logic. It accepts an `ENVKEY` generated by the [EnvKey App](https://www.github.com/envkey/envkey-app) and returns decrypted configuration for a specific app environment as json. 4 | 5 | It is used by EnvKey's various Client Libraries, including [envkey-source](https://github.com/envkey/envkey-source) for bash, [envkey-ruby](https://github.com/envkey/envkey-ruby) for Ruby and Rails, [envkey-python](https://github.com/envkey/envkey-python) for Python, [envkey-node](https://github.com/envkey/envkey-node) for Node.js, and [envkeygo](https://github.com/envkey/envkeygo) for Go. 6 | 7 | If you want to build an EnvKey library in a language that isn't yet officially supported, build some other type of integration, or simply play around with EnvKey on the command line, envkey-fetch is the library for you. If you just want to integrate EnvKey with your project, check out one of the aforementioned higher level libraries. 8 | 9 | ## Installation 10 | 11 | envkey-fetch compiles into a simple static binary with no dependencies, which makes installation a simple matter of fetching the right binary for your platform and putting it in your `PATH`. An `install.sh` script is available to simplify this, as well as a [homebrew tap](https://github.com/envkey/homebrew-envkey).. 12 | 13 | **Install via bash:** 14 | 15 | ```bash 16 | curl -s https://raw.githubusercontent.com/envkey/envkey-fetch/master/install.sh | bash 17 | ``` 18 | 19 | **Install manually:** 20 | 21 | Find the [release](https://github.com/envkey/envkey-fetch/releases) for your platform and architecture, and stick the appropriate binary somewhere in your `PATH` (or wherever you like really). 22 | 23 | **Install from source:** 24 | 25 | With Go installed, clone the project into your `GOPATH`. `cd` into the directory and run `go get` and `go build`. 26 | 27 | **Cross-compile from source:** 28 | 29 | To compile cross-platform binaries, make sure Go is installed, then install [goreleaser](https://goreleaser.com/) - follow instructions in the docs to do so. 30 | 31 | Then to cross-compile, run: 32 | 33 | `goreleaser` 34 | 35 | Binaries for each platform will be output to the `dist` folder. 36 | 37 | ## Usage 38 | 39 | ```bash 40 | envkey-fetch YOUR-ENVKEY [flags] 41 | ``` 42 | 43 | This will either write your the app environment's configuration associated with your `ENVKEY` as json to stdout or write an error message beginning with `error:` to stdout. 44 | 45 | ### Example json output 46 | 47 | ```json 48 | {"TEST":"it","TEST_2":"works!"} 49 | ``` 50 | 51 | ### Example error output 52 | 53 | ```text 54 | error: ENVKEY invalid 55 | ``` 56 | 57 | ### Flags 58 | 59 | ```text 60 | --cache cache encrypted config as a local backup (default is false) 61 | --cache-dir string cache directory (default is $HOME/.envkey/cache) 62 | --client-name string calling client library name (default is none) 63 | --client-version string calling client library version (default is none) 64 | -h, --help help for envkey-fetch 65 | --retries uint8 number of times to retry requests on failure (default 3) 66 | --retryBackoff float retry backoff factor: {retryBackoff} * (2 ^ {retries - 1}) (default 1) 67 | --timeout float timeout in seconds for http requests (default 10) 68 | --verbose print verbose output (default is false) 69 | -v, --version prints the version 70 | ``` 71 | 72 | ## x509 error / ca-certificates 73 | 74 | On a stripped down OS like Alpine Linux, you may get an `x509: certificate signed by unknown authority` error when `envkey-fetch` attempts to load your config. `envkey-fetch` tries to handle this by including its own set of trusted CAs via [gocertifi](https://github.com/certifi/gocertifi), but if you're getting this error anyway, you can fix it by ensuring that the `ca-certificates` dependency is installed. On Alpine you'll want to run: 75 | ``` 76 | apk add --no-cache ca-certificates 77 | ``` 78 | 79 | ## Further Reading 80 | 81 | For more on EnvKey in general: 82 | 83 | Read the [docs](https://docs.envkey.com). 84 | 85 | Read the [integration quickstart](https://docs.envkey.com/integration-quickstart.html). 86 | 87 | Read the [security and cryptography overview](https://security.envkey.com). 88 | 89 | ## Need help? Have questions, feedback, or ideas? 90 | 91 | Post an [issue](https://github.com/envkey/envkey-fetch/issues) or email us: [support@envkey.com](mailto:support@envkey.com). 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_freebsd_amd64/envkey-fetch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envkey/envkey-ruby/0ebecfd9b8daa91d7e607c5684dd628a25b8ff2f/ext/envkey-fetch_1.2.9_freebsd_amd64/envkey-fetch -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_linux_amd64/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2021 Envkey Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_linux_amd64/README.md: -------------------------------------------------------------------------------- 1 | # envkey-fetch 2 | 3 | This library contains [EnvKey](https://www.envkey.com)'s core cross-platform fetching, decryption, verification, web of trust, redundancy, and caching logic. It accepts an `ENVKEY` generated by the [EnvKey App](https://www.github.com/envkey/envkey-app) and returns decrypted configuration for a specific app environment as json. 4 | 5 | It is used by EnvKey's various Client Libraries, including [envkey-source](https://github.com/envkey/envkey-source) for bash, [envkey-ruby](https://github.com/envkey/envkey-ruby) for Ruby and Rails, [envkey-python](https://github.com/envkey/envkey-python) for Python, [envkey-node](https://github.com/envkey/envkey-node) for Node.js, and [envkeygo](https://github.com/envkey/envkeygo) for Go. 6 | 7 | If you want to build an EnvKey library in a language that isn't yet officially supported, build some other type of integration, or simply play around with EnvKey on the command line, envkey-fetch is the library for you. If you just want to integrate EnvKey with your project, check out one of the aforementioned higher level libraries. 8 | 9 | ## Installation 10 | 11 | envkey-fetch compiles into a simple static binary with no dependencies, which makes installation a simple matter of fetching the right binary for your platform and putting it in your `PATH`. An `install.sh` script is available to simplify this, as well as a [homebrew tap](https://github.com/envkey/homebrew-envkey).. 12 | 13 | **Install via bash:** 14 | 15 | ```bash 16 | curl -s https://raw.githubusercontent.com/envkey/envkey-fetch/master/install.sh | bash 17 | ``` 18 | 19 | **Install manually:** 20 | 21 | Find the [release](https://github.com/envkey/envkey-fetch/releases) for your platform and architecture, and stick the appropriate binary somewhere in your `PATH` (or wherever you like really). 22 | 23 | **Install from source:** 24 | 25 | With Go installed, clone the project into your `GOPATH`. `cd` into the directory and run `go get` and `go build`. 26 | 27 | **Cross-compile from source:** 28 | 29 | To compile cross-platform binaries, make sure Go is installed, then install [goreleaser](https://goreleaser.com/) - follow instructions in the docs to do so. 30 | 31 | Then to cross-compile, run: 32 | 33 | `goreleaser` 34 | 35 | Binaries for each platform will be output to the `dist` folder. 36 | 37 | ## Usage 38 | 39 | ```bash 40 | envkey-fetch YOUR-ENVKEY [flags] 41 | ``` 42 | 43 | This will either write your the app environment's configuration associated with your `ENVKEY` as json to stdout or write an error message beginning with `error:` to stdout. 44 | 45 | ### Example json output 46 | 47 | ```json 48 | {"TEST":"it","TEST_2":"works!"} 49 | ``` 50 | 51 | ### Example error output 52 | 53 | ```text 54 | error: ENVKEY invalid 55 | ``` 56 | 57 | ### Flags 58 | 59 | ```text 60 | --cache cache encrypted config as a local backup (default is false) 61 | --cache-dir string cache directory (default is $HOME/.envkey/cache) 62 | --client-name string calling client library name (default is none) 63 | --client-version string calling client library version (default is none) 64 | -h, --help help for envkey-fetch 65 | --retries uint8 number of times to retry requests on failure (default 3) 66 | --retryBackoff float retry backoff factor: {retryBackoff} * (2 ^ {retries - 1}) (default 1) 67 | --timeout float timeout in seconds for http requests (default 10) 68 | --verbose print verbose output (default is false) 69 | -v, --version prints the version 70 | ``` 71 | 72 | ## x509 error / ca-certificates 73 | 74 | On a stripped down OS like Alpine Linux, you may get an `x509: certificate signed by unknown authority` error when `envkey-fetch` attempts to load your config. `envkey-fetch` tries to handle this by including its own set of trusted CAs via [gocertifi](https://github.com/certifi/gocertifi), but if you're getting this error anyway, you can fix it by ensuring that the `ca-certificates` dependency is installed. On Alpine you'll want to run: 75 | ``` 76 | apk add --no-cache ca-certificates 77 | ``` 78 | 79 | ## Further Reading 80 | 81 | For more on EnvKey in general: 82 | 83 | Read the [docs](https://docs.envkey.com). 84 | 85 | Read the [integration quickstart](https://docs.envkey.com/integration-quickstart.html). 86 | 87 | Read the [security and cryptography overview](https://security.envkey.com). 88 | 89 | ## Need help? Have questions, feedback, or ideas? 90 | 91 | Post an [issue](https://github.com/envkey/envkey-fetch/issues) or email us: [support@envkey.com](mailto:support@envkey.com). 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_linux_amd64/envkey-fetch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envkey/envkey-ruby/0ebecfd9b8daa91d7e607c5684dd628a25b8ff2f/ext/envkey-fetch_1.2.9_linux_amd64/envkey-fetch -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_linux_arm64/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2021 Envkey Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_linux_arm64/README.md: -------------------------------------------------------------------------------- 1 | # envkey-fetch 2 | 3 | This library contains [EnvKey](https://www.envkey.com)'s core cross-platform fetching, decryption, verification, web of trust, redundancy, and caching logic. It accepts an `ENVKEY` generated by the [EnvKey App](https://www.github.com/envkey/envkey-app) and returns decrypted configuration for a specific app environment as json. 4 | 5 | It is used by EnvKey's various Client Libraries, including [envkey-source](https://github.com/envkey/envkey-source) for bash, [envkey-ruby](https://github.com/envkey/envkey-ruby) for Ruby and Rails, [envkey-python](https://github.com/envkey/envkey-python) for Python, [envkey-node](https://github.com/envkey/envkey-node) for Node.js, and [envkeygo](https://github.com/envkey/envkeygo) for Go. 6 | 7 | If you want to build an EnvKey library in a language that isn't yet officially supported, build some other type of integration, or simply play around with EnvKey on the command line, envkey-fetch is the library for you. If you just want to integrate EnvKey with your project, check out one of the aforementioned higher level libraries. 8 | 9 | ## Installation 10 | 11 | envkey-fetch compiles into a simple static binary with no dependencies, which makes installation a simple matter of fetching the right binary for your platform and putting it in your `PATH`. An `install.sh` script is available to simplify this, as well as a [homebrew tap](https://github.com/envkey/homebrew-envkey).. 12 | 13 | **Install via bash:** 14 | 15 | ```bash 16 | curl -s https://raw.githubusercontent.com/envkey/envkey-fetch/master/install.sh | bash 17 | ``` 18 | 19 | **Install manually:** 20 | 21 | Find the [release](https://github.com/envkey/envkey-fetch/releases) for your platform and architecture, and stick the appropriate binary somewhere in your `PATH` (or wherever you like really). 22 | 23 | **Install from source:** 24 | 25 | With Go installed, clone the project into your `GOPATH`. `cd` into the directory and run `go get` and `go build`. 26 | 27 | **Cross-compile from source:** 28 | 29 | To compile cross-platform binaries, make sure Go is installed, then install [goreleaser](https://goreleaser.com/) - follow instructions in the docs to do so. 30 | 31 | Then to cross-compile, run: 32 | 33 | `goreleaser` 34 | 35 | Binaries for each platform will be output to the `dist` folder. 36 | 37 | ## Usage 38 | 39 | ```bash 40 | envkey-fetch YOUR-ENVKEY [flags] 41 | ``` 42 | 43 | This will either write your the app environment's configuration associated with your `ENVKEY` as json to stdout or write an error message beginning with `error:` to stdout. 44 | 45 | ### Example json output 46 | 47 | ```json 48 | {"TEST":"it","TEST_2":"works!"} 49 | ``` 50 | 51 | ### Example error output 52 | 53 | ```text 54 | error: ENVKEY invalid 55 | ``` 56 | 57 | ### Flags 58 | 59 | ```text 60 | --cache cache encrypted config as a local backup (default is false) 61 | --cache-dir string cache directory (default is $HOME/.envkey/cache) 62 | --client-name string calling client library name (default is none) 63 | --client-version string calling client library version (default is none) 64 | -h, --help help for envkey-fetch 65 | --retries uint8 number of times to retry requests on failure (default 3) 66 | --retryBackoff float retry backoff factor: {retryBackoff} * (2 ^ {retries - 1}) (default 1) 67 | --timeout float timeout in seconds for http requests (default 10) 68 | --verbose print verbose output (default is false) 69 | -v, --version prints the version 70 | ``` 71 | 72 | ## x509 error / ca-certificates 73 | 74 | On a stripped down OS like Alpine Linux, you may get an `x509: certificate signed by unknown authority` error when `envkey-fetch` attempts to load your config. `envkey-fetch` tries to handle this by including its own set of trusted CAs via [gocertifi](https://github.com/certifi/gocertifi), but if you're getting this error anyway, you can fix it by ensuring that the `ca-certificates` dependency is installed. On Alpine you'll want to run: 75 | ``` 76 | apk add --no-cache ca-certificates 77 | ``` 78 | 79 | ## Further Reading 80 | 81 | For more on EnvKey in general: 82 | 83 | Read the [docs](https://docs.envkey.com). 84 | 85 | Read the [integration quickstart](https://docs.envkey.com/integration-quickstart.html). 86 | 87 | Read the [security and cryptography overview](https://security.envkey.com). 88 | 89 | ## Need help? Have questions, feedback, or ideas? 90 | 91 | Post an [issue](https://github.com/envkey/envkey-fetch/issues) or email us: [support@envkey.com](mailto:support@envkey.com). 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_linux_arm64/envkey-fetch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envkey/envkey-ruby/0ebecfd9b8daa91d7e607c5684dd628a25b8ff2f/ext/envkey-fetch_1.2.9_linux_arm64/envkey-fetch -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_windows_amd64/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2021 Envkey Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_windows_amd64/README.md: -------------------------------------------------------------------------------- 1 | # envkey-fetch 2 | 3 | This library contains [EnvKey](https://www.envkey.com)'s core cross-platform fetching, decryption, verification, web of trust, redundancy, and caching logic. It accepts an `ENVKEY` generated by the [EnvKey App](https://www.github.com/envkey/envkey-app) and returns decrypted configuration for a specific app environment as json. 4 | 5 | It is used by EnvKey's various Client Libraries, including [envkey-source](https://github.com/envkey/envkey-source) for bash, [envkey-ruby](https://github.com/envkey/envkey-ruby) for Ruby and Rails, [envkey-python](https://github.com/envkey/envkey-python) for Python, [envkey-node](https://github.com/envkey/envkey-node) for Node.js, and [envkeygo](https://github.com/envkey/envkeygo) for Go. 6 | 7 | If you want to build an EnvKey library in a language that isn't yet officially supported, build some other type of integration, or simply play around with EnvKey on the command line, envkey-fetch is the library for you. If you just want to integrate EnvKey with your project, check out one of the aforementioned higher level libraries. 8 | 9 | ## Installation 10 | 11 | envkey-fetch compiles into a simple static binary with no dependencies, which makes installation a simple matter of fetching the right binary for your platform and putting it in your `PATH`. An `install.sh` script is available to simplify this, as well as a [homebrew tap](https://github.com/envkey/homebrew-envkey).. 12 | 13 | **Install via bash:** 14 | 15 | ```bash 16 | curl -s https://raw.githubusercontent.com/envkey/envkey-fetch/master/install.sh | bash 17 | ``` 18 | 19 | **Install manually:** 20 | 21 | Find the [release](https://github.com/envkey/envkey-fetch/releases) for your platform and architecture, and stick the appropriate binary somewhere in your `PATH` (or wherever you like really). 22 | 23 | **Install from source:** 24 | 25 | With Go installed, clone the project into your `GOPATH`. `cd` into the directory and run `go get` and `go build`. 26 | 27 | **Cross-compile from source:** 28 | 29 | To compile cross-platform binaries, make sure Go is installed, then install [goreleaser](https://goreleaser.com/) - follow instructions in the docs to do so. 30 | 31 | Then to cross-compile, run: 32 | 33 | `goreleaser` 34 | 35 | Binaries for each platform will be output to the `dist` folder. 36 | 37 | ## Usage 38 | 39 | ```bash 40 | envkey-fetch YOUR-ENVKEY [flags] 41 | ``` 42 | 43 | This will either write your the app environment's configuration associated with your `ENVKEY` as json to stdout or write an error message beginning with `error:` to stdout. 44 | 45 | ### Example json output 46 | 47 | ```json 48 | {"TEST":"it","TEST_2":"works!"} 49 | ``` 50 | 51 | ### Example error output 52 | 53 | ```text 54 | error: ENVKEY invalid 55 | ``` 56 | 57 | ### Flags 58 | 59 | ```text 60 | --cache cache encrypted config as a local backup (default is false) 61 | --cache-dir string cache directory (default is $HOME/.envkey/cache) 62 | --client-name string calling client library name (default is none) 63 | --client-version string calling client library version (default is none) 64 | -h, --help help for envkey-fetch 65 | --retries uint8 number of times to retry requests on failure (default 3) 66 | --retryBackoff float retry backoff factor: {retryBackoff} * (2 ^ {retries - 1}) (default 1) 67 | --timeout float timeout in seconds for http requests (default 10) 68 | --verbose print verbose output (default is false) 69 | -v, --version prints the version 70 | ``` 71 | 72 | ## x509 error / ca-certificates 73 | 74 | On a stripped down OS like Alpine Linux, you may get an `x509: certificate signed by unknown authority` error when `envkey-fetch` attempts to load your config. `envkey-fetch` tries to handle this by including its own set of trusted CAs via [gocertifi](https://github.com/certifi/gocertifi), but if you're getting this error anyway, you can fix it by ensuring that the `ca-certificates` dependency is installed. On Alpine you'll want to run: 75 | ``` 76 | apk add --no-cache ca-certificates 77 | ``` 78 | 79 | ## Further Reading 80 | 81 | For more on EnvKey in general: 82 | 83 | Read the [docs](https://docs.envkey.com). 84 | 85 | Read the [integration quickstart](https://docs.envkey.com/integration-quickstart.html). 86 | 87 | Read the [security and cryptography overview](https://security.envkey.com). 88 | 89 | ## Need help? Have questions, feedback, or ideas? 90 | 91 | Post an [issue](https://github.com/envkey/envkey-fetch/issues) or email us: [support@envkey.com](mailto:support@envkey.com). 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /ext/envkey-fetch_1.2.9_windows_amd64/envkey-fetch.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envkey/envkey-ruby/0ebecfd9b8daa91d7e607c5684dd628a25b8ff2f/ext/envkey-fetch_1.2.9_windows_amd64/envkey-fetch.exe -------------------------------------------------------------------------------- /lib/envkey.rb: -------------------------------------------------------------------------------- 1 | require "envkey/version" 2 | require "envkey/core" 3 | 4 | Envkey::Core.load_env 5 | 6 | begin 7 | require "envkey/rails" 8 | rescue LoadError 9 | end 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /lib/envkey/core.rb: -------------------------------------------------------------------------------- 1 | require 'dotenv' 2 | require 'set' 3 | require 'json' 4 | require 'envkey/fetch' 5 | 6 | module Envkey::Core 7 | 8 | def self.load_env 9 | original_env = ENV.to_h 10 | dotenv_vars = Dotenv.parse 11 | 12 | overwrite_dotenv_vars = JSON.parse(ENV["__ENVKEY_DOT_ENV_VARS"] || "[]") 13 | overwrite_envkey_vars = JSON.parse(ENV["__ENVKEY_VARS"] || "[]") 14 | 15 | updated_dotenv_vars = dotenv_vars.keys.select do |k| 16 | (overwrite_dotenv_vars.include?(k) || original_env[k] == nil) 17 | end 18 | updated_dotenv_vars.each do |k| 19 | ENV[k] = dotenv_vars[k] 20 | end 21 | 22 | key = ENV["ENVKEY"] 23 | 24 | # handle changed ENVKEY 25 | if key && updated_dotenv_vars.include?("ENVKEY") && key != original_env["ENVKEY"] 26 | overwrite_envkey_vars.each {|var| ENV.delete(var) } 27 | end 28 | 29 | if (key = ENV["ENVKEY"]) 30 | res = Envkey::Fetch.fetch_env(key) 31 | if res && res.gsub("\n","").gsub("\r", "") != "" && !res.start_with?("error:") 32 | envs = JSON.parse(res) 33 | updated_envkey_vars = [] 34 | envs.each do |k,v| 35 | var = k.upcase 36 | if !ENV[var] || overwrite_envkey_vars.include?(var) 37 | updated_envkey_vars << var 38 | ENV[var] = v 39 | end 40 | end 41 | 42 | ENV["__ENVKEY_DOT_ENV_VARS"] = updated_dotenv_vars.to_json 43 | ENV["__ENVKEY_VARS"] = updated_envkey_vars.to_json 44 | 45 | return updated_dotenv_vars, updated_envkey_vars 46 | elsif res.start_with?("error:") 47 | STDERR.puts "envkey-fetch " + res 48 | raise "ENVKEY invalid. Couldn't load vars." 49 | else 50 | raise "ENVKEY invalid. Couldn't load vars." 51 | end 52 | else 53 | raise "ENVKEY missing - must be set as an environment variable or in a gitignored .env file in the root of your project. Go to https://www.envkey.com if you don't know what an ENVKEY is." 54 | end 55 | end 56 | 57 | end 58 | 59 | -------------------------------------------------------------------------------- /lib/envkey/fetch.rb: -------------------------------------------------------------------------------- 1 | require 'envkey/platform' 2 | 3 | module Envkey::Fetch 4 | 5 | def self.fetch_env key 6 | fetch_env_path = Envkey::Platform.fetch_env_path 7 | `#{fetch_env_path} #{key}#{is_dev ? ' --cache' : ''} --client-name envkey-ruby --client-version #{Envkey::VERSION} 2>&1` 8 | end 9 | 10 | def self.is_dev 11 | dev_vals = %w(development test) 12 | dev_vals.include?(ENV["RAILS_ENV"]) || 13 | dev_vals.include?(ENV["RACK_ENV"]) || 14 | (ENV["RAILS_ENV"].nil? && ENV["RACK_ENV"].nil? && File.exist?(".env")) 15 | end 16 | 17 | end -------------------------------------------------------------------------------- /lib/envkey/platform.rb: -------------------------------------------------------------------------------- 1 | module Envkey::Platform 2 | # Normalize the platform OS 3 | OS = case os = RbConfig::CONFIG['host_os'].downcase 4 | when /linux/ 5 | "linux" 6 | when /darwin/ 7 | "darwin" 8 | when /bsd/ 9 | "freebsd" 10 | when /mingw|mswin/ 11 | "windows" 12 | else 13 | "linux" 14 | end 15 | 16 | # Normalize the platform CPU 17 | ARCH = case cpu = RbConfig::CONFIG['host_cpu'].downcase 18 | when /amd64|x86_64/ 19 | "x86_64" 20 | when /i?86|x86|i86pc/ 21 | "x86" 22 | when /ppc|powerpc/ 23 | "powerpc" 24 | when /^arm|^aarch/ 25 | "arm" 26 | else 27 | cpu 28 | end 29 | 30 | def self.platform_part 31 | case OS 32 | when "darwin", "linux", "windows", "freebsd" 33 | OS 34 | else 35 | "linux" 36 | end 37 | end 38 | 39 | def self.arch_part 40 | if (platform_part == "darwin" || platform_part == "linux") && ARCH == "arm" 41 | "arm64" 42 | elsif ARCH == "x86_64" 43 | "amd64" 44 | else 45 | raise "As of 1.3.0, envkey-ruby only supports 64-bit systems. Please use an earlier version for 32-bit support." 46 | end 47 | end 48 | 49 | def self.ext 50 | platform_part == "windows" ? ".exe" : "" 51 | end 52 | 53 | def self.fetch_env_path 54 | File.expand_path("../../ext/#{lib_file_dir}/envkey-fetch#{ext}", File.dirname(__FILE__)) 55 | end 56 | 57 | def self.lib_file_dir 58 | ["envkey-fetch", Envkey::ENVKEY_FETCH_VERSION.to_s, platform_part, arch_part].join("_") 59 | end 60 | 61 | end 62 | -------------------------------------------------------------------------------- /lib/envkey/rails.rb: -------------------------------------------------------------------------------- 1 | require "envkey/core" 2 | require "rails" 3 | 4 | module Envkey 5 | class Railtie < Rails::Railtie 6 | config.before_configuration do 7 | begin 8 | require "spring/commands" 9 | Spring.after_fork do 10 | Envkey::Core.load_env 11 | end 12 | rescue LoadError 13 | end 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /lib/envkey/version.rb: -------------------------------------------------------------------------------- 1 | module Envkey 2 | VERSION = "1.3.2" 3 | ENVKEY_FETCH_VERSION="1.2.9" 4 | end 5 | -------------------------------------------------------------------------------- /spec/envkey_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | require "envkey/version" 3 | require "envkey/core" 4 | 5 | VALID_ENVKEY = "wYv78UmHsfEu6jSqMZrU-3w1kwyF35nRYwsAJ-env-staging.envkey.com" 6 | INVALID_ENVKEY = "Emzt4BE7C23QtsC7gb1z-3NvfNiG1Boy6XH2oinvalid-env-staging.envkey.com" 7 | INVALID_ENVKEY2 = "Emzt4BE7C23QtsC7gb1zinvalid-3NvfNiG1Boy6XH2o-env-staging.envkey.com" 8 | INVALID_ENVKEY3 = "Emzt4BE7C23QtsC7gb1zinvalid-3NvfNiG1Boy6XH2o-localhost:387946" 9 | INVALID_ENVKEY4 = "invalid" 10 | 11 | describe Envkey do 12 | after do 13 | ENV.delete("ENVKEY") 14 | ENV.delete("TEST") 15 | ENV.delete("TEST_2") 16 | ENV.delete("__ENVKEY_DOT_ENV_VARS") 17 | ENV.delete("__ENVKEY_VARS") 18 | end 19 | 20 | it "has a version number" do 21 | expect(Envkey::VERSION).not_to be nil 22 | end 23 | 24 | it "has an envkey-fetch version number" do 25 | expect(Envkey::ENVKEY_FETCH_VERSION).not_to be nil 26 | end 27 | 28 | it "loads and decrypts config with a valid ENVKEY" do 29 | ENV["ENVKEY"] = VALID_ENVKEY 30 | Envkey::Core.load_env 31 | expect(ENV["TEST"]).to eq("it") 32 | expect(ENV["TEST_2"]).to eq("works!") 33 | end 34 | 35 | it "doesn't overwrite existing ENV vars" do 36 | ENV["TEST"] = "otherthing" 37 | ENV["ENVKEY"] = VALID_ENVKEY 38 | Envkey::Core.load_env 39 | expect(ENV["TEST"]).to eq("otherthing") 40 | expect(ENV["TEST_2"]).to eq("works!") 41 | end 42 | 43 | it "does overwrite ENV vars loaded by ENVKEY on subsequent loads, but not pre-existing ENV vars" do 44 | ENV["TEST"] = "otherthing" 45 | ENV["ENVKEY"] = VALID_ENVKEY 46 | Envkey::Core.load_env 47 | ENV["TEST_2"] = "to overwrite" 48 | Envkey::Core.load_env 49 | expect(ENV["TEST"]).to eq("otherthing") 50 | expect(ENV["TEST_2"]).to eq("works!") 51 | end 52 | 53 | it "raises an error with an invalid ENVKEY" do 54 | ENV["ENVKEY"] = INVALID_ENVKEY 55 | expect { Envkey::Core.load_env }.to raise_error(/ENVKEY invalid/) 56 | 57 | ENV["ENVKEY"] = INVALID_ENVKEY2 58 | expect { Envkey::Core.load_env }.to raise_error(/ENVKEY invalid/) 59 | 60 | ENV["ENVKEY"] = INVALID_ENVKEY3 61 | expect { Envkey::Core.load_env }.to raise_error(/ENVKEY invalid/) 62 | 63 | ENV["ENVKEY"] = INVALID_ENVKEY4 64 | expect { Envkey::Core.load_env }.to raise_error(/ENVKEY invalid/) 65 | end 66 | 67 | it "raises an error no ENVKEY set" do 68 | expect { Envkey::Core.load_env }.to raise_error(/ENVKEY missing/) 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) 2 | --------------------------------------------------------------------------------