envkey 0.1.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +51 -19
- data/envkey.gemspec +1 -3
- data/ext/envkey-fetch_1.0.0_darwin_386/envkey-fetch +0 -0
- data/ext/envkey-fetch_1.0.0_darwin_amd64/envkey-fetch +0 -0
- data/ext/envkey-fetch_1.0.0_freebsd_386/envkey-fetch +0 -0
- data/ext/envkey-fetch_1.0.0_freebsd_amd64/envkey-fetch +0 -0
- data/ext/envkey-fetch_1.0.0_linux_386/envkey-fetch +0 -0
- data/ext/envkey-fetch_1.0.0_linux_amd64/envkey-fetch +0 -0
- data/ext/envkey-fetch_1.0.0_windows_386/envkey-fetch.exe +0 -0
- data/ext/envkey-fetch_1.0.0_windows_amd64/envkey-fetch.exe +0 -0
- data/lib/envkey/core.rb +18 -40
- data/lib/envkey/fetch.rb +16 -0
- data/lib/envkey/platform.rb +45 -24
- data/lib/envkey/version.rb +2 -1
- metadata +12 -35
- data/ext/envkey-darwin-10.6-386.dylib +0 -0
- data/ext/envkey-darwin-10.6-386.h +0 -60
- data/ext/envkey-darwin-10.6-amd64.dylib +0 -0
- data/ext/envkey-darwin-10.6-amd64.h +0 -60
- data/ext/envkey-linux-386.h +0 -60
- data/ext/envkey-linux-386.so +0 -0
- data/ext/envkey-linux-amd64.h +0 -60
- data/ext/envkey-linux-amd64.so +0 -0
- data/ext/envkey-linux-arm-5.h +0 -60
- data/ext/envkey-linux-arm-5.so +0 -0
- data/ext/envkey-linux-arm-6.h +0 -60
- data/ext/envkey-linux-arm-6.so +0 -0
- data/ext/envkey-linux-arm-7.h +0 -60
- data/ext/envkey-linux-arm-7.so +0 -0
- data/ext/envkey-linux-arm64.h +0 -60
- data/ext/envkey-linux-arm64.so +0 -0
- data/ext/envkey.go +0 -90
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0423eb22082c5f775c25c56686eb943f899e6aba
|
4
|
+
data.tar.gz: ac0d7784f49ac0ccc5688b0afa23e35dead9d829
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8963f13406a5ac9fa0e66b924d4680ba4273d2b177b72b2aadf07f68e13b943a1d19633b3c82b6e6ba7deb3ee995fe636fa878f6e558e39749ad908edb5c7a74
|
7
|
+
data.tar.gz: a8a46cf837becd6f9bbd44126dff6b972b8d12ef72522aaeefd00f9128280ee14378a13ee904a251f134e09ed9fbf9683846e6302301c05266e37845993a6032
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2017
|
3
|
+
Copyright (c) 2017 Envkey Inc. <support@envkey.com>
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,41 +1,73 @@
|
|
1
|
-
#
|
1
|
+
# envkey
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
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.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
7
|
+
In your Gemfile:
|
10
8
|
|
11
9
|
```ruby
|
12
|
-
gem 'envkey'
|
10
|
+
gem install 'envkey'
|
13
11
|
```
|
14
12
|
|
15
|
-
|
13
|
+
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.
|
14
|
+
|
15
|
+
```
|
16
|
+
require 'envkey'
|
17
|
+
```
|
16
18
|
|
17
|
-
|
19
|
+
## Usage
|
18
20
|
|
19
|
-
|
21
|
+
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).
|
20
22
|
|
21
|
-
|
23
|
+
Now all your EnvKey variables will be available on `ENV`.
|
22
24
|
|
23
|
-
|
25
|
+
### Errors
|
26
|
+
|
27
|
+
The gem will throw an error if an `ENVKEY` is missing or invalid.
|
28
|
+
|
29
|
+
### Example
|
30
|
+
|
31
|
+
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`.
|
32
|
+
|
33
|
+
In your project's **gitignored** `.env` file:
|
34
|
+
|
35
|
+
```bash
|
36
|
+
# .env
|
37
|
+
ENVKEY=GsL8zC74DWchdpvssa9z-nk7humd7hJmAqNoA
|
38
|
+
```
|
39
|
+
|
40
|
+
In `config/initializers/stripe.rb`:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
Stripe.api_key = ENV.fetch("STRIPE_SECRET_KEY")
|
44
|
+
```
|
45
|
+
|
46
|
+
Now `STRIPE_SECRET_KEY` will stay automatically in sync for all the developers on your team.
|
47
|
+
|
48
|
+
On your servers, set the `ENVKEY` as an environment variable instead of putting it in a `.env` file.
|
49
|
+
|
50
|
+
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.
|
51
|
+
|
52
|
+
### Overriding Vars
|
53
|
+
|
54
|
+
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 read more about this topic in the EnvKey [docs](https://docs.envkey.com/overriding-envkey-variables.html).
|
24
55
|
|
25
|
-
|
56
|
+
### Working Offline
|
26
57
|
|
27
|
-
|
58
|
+
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`
|
28
59
|
|
29
|
-
|
60
|
+
## Further Reading
|
30
61
|
|
31
|
-
|
62
|
+
For more on EnvKey in general:
|
32
63
|
|
33
|
-
|
64
|
+
Read the [docs](https://docs.envkey.com).
|
34
65
|
|
35
|
-
|
66
|
+
Read the [integration quickstart](https://docs.envkey.com/integration-quickstart.html).
|
36
67
|
|
68
|
+
Read the [security and cryptography overview](https://security.envkey.com).
|
37
69
|
|
38
|
-
##
|
70
|
+
## Need help? Have questions, feedback, or ideas?
|
39
71
|
|
40
|
-
|
72
|
+
Post an [issue](https://github.com/envkey/envkey-ruby/issues) or email us: [support@envkey.com](mailto:support@envkey.com).
|
41
73
|
|
data/envkey.gemspec
CHANGED
@@ -9,8 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Dane Schneider"]
|
10
10
|
spec.email = ["dane@envkey.com"]
|
11
11
|
|
12
|
-
spec.summary = "Envkey secures and simplifies app secrets and config
|
13
|
-
# spec.description = ""#%q{TODO: Write a longer description or delete this line.}
|
12
|
+
spec.summary = "Envkey secures and simplifies app secrets and config."
|
14
13
|
spec.homepage = "https://www.envkey.com"
|
15
14
|
spec.license = "MIT"
|
16
15
|
|
@@ -34,6 +33,5 @@ Gem::Specification.new do |spec|
|
|
34
33
|
spec.add_development_dependency "rake", "~> 10.0"
|
35
34
|
spec.add_development_dependency "rspec", "~> 3.0"
|
36
35
|
|
37
|
-
spec.add_runtime_dependency "ffi", "~> 1.9"
|
38
36
|
spec.add_runtime_dependency "dotenv", "~> 2.0"
|
39
37
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/envkey/core.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
require 'ffi'
|
2
1
|
require 'dotenv'
|
3
|
-
require 'json'
|
4
2
|
require 'set'
|
5
|
-
require '
|
3
|
+
require 'json'
|
4
|
+
require 'envkey/fetch'
|
6
5
|
|
7
6
|
module Envkey::Core
|
8
|
-
extend FFI::Library
|
9
7
|
|
10
8
|
def self.load_env spring_pre_fork_ts=nil,
|
11
9
|
overload_dotenv_vars=[],
|
@@ -20,46 +18,26 @@ module Envkey::Core
|
|
20
18
|
end
|
21
19
|
|
22
20
|
if (key = ENV["ENVKEY"])
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
raise "There was a problem loading Envkey on your platform."
|
33
|
-
end
|
34
|
-
|
35
|
-
json = EnvJson(FFI::MemoryPointer.from_string(key))
|
36
|
-
|
37
|
-
writer.puts json
|
38
|
-
end
|
39
|
-
|
40
|
-
writer.close
|
41
|
-
while json = reader.gets
|
42
|
-
if json && json.gsub("\n","").gsub("\r", "") != ""
|
43
|
-
envs = JSON.parse(json)
|
44
|
-
updated_envkey_vars = []
|
45
|
-
envs.each do |k,v|
|
46
|
-
var = k.upcase
|
47
|
-
if !ENV[var] || overload_envkey_vars.include?(var)
|
48
|
-
updated_envkey_vars << var
|
49
|
-
ENV[var] = v
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# avoid printing success message twice in quick succession when using spring
|
54
|
-
if !spring_pre_fork_ts || (Time.now - spring_pre_fork_ts) > 3
|
55
|
-
puts "ENVKEY: vars loaded and decrypted - access with ENV['YOUR_VAR_NAME']"
|
21
|
+
res = Envkey::Fetch.fetch_env(key)
|
22
|
+
if res && res.gsub("\n","").gsub("\r", "") != "" && !res.start_with?("error:")
|
23
|
+
envs = JSON.parse(res)
|
24
|
+
updated_envkey_vars = []
|
25
|
+
envs.each do |k,v|
|
26
|
+
var = k.upcase
|
27
|
+
if !ENV[var] || overload_envkey_vars.include?(var)
|
28
|
+
updated_envkey_vars << var
|
29
|
+
ENV[var] = v
|
56
30
|
end
|
57
|
-
return [Set.new(updated_dotenv_vars), Set.new(updated_envkey_vars)]
|
58
|
-
else
|
59
|
-
raise "Envkey invalid. Couldn't load vars."
|
60
31
|
end
|
32
|
+
|
33
|
+
return [Set.new(updated_dotenv_vars), Set.new(updated_envkey_vars)]
|
34
|
+
else
|
35
|
+
raise "ENVKEY invalid. Couldn't load vars."
|
61
36
|
end
|
37
|
+
else
|
38
|
+
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."
|
62
39
|
end
|
63
40
|
end
|
41
|
+
|
64
42
|
end
|
65
43
|
|
data/lib/envkey/fetch.rb
ADDED
@@ -0,0 +1,16 @@
|
|
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' : ''}`
|
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
|
+
end
|
15
|
+
|
16
|
+
end
|
data/lib/envkey/platform.rb
CHANGED
@@ -1,34 +1,55 @@
|
|
1
1
|
module Envkey::Platform
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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"
|
7
14
|
end
|
8
15
|
|
9
|
-
|
10
|
-
|
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/
|
25
|
+
"arm"
|
26
|
+
else
|
27
|
+
cpu
|
28
|
+
end
|
11
29
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
if arch == "x86_64"
|
17
|
-
["darwin-10.6-amd64"]
|
18
|
-
else
|
19
|
-
["darwin-10.6-386"]
|
20
|
-
end
|
30
|
+
def self.platform_part
|
31
|
+
case OS
|
32
|
+
when "darwin", "linux", "windows", "freebsd"
|
33
|
+
OS
|
21
34
|
else
|
22
|
-
|
23
|
-
["linux-amd64", "linux-arm64"]
|
24
|
-
elsif arch == "i386"
|
25
|
-
["linux-386"]
|
26
|
-
else
|
27
|
-
%w(arm64 arm-7 arm-6 arm-5).map {|s| "linux-#{s}"}
|
28
|
-
end
|
35
|
+
"linux"
|
29
36
|
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.arch_part
|
40
|
+
ARCH == "x86_64" ? "amd64" : "386"
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.ext
|
44
|
+
platform_part == "windows" ? ".exe" : ""
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.fetch_env_path
|
48
|
+
File.expand_path("../../ext/#{lib_file_dir}/envkey-fetch#{ext}", File.dirname(__FILE__))
|
49
|
+
end
|
30
50
|
|
31
|
-
|
51
|
+
def self.lib_file_dir
|
52
|
+
["envkey-fetch", Envkey::ENVKEY_FETCH_VERSION.to_s, platform_part, arch_part].join("_")
|
32
53
|
end
|
33
54
|
|
34
55
|
end
|
data/lib/envkey/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: envkey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dane Schneider
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: ffi
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.9'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.9'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: dotenv
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,25 +83,17 @@ files:
|
|
97
83
|
- bin/console
|
98
84
|
- bin/setup
|
99
85
|
- envkey.gemspec
|
100
|
-
- ext/envkey-
|
101
|
-
- ext/envkey-
|
102
|
-
- ext/envkey-
|
103
|
-
- ext/envkey-
|
104
|
-
- ext/envkey-
|
105
|
-
- ext/envkey-
|
106
|
-
- ext/envkey-
|
107
|
-
- ext/envkey-
|
108
|
-
- ext/envkey-linux-arm-5.h
|
109
|
-
- ext/envkey-linux-arm-5.so
|
110
|
-
- ext/envkey-linux-arm-6.h
|
111
|
-
- ext/envkey-linux-arm-6.so
|
112
|
-
- ext/envkey-linux-arm-7.h
|
113
|
-
- ext/envkey-linux-arm-7.so
|
114
|
-
- ext/envkey-linux-arm64.h
|
115
|
-
- ext/envkey-linux-arm64.so
|
116
|
-
- ext/envkey.go
|
86
|
+
- ext/envkey-fetch_1.0.0_darwin_386/envkey-fetch
|
87
|
+
- ext/envkey-fetch_1.0.0_darwin_amd64/envkey-fetch
|
88
|
+
- ext/envkey-fetch_1.0.0_freebsd_386/envkey-fetch
|
89
|
+
- ext/envkey-fetch_1.0.0_freebsd_amd64/envkey-fetch
|
90
|
+
- ext/envkey-fetch_1.0.0_linux_386/envkey-fetch
|
91
|
+
- ext/envkey-fetch_1.0.0_linux_amd64/envkey-fetch
|
92
|
+
- ext/envkey-fetch_1.0.0_windows_386/envkey-fetch.exe
|
93
|
+
- ext/envkey-fetch_1.0.0_windows_amd64/envkey-fetch.exe
|
117
94
|
- lib/envkey.rb
|
118
95
|
- lib/envkey/core.rb
|
96
|
+
- lib/envkey/fetch.rb
|
119
97
|
- lib/envkey/platform.rb
|
120
98
|
- lib/envkey/rails.rb
|
121
99
|
- lib/envkey/version.rb
|
@@ -143,6 +121,5 @@ rubyforge_project:
|
|
143
121
|
rubygems_version: 2.5.1
|
144
122
|
signing_key:
|
145
123
|
specification_version: 4
|
146
|
-
summary: Envkey secures and simplifies app secrets and config
|
147
|
-
encrypted vault and granting access to developers and servers.
|
124
|
+
summary: Envkey secures and simplifies app secrets and config.
|
148
125
|
test_files: []
|
Binary file
|
@@ -1,60 +0,0 @@
|
|
1
|
-
/* Created by "go tool cgo" - DO NOT EDIT. */
|
2
|
-
|
3
|
-
/* package envkey/envkey-go-shared */
|
4
|
-
|
5
|
-
/* Start of preamble from import "C" comments. */
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
/* End of preamble from import "C" comments. */
|
11
|
-
|
12
|
-
|
13
|
-
/* Start of boilerplate cgo prologue. */
|
14
|
-
#line 1 "cgo-gcc-export-header-prolog"
|
15
|
-
|
16
|
-
#ifndef GO_CGO_PROLOGUE_H
|
17
|
-
#define GO_CGO_PROLOGUE_H
|
18
|
-
|
19
|
-
typedef signed char GoInt8;
|
20
|
-
typedef unsigned char GoUint8;
|
21
|
-
typedef short GoInt16;
|
22
|
-
typedef unsigned short GoUint16;
|
23
|
-
typedef int GoInt32;
|
24
|
-
typedef unsigned int GoUint32;
|
25
|
-
typedef long long GoInt64;
|
26
|
-
typedef unsigned long long GoUint64;
|
27
|
-
typedef GoInt32 GoInt;
|
28
|
-
typedef GoUint32 GoUint;
|
29
|
-
typedef __SIZE_TYPE__ GoUintptr;
|
30
|
-
typedef float GoFloat32;
|
31
|
-
typedef double GoFloat64;
|
32
|
-
typedef float _Complex GoComplex64;
|
33
|
-
typedef double _Complex GoComplex128;
|
34
|
-
|
35
|
-
/*
|
36
|
-
static assertion to make sure the file is being used on architecture
|
37
|
-
at least with matching size of GoInt.
|
38
|
-
*/
|
39
|
-
typedef char _check_for_32_bit_pointer_matching_GoInt[sizeof(void*)==32/8 ? 1:-1];
|
40
|
-
|
41
|
-
typedef struct { const char *p; GoInt n; } GoString;
|
42
|
-
typedef void *GoMap;
|
43
|
-
typedef void *GoChan;
|
44
|
-
typedef struct { void *t; void *v; } GoInterface;
|
45
|
-
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
46
|
-
|
47
|
-
#endif
|
48
|
-
|
49
|
-
/* End of boilerplate cgo prologue. */
|
50
|
-
|
51
|
-
#ifdef __cplusplus
|
52
|
-
extern "C" {
|
53
|
-
#endif
|
54
|
-
|
55
|
-
|
56
|
-
extern char* EnvJson(char* p0);
|
57
|
-
|
58
|
-
#ifdef __cplusplus
|
59
|
-
}
|
60
|
-
#endif
|
Binary file
|
@@ -1,60 +0,0 @@
|
|
1
|
-
/* Created by "go tool cgo" - DO NOT EDIT. */
|
2
|
-
|
3
|
-
/* package envkey/envkey-go-shared */
|
4
|
-
|
5
|
-
/* Start of preamble from import "C" comments. */
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
/* End of preamble from import "C" comments. */
|
11
|
-
|
12
|
-
|
13
|
-
/* Start of boilerplate cgo prologue. */
|
14
|
-
#line 1 "cgo-gcc-export-header-prolog"
|
15
|
-
|
16
|
-
#ifndef GO_CGO_PROLOGUE_H
|
17
|
-
#define GO_CGO_PROLOGUE_H
|
18
|
-
|
19
|
-
typedef signed char GoInt8;
|
20
|
-
typedef unsigned char GoUint8;
|
21
|
-
typedef short GoInt16;
|
22
|
-
typedef unsigned short GoUint16;
|
23
|
-
typedef int GoInt32;
|
24
|
-
typedef unsigned int GoUint32;
|
25
|
-
typedef long long GoInt64;
|
26
|
-
typedef unsigned long long GoUint64;
|
27
|
-
typedef GoInt64 GoInt;
|
28
|
-
typedef GoUint64 GoUint;
|
29
|
-
typedef __SIZE_TYPE__ GoUintptr;
|
30
|
-
typedef float GoFloat32;
|
31
|
-
typedef double GoFloat64;
|
32
|
-
typedef float _Complex GoComplex64;
|
33
|
-
typedef double _Complex GoComplex128;
|
34
|
-
|
35
|
-
/*
|
36
|
-
static assertion to make sure the file is being used on architecture
|
37
|
-
at least with matching size of GoInt.
|
38
|
-
*/
|
39
|
-
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
40
|
-
|
41
|
-
typedef struct { const char *p; GoInt n; } GoString;
|
42
|
-
typedef void *GoMap;
|
43
|
-
typedef void *GoChan;
|
44
|
-
typedef struct { void *t; void *v; } GoInterface;
|
45
|
-
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
46
|
-
|
47
|
-
#endif
|
48
|
-
|
49
|
-
/* End of boilerplate cgo prologue. */
|
50
|
-
|
51
|
-
#ifdef __cplusplus
|
52
|
-
extern "C" {
|
53
|
-
#endif
|
54
|
-
|
55
|
-
|
56
|
-
extern char* EnvJson(char* p0);
|
57
|
-
|
58
|
-
#ifdef __cplusplus
|
59
|
-
}
|
60
|
-
#endif
|
data/ext/envkey-linux-386.h
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
/* Created by "go tool cgo" - DO NOT EDIT. */
|
2
|
-
|
3
|
-
/* package envkey/envkey-go-shared */
|
4
|
-
|
5
|
-
/* Start of preamble from import "C" comments. */
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
/* End of preamble from import "C" comments. */
|
11
|
-
|
12
|
-
|
13
|
-
/* Start of boilerplate cgo prologue. */
|
14
|
-
#line 1 "cgo-gcc-export-header-prolog"
|
15
|
-
|
16
|
-
#ifndef GO_CGO_PROLOGUE_H
|
17
|
-
#define GO_CGO_PROLOGUE_H
|
18
|
-
|
19
|
-
typedef signed char GoInt8;
|
20
|
-
typedef unsigned char GoUint8;
|
21
|
-
typedef short GoInt16;
|
22
|
-
typedef unsigned short GoUint16;
|
23
|
-
typedef int GoInt32;
|
24
|
-
typedef unsigned int GoUint32;
|
25
|
-
typedef long long GoInt64;
|
26
|
-
typedef unsigned long long GoUint64;
|
27
|
-
typedef GoInt32 GoInt;
|
28
|
-
typedef GoUint32 GoUint;
|
29
|
-
typedef __SIZE_TYPE__ GoUintptr;
|
30
|
-
typedef float GoFloat32;
|
31
|
-
typedef double GoFloat64;
|
32
|
-
typedef float _Complex GoComplex64;
|
33
|
-
typedef double _Complex GoComplex128;
|
34
|
-
|
35
|
-
/*
|
36
|
-
static assertion to make sure the file is being used on architecture
|
37
|
-
at least with matching size of GoInt.
|
38
|
-
*/
|
39
|
-
typedef char _check_for_32_bit_pointer_matching_GoInt[sizeof(void*)==32/8 ? 1:-1];
|
40
|
-
|
41
|
-
typedef struct { const char *p; GoInt n; } GoString;
|
42
|
-
typedef void *GoMap;
|
43
|
-
typedef void *GoChan;
|
44
|
-
typedef struct { void *t; void *v; } GoInterface;
|
45
|
-
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
46
|
-
|
47
|
-
#endif
|
48
|
-
|
49
|
-
/* End of boilerplate cgo prologue. */
|
50
|
-
|
51
|
-
#ifdef __cplusplus
|
52
|
-
extern "C" {
|
53
|
-
#endif
|
54
|
-
|
55
|
-
|
56
|
-
extern char* EnvJson(char* p0);
|
57
|
-
|
58
|
-
#ifdef __cplusplus
|
59
|
-
}
|
60
|
-
#endif
|
data/ext/envkey-linux-386.so
DELETED
Binary file
|
data/ext/envkey-linux-amd64.h
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
/* Created by "go tool cgo" - DO NOT EDIT. */
|
2
|
-
|
3
|
-
/* package envkey/envkey-go-shared */
|
4
|
-
|
5
|
-
/* Start of preamble from import "C" comments. */
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
/* End of preamble from import "C" comments. */
|
11
|
-
|
12
|
-
|
13
|
-
/* Start of boilerplate cgo prologue. */
|
14
|
-
#line 1 "cgo-gcc-export-header-prolog"
|
15
|
-
|
16
|
-
#ifndef GO_CGO_PROLOGUE_H
|
17
|
-
#define GO_CGO_PROLOGUE_H
|
18
|
-
|
19
|
-
typedef signed char GoInt8;
|
20
|
-
typedef unsigned char GoUint8;
|
21
|
-
typedef short GoInt16;
|
22
|
-
typedef unsigned short GoUint16;
|
23
|
-
typedef int GoInt32;
|
24
|
-
typedef unsigned int GoUint32;
|
25
|
-
typedef long long GoInt64;
|
26
|
-
typedef unsigned long long GoUint64;
|
27
|
-
typedef GoInt64 GoInt;
|
28
|
-
typedef GoUint64 GoUint;
|
29
|
-
typedef __SIZE_TYPE__ GoUintptr;
|
30
|
-
typedef float GoFloat32;
|
31
|
-
typedef double GoFloat64;
|
32
|
-
typedef float _Complex GoComplex64;
|
33
|
-
typedef double _Complex GoComplex128;
|
34
|
-
|
35
|
-
/*
|
36
|
-
static assertion to make sure the file is being used on architecture
|
37
|
-
at least with matching size of GoInt.
|
38
|
-
*/
|
39
|
-
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
40
|
-
|
41
|
-
typedef struct { const char *p; GoInt n; } GoString;
|
42
|
-
typedef void *GoMap;
|
43
|
-
typedef void *GoChan;
|
44
|
-
typedef struct { void *t; void *v; } GoInterface;
|
45
|
-
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
46
|
-
|
47
|
-
#endif
|
48
|
-
|
49
|
-
/* End of boilerplate cgo prologue. */
|
50
|
-
|
51
|
-
#ifdef __cplusplus
|
52
|
-
extern "C" {
|
53
|
-
#endif
|
54
|
-
|
55
|
-
|
56
|
-
extern char* EnvJson(char* p0);
|
57
|
-
|
58
|
-
#ifdef __cplusplus
|
59
|
-
}
|
60
|
-
#endif
|
data/ext/envkey-linux-amd64.so
DELETED
Binary file
|
data/ext/envkey-linux-arm-5.h
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
/* Created by "go tool cgo" - DO NOT EDIT. */
|
2
|
-
|
3
|
-
/* package envkey/envkey-go-shared */
|
4
|
-
|
5
|
-
/* Start of preamble from import "C" comments. */
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
/* End of preamble from import "C" comments. */
|
11
|
-
|
12
|
-
|
13
|
-
/* Start of boilerplate cgo prologue. */
|
14
|
-
#line 1 "cgo-gcc-export-header-prolog"
|
15
|
-
|
16
|
-
#ifndef GO_CGO_PROLOGUE_H
|
17
|
-
#define GO_CGO_PROLOGUE_H
|
18
|
-
|
19
|
-
typedef signed char GoInt8;
|
20
|
-
typedef unsigned char GoUint8;
|
21
|
-
typedef short GoInt16;
|
22
|
-
typedef unsigned short GoUint16;
|
23
|
-
typedef int GoInt32;
|
24
|
-
typedef unsigned int GoUint32;
|
25
|
-
typedef long long GoInt64;
|
26
|
-
typedef unsigned long long GoUint64;
|
27
|
-
typedef GoInt32 GoInt;
|
28
|
-
typedef GoUint32 GoUint;
|
29
|
-
typedef __SIZE_TYPE__ GoUintptr;
|
30
|
-
typedef float GoFloat32;
|
31
|
-
typedef double GoFloat64;
|
32
|
-
typedef float _Complex GoComplex64;
|
33
|
-
typedef double _Complex GoComplex128;
|
34
|
-
|
35
|
-
/*
|
36
|
-
static assertion to make sure the file is being used on architecture
|
37
|
-
at least with matching size of GoInt.
|
38
|
-
*/
|
39
|
-
typedef char _check_for_32_bit_pointer_matching_GoInt[sizeof(void*)==32/8 ? 1:-1];
|
40
|
-
|
41
|
-
typedef struct { const char *p; GoInt n; } GoString;
|
42
|
-
typedef void *GoMap;
|
43
|
-
typedef void *GoChan;
|
44
|
-
typedef struct { void *t; void *v; } GoInterface;
|
45
|
-
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
46
|
-
|
47
|
-
#endif
|
48
|
-
|
49
|
-
/* End of boilerplate cgo prologue. */
|
50
|
-
|
51
|
-
#ifdef __cplusplus
|
52
|
-
extern "C" {
|
53
|
-
#endif
|
54
|
-
|
55
|
-
|
56
|
-
extern char* EnvJson(char* p0);
|
57
|
-
|
58
|
-
#ifdef __cplusplus
|
59
|
-
}
|
60
|
-
#endif
|
data/ext/envkey-linux-arm-5.so
DELETED
Binary file
|
data/ext/envkey-linux-arm-6.h
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
/* Created by "go tool cgo" - DO NOT EDIT. */
|
2
|
-
|
3
|
-
/* package envkey/envkey-go-shared */
|
4
|
-
|
5
|
-
/* Start of preamble from import "C" comments. */
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
/* End of preamble from import "C" comments. */
|
11
|
-
|
12
|
-
|
13
|
-
/* Start of boilerplate cgo prologue. */
|
14
|
-
#line 1 "cgo-gcc-export-header-prolog"
|
15
|
-
|
16
|
-
#ifndef GO_CGO_PROLOGUE_H
|
17
|
-
#define GO_CGO_PROLOGUE_H
|
18
|
-
|
19
|
-
typedef signed char GoInt8;
|
20
|
-
typedef unsigned char GoUint8;
|
21
|
-
typedef short GoInt16;
|
22
|
-
typedef unsigned short GoUint16;
|
23
|
-
typedef int GoInt32;
|
24
|
-
typedef unsigned int GoUint32;
|
25
|
-
typedef long long GoInt64;
|
26
|
-
typedef unsigned long long GoUint64;
|
27
|
-
typedef GoInt32 GoInt;
|
28
|
-
typedef GoUint32 GoUint;
|
29
|
-
typedef __SIZE_TYPE__ GoUintptr;
|
30
|
-
typedef float GoFloat32;
|
31
|
-
typedef double GoFloat64;
|
32
|
-
typedef float _Complex GoComplex64;
|
33
|
-
typedef double _Complex GoComplex128;
|
34
|
-
|
35
|
-
/*
|
36
|
-
static assertion to make sure the file is being used on architecture
|
37
|
-
at least with matching size of GoInt.
|
38
|
-
*/
|
39
|
-
typedef char _check_for_32_bit_pointer_matching_GoInt[sizeof(void*)==32/8 ? 1:-1];
|
40
|
-
|
41
|
-
typedef struct { const char *p; GoInt n; } GoString;
|
42
|
-
typedef void *GoMap;
|
43
|
-
typedef void *GoChan;
|
44
|
-
typedef struct { void *t; void *v; } GoInterface;
|
45
|
-
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
46
|
-
|
47
|
-
#endif
|
48
|
-
|
49
|
-
/* End of boilerplate cgo prologue. */
|
50
|
-
|
51
|
-
#ifdef __cplusplus
|
52
|
-
extern "C" {
|
53
|
-
#endif
|
54
|
-
|
55
|
-
|
56
|
-
extern char* EnvJson(char* p0);
|
57
|
-
|
58
|
-
#ifdef __cplusplus
|
59
|
-
}
|
60
|
-
#endif
|
data/ext/envkey-linux-arm-6.so
DELETED
Binary file
|
data/ext/envkey-linux-arm-7.h
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
/* Created by "go tool cgo" - DO NOT EDIT. */
|
2
|
-
|
3
|
-
/* package envkey/envkey-go-shared */
|
4
|
-
|
5
|
-
/* Start of preamble from import "C" comments. */
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
/* End of preamble from import "C" comments. */
|
11
|
-
|
12
|
-
|
13
|
-
/* Start of boilerplate cgo prologue. */
|
14
|
-
#line 1 "cgo-gcc-export-header-prolog"
|
15
|
-
|
16
|
-
#ifndef GO_CGO_PROLOGUE_H
|
17
|
-
#define GO_CGO_PROLOGUE_H
|
18
|
-
|
19
|
-
typedef signed char GoInt8;
|
20
|
-
typedef unsigned char GoUint8;
|
21
|
-
typedef short GoInt16;
|
22
|
-
typedef unsigned short GoUint16;
|
23
|
-
typedef int GoInt32;
|
24
|
-
typedef unsigned int GoUint32;
|
25
|
-
typedef long long GoInt64;
|
26
|
-
typedef unsigned long long GoUint64;
|
27
|
-
typedef GoInt32 GoInt;
|
28
|
-
typedef GoUint32 GoUint;
|
29
|
-
typedef __SIZE_TYPE__ GoUintptr;
|
30
|
-
typedef float GoFloat32;
|
31
|
-
typedef double GoFloat64;
|
32
|
-
typedef float _Complex GoComplex64;
|
33
|
-
typedef double _Complex GoComplex128;
|
34
|
-
|
35
|
-
/*
|
36
|
-
static assertion to make sure the file is being used on architecture
|
37
|
-
at least with matching size of GoInt.
|
38
|
-
*/
|
39
|
-
typedef char _check_for_32_bit_pointer_matching_GoInt[sizeof(void*)==32/8 ? 1:-1];
|
40
|
-
|
41
|
-
typedef struct { const char *p; GoInt n; } GoString;
|
42
|
-
typedef void *GoMap;
|
43
|
-
typedef void *GoChan;
|
44
|
-
typedef struct { void *t; void *v; } GoInterface;
|
45
|
-
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
46
|
-
|
47
|
-
#endif
|
48
|
-
|
49
|
-
/* End of boilerplate cgo prologue. */
|
50
|
-
|
51
|
-
#ifdef __cplusplus
|
52
|
-
extern "C" {
|
53
|
-
#endif
|
54
|
-
|
55
|
-
|
56
|
-
extern char* EnvJson(char* p0);
|
57
|
-
|
58
|
-
#ifdef __cplusplus
|
59
|
-
}
|
60
|
-
#endif
|
data/ext/envkey-linux-arm-7.so
DELETED
Binary file
|
data/ext/envkey-linux-arm64.h
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
/* Created by "go tool cgo" - DO NOT EDIT. */
|
2
|
-
|
3
|
-
/* package envkey/envkey-go-shared */
|
4
|
-
|
5
|
-
/* Start of preamble from import "C" comments. */
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
/* End of preamble from import "C" comments. */
|
11
|
-
|
12
|
-
|
13
|
-
/* Start of boilerplate cgo prologue. */
|
14
|
-
#line 1 "cgo-gcc-export-header-prolog"
|
15
|
-
|
16
|
-
#ifndef GO_CGO_PROLOGUE_H
|
17
|
-
#define GO_CGO_PROLOGUE_H
|
18
|
-
|
19
|
-
typedef signed char GoInt8;
|
20
|
-
typedef unsigned char GoUint8;
|
21
|
-
typedef short GoInt16;
|
22
|
-
typedef unsigned short GoUint16;
|
23
|
-
typedef int GoInt32;
|
24
|
-
typedef unsigned int GoUint32;
|
25
|
-
typedef long long GoInt64;
|
26
|
-
typedef unsigned long long GoUint64;
|
27
|
-
typedef GoInt64 GoInt;
|
28
|
-
typedef GoUint64 GoUint;
|
29
|
-
typedef __SIZE_TYPE__ GoUintptr;
|
30
|
-
typedef float GoFloat32;
|
31
|
-
typedef double GoFloat64;
|
32
|
-
typedef float _Complex GoComplex64;
|
33
|
-
typedef double _Complex GoComplex128;
|
34
|
-
|
35
|
-
/*
|
36
|
-
static assertion to make sure the file is being used on architecture
|
37
|
-
at least with matching size of GoInt.
|
38
|
-
*/
|
39
|
-
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
40
|
-
|
41
|
-
typedef struct { const char *p; GoInt n; } GoString;
|
42
|
-
typedef void *GoMap;
|
43
|
-
typedef void *GoChan;
|
44
|
-
typedef struct { void *t; void *v; } GoInterface;
|
45
|
-
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
46
|
-
|
47
|
-
#endif
|
48
|
-
|
49
|
-
/* End of boilerplate cgo prologue. */
|
50
|
-
|
51
|
-
#ifdef __cplusplus
|
52
|
-
extern "C" {
|
53
|
-
#endif
|
54
|
-
|
55
|
-
|
56
|
-
extern char* EnvJson(char* p0);
|
57
|
-
|
58
|
-
#ifdef __cplusplus
|
59
|
-
}
|
60
|
-
#endif
|
data/ext/envkey-linux-arm64.so
DELETED
Binary file
|
data/ext/envkey.go
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
package main
|
2
|
-
|
3
|
-
import (
|
4
|
-
"C"
|
5
|
-
"bytes"
|
6
|
-
"strings"
|
7
|
-
"net/http"
|
8
|
-
"encoding/json"
|
9
|
-
"io/ioutil"
|
10
|
-
"log"
|
11
|
-
"golang.org/x/crypto/openpgp"
|
12
|
-
"golang.org/x/crypto/openpgp/armor"
|
13
|
-
)
|
14
|
-
|
15
|
-
const urlBase = "https://env-service.herokuapp.com/"
|
16
|
-
|
17
|
-
type EnvResponse struct {
|
18
|
-
Env string `json:"env"`
|
19
|
-
EncryptedPrivkey string `json:"encrypted_privkey"`
|
20
|
-
}
|
21
|
-
|
22
|
-
//export EnvJson
|
23
|
-
func EnvJson(envkey *C.char) *C.char {
|
24
|
-
split := strings.Split(C.GoString(envkey), "-")
|
25
|
-
envkeyParam, pw := split[0], split[1]
|
26
|
-
envResponse := new(EnvResponse)
|
27
|
-
var err error
|
28
|
-
err = getJson(urlBase + envkeyParam, envResponse)
|
29
|
-
if (err != nil){
|
30
|
-
return C.CString("")
|
31
|
-
}
|
32
|
-
var decrypted string
|
33
|
-
decrypted, err = decrypt(envResponse.Env, envResponse.EncryptedPrivkey, pw)
|
34
|
-
if (err != nil){
|
35
|
-
return C.CString("")
|
36
|
-
}
|
37
|
-
|
38
|
-
return C.CString(decrypted)
|
39
|
-
}
|
40
|
-
|
41
|
-
func getJson(url string, target interface{}) error {
|
42
|
-
r, err := http.Get(url)
|
43
|
-
if err != nil {
|
44
|
-
log.Fatal(err)
|
45
|
-
return err
|
46
|
-
}
|
47
|
-
defer r.Body.Close()
|
48
|
-
|
49
|
-
return json.NewDecoder(r.Body).Decode(target)
|
50
|
-
}
|
51
|
-
|
52
|
-
func decrypt(cipher, privkey, pw string) (string, error) {
|
53
|
-
// Open the private key file
|
54
|
-
keyringFileBuffer := bytes.NewBufferString(privkey)
|
55
|
-
entityList, err := openpgp.ReadArmoredKeyRing(keyringFileBuffer)
|
56
|
-
if (err != nil){
|
57
|
-
log.Fatal(err)
|
58
|
-
return "", err
|
59
|
-
}
|
60
|
-
entity := entityList[0]
|
61
|
-
|
62
|
-
// Get the passphrase and read the private key.
|
63
|
-
passphraseByte := []byte(pw)
|
64
|
-
entity.PrivateKey.Decrypt(passphraseByte)
|
65
|
-
for _, subkey := range entity.Subkeys {
|
66
|
-
subkey.PrivateKey.Decrypt(passphraseByte)
|
67
|
-
}
|
68
|
-
|
69
|
-
// Decode armored message
|
70
|
-
decbuf := bytes.NewBufferString(cipher)
|
71
|
-
result, err := armor.Decode(decbuf)
|
72
|
-
if err != nil {
|
73
|
-
return "", err
|
74
|
-
}
|
75
|
-
|
76
|
-
// Decrypt it with the contents of the private key
|
77
|
-
md, err := openpgp.ReadMessage(result.Body, entityList, nil, nil)
|
78
|
-
if err != nil {
|
79
|
-
return "", err
|
80
|
-
}
|
81
|
-
|
82
|
-
bytes, err := ioutil.ReadAll(md.UnverifiedBody)
|
83
|
-
if err != nil {
|
84
|
-
return "", err
|
85
|
-
}
|
86
|
-
|
87
|
-
return string(bytes), nil
|
88
|
-
}
|
89
|
-
|
90
|
-
func main() {}
|