bridgetown_credentials 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +153 -0
- data/bridgetown.automation.rb +7 -0
- data/lib/bridgetown_credentials/bridgetown.rb +14 -0
- data/lib/bridgetown_credentials/commands/credentials.rb +28 -0
- data/lib/bridgetown_credentials/commands.rb +24 -0
- data/lib/bridgetown_credentials/credentials.rb +60 -0
- data/lib/bridgetown_credentials/version.rb +5 -0
- data/lib/bridgetown_credentials.rb +17 -0
- data/spec/fixtures/separated/config/credentials/development.yml.enc +1 -0
- data/spec/fixtures/separated/config/credentials/production.yml.enc +1 -0
- data/spec/fixtures/unified/config/credentials/development.yml.enc +1 -0
- data/spec/fixtures/unified/config/credentials/production.yml.enc +1 -0
- data/spec/fixtures/unified/config/credentials.yml.enc +1 -0
- data/spec/lib/bridgetown_credentials/commands_spec.rb +34 -0
- data/spec/lib/bridgetown_credentials/credentials_spec.rb +83 -0
- data/spec/lib/bridgetown_credentials/version_spec.rb +7 -0
- data/spec/sounds/failure.mp3 +0 -0
- data/spec/sounds/success.mp3 +0 -0
- data/spec/spec_helper.rb +33 -0
- data.tar.gz.sig +0 -0
- metadata +263 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c194e19c7c65a4fa6619ad6fb82bf0b51549ac4f3c4c0540b5bd264ceae12940
|
4
|
+
data.tar.gz: cec0d7a2abbf0bf0c1b3b0e01f1762df1c0b9ece09e05e6aa786c0b714121bb9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f8c198d161e1f41b46788f4aafa6a1f0a2339023b6f5b285b001e221c0ec0812a238c901572f230326e67efbab8480b2c97f8c417572c898fd8cc07d78fc333b
|
7
|
+
data.tar.gz: b812f1fa40bc71ea144219730cdec378f07d3f21457d5b65e7af41d14ea6be63d1710f9893bbe4e5adbc5c0430aefa40787547f07b6b252a3dff4cf541ddf01b
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020-present
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
[![Version](https://img.shields.io/gem/v/bridgetown_credentials.svg?style=flat)](https://rubygems.org/gems/bridgetown_credentials)
|
2
|
+
[![Tests](https://img.shields.io/github/actions/workflow/status/svoop/bridgetown_credentials/test.yml?style=flat&label=tests)](https://github.com/svoop/bridgetown_credentials/actions?workflow=Test)
|
3
|
+
[![Code Climate](https://img.shields.io/codeclimate/maintainability/svoop/bridgetown_credentials.svg?style=flat)](https://codeclimate.com/github/svoop/bridgetown_credentials/)
|
4
|
+
[![Donorbox](https://img.shields.io/badge/donate-on_donorbox-yellow.svg)](https://donorbox.org/bitcetera)
|
5
|
+
|
6
|
+
# Credentials for Bridgetown
|
7
|
+
|
8
|
+
This plugin adds Rails-like encrypted credentials to Bridgetown.
|
9
|
+
|
10
|
+
Credentials like passwords, access tokens and other secrets are often passed to sites each by it's own ENV variable. This is both uncool, non-atomic and therefore unreliable. Use this plugin to store your credentials in encrypted YAML files which you can safely commit to your source code repository. In order to use all of them in Bridgetown, you have to set or pass exactly one ENV variable holding the key to decrypt.
|
11
|
+
|
12
|
+
* [Homepage](https://github.com/svoop/bridgetown_credentials)
|
13
|
+
* [API](https://www.rubydoc.info/gems/bridgetown_credentials)
|
14
|
+
* Author: [Sven Schwyn - Bitcetera](https://bitcetera.com)
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
First add this gem to your bundle:
|
19
|
+
|
20
|
+
```shell
|
21
|
+
$ bundle add bridgetown_credentials
|
22
|
+
```
|
23
|
+
|
24
|
+
Then enable it in `config/initializers.rb`:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
init :bridgetown_credentials
|
28
|
+
```
|
29
|
+
|
30
|
+
For the time being, it's necessary to [require this gem early in the boot process](https://www.bridgetownrb.com/docs/plugins/commands) for the commands to be picked up. Add `config/boot.rb` to your site reading:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
Bundler.setup(:default, Bridgetown.env)
|
34
|
+
require "bridgetown_credentials"
|
35
|
+
```
|
36
|
+
|
37
|
+
For safety, you should exclude key files from the source code repository:
|
38
|
+
|
39
|
+
```shell
|
40
|
+
bin/bridgetown apply "$(bundle info --path bridgetown_credentials)/bridgetown.automation.rb"
|
41
|
+
```
|
42
|
+
|
43
|
+
### Secure Installation
|
44
|
+
|
45
|
+
This gem is [cryptographically signed](https://guides.rubygems.org/security/#using-gems) in order to assure it hasn't been tampered with.
|
46
|
+
|
47
|
+
To install it securely, add the author's public key as a trusted certificate and then install the bundle with the trust policy of your choice:
|
48
|
+
|
49
|
+
```shell
|
50
|
+
gem cert --add <(curl -Ls https://raw.github.com/svoop/bridgetown_credentials/main/certs/svoop.pem)
|
51
|
+
bundle install --trust-policy MediumSecurity
|
52
|
+
```
|
53
|
+
|
54
|
+
## Usage
|
55
|
+
|
56
|
+
### First Time
|
57
|
+
|
58
|
+
Make sure you have set the `EDITOR` variable to your favourite editor and then create a new credentials file:
|
59
|
+
|
60
|
+
```shell
|
61
|
+
echo $EDITOR
|
62
|
+
bin/bridgetown credentials edit
|
63
|
+
```
|
64
|
+
|
65
|
+
You might want to add something along the lines of:
|
66
|
+
|
67
|
+
```yml
|
68
|
+
foo: bar
|
69
|
+
aws:
|
70
|
+
access_key_id: awsXid
|
71
|
+
secret_access_key: awsXsecret
|
72
|
+
google:
|
73
|
+
maps:
|
74
|
+
api_key: goomXkey
|
75
|
+
places:
|
76
|
+
api_key: goopXkey
|
77
|
+
```
|
78
|
+
|
79
|
+
After saving the file, the following new files have been created:
|
80
|
+
|
81
|
+
```
|
82
|
+
config/
|
83
|
+
└─ credentials/
|
84
|
+
├─ development.key
|
85
|
+
└─ development.yml.enc
|
86
|
+
```
|
87
|
+
|
88
|
+
⚠️ Move the `*.key` files to a safe place such as a password manager now! Never check them into the source code repository!
|
89
|
+
|
90
|
+
The credentials you've edited above have been written to `development.yml.enc` and will be available when Bridgetown is in `development` mode.
|
91
|
+
|
92
|
+
To edit the credentials for `production` mode:
|
93
|
+
|
94
|
+
```shell
|
95
|
+
bin/bridgetown credentials edit -e production
|
96
|
+
```
|
97
|
+
|
98
|
+
To edit or use a credentials file from now on, you have to set the corresponding key as an ENV variable. The actual key is the content of the `*.key` file you should have tucked away above.
|
99
|
+
|
100
|
+
```shell
|
101
|
+
export BRIDGETOWN_DEVELOPMENT_KEY="10aabbccddeeff00112233445566778899"
|
102
|
+
export BRIDGETOWN_PRODUCTION_KEY="20aabbccddeeff00112233445566778899"
|
103
|
+
```
|
104
|
+
|
105
|
+
#### Unified Environments
|
106
|
+
|
107
|
+
If you prefer not to separate credentials between different environments:
|
108
|
+
|
109
|
+
```shell
|
110
|
+
rm config/credentials/production.*
|
111
|
+
mv config/credentials/development.yml config/credentials.yml
|
112
|
+
rmdir config/credentials
|
113
|
+
```
|
114
|
+
|
115
|
+
This simplifies the files to:
|
116
|
+
|
117
|
+
```
|
118
|
+
config/
|
119
|
+
└─ credentials.yml.enc
|
120
|
+
```
|
121
|
+
|
122
|
+
To edit or use this from now on, you have to set:
|
123
|
+
|
124
|
+
|
125
|
+
```shell
|
126
|
+
export BRIDGETOWN_CREDENTIALS_KEY="30aabbccddeeff00112233445566778899"
|
127
|
+
```
|
128
|
+
|
129
|
+
⚠️ If `config/credentials.yml` is present, any other credentials files are ignored.
|
130
|
+
|
131
|
+
### Read
|
132
|
+
|
133
|
+
Throughout the Bridgetown stack, you can now use the credentials as follows:
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
Bridgetown.credentials.foo # => "bar"
|
137
|
+
Bridgetown.credentials.aws[:access_key_id] # => "awsXid"
|
138
|
+
Bridgetown.credentials.google.dig((:maps, :api_key) # => "goomXkey"
|
139
|
+
```
|
140
|
+
|
141
|
+
### Commands
|
142
|
+
|
143
|
+
* `bin/bridgetown credentials edit` – edit the credentials
|
144
|
+
* `bin/bridgetown credentials show` – dump the decrypted credentials to STDOUT
|
145
|
+
|
146
|
+
## Tests
|
147
|
+
|
148
|
+
* `bundle exec rake test` to run the test suite
|
149
|
+
* `script/cibuild` to validate with Rubocop and Minitest together
|
150
|
+
|
151
|
+
## Development
|
152
|
+
|
153
|
+
You're welcome to [submit issues](https://github.com/svoop/bridgetown_credentials/issues) and contribute code by [forking the project and submitting pull requests](https://docs.github.com/en/get-started/quickstart/fork-a-repo).
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BridgetownCredentials
|
4
|
+
module Bridgetown
|
5
|
+
|
6
|
+
def credentials
|
7
|
+
BridgetownCredentials::Credentials.new(
|
8
|
+
root_dir: ::Bridgetown.configuration.root_dir,
|
9
|
+
env: ::Bridgetown.env
|
10
|
+
).credentials
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_all "bridgetown-core/commands/concerns"
|
4
|
+
|
5
|
+
module BridgetownCredentials
|
6
|
+
class Commands
|
7
|
+
class Credentials < Thor
|
8
|
+
Bridgetown::Commands::Registrations.register do
|
9
|
+
desc "credentials <command>", "Work with Rails-like encrypted credentials"
|
10
|
+
subcommand "credentials", Credentials
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "edit", "Edit the credentials"
|
14
|
+
option :environment, aliases: '-e'
|
15
|
+
def edit
|
16
|
+
ENV['BRIDGETOWN_ENV'] = options['environment'] if options['environment']
|
17
|
+
BridgetownCredentials::Commands.new.edit
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "show", "Dump the decrypted credentials to STDOUT"
|
21
|
+
option :environment, aliases: '-e'
|
22
|
+
def show
|
23
|
+
ENV['BRIDGETOWN_ENV'] = options['environment'] if options['environment']
|
24
|
+
BridgetownCredentials::Commands.new.show
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BridgetownCredentials
|
4
|
+
class Commands
|
5
|
+
|
6
|
+
def initialize(root_dir: ::Bridgetown.configuration.root_dir, env: ::Bridgetown.env)
|
7
|
+
@credentials = BridgetownCredentials::Credentials.new(root_dir: root_dir, env: env)
|
8
|
+
end
|
9
|
+
|
10
|
+
def edit
|
11
|
+
tempfile = Tempfile.new('btcs')
|
12
|
+
tempfile.write @credentials.credentials.read
|
13
|
+
tempfile.close
|
14
|
+
system "#{ENV['EDITOR']} #{tempfile.path}"
|
15
|
+
@credentials.credentials.write File.read(tempfile.path)
|
16
|
+
ensure
|
17
|
+
tempfile.unlink
|
18
|
+
end
|
19
|
+
|
20
|
+
def show
|
21
|
+
puts @credentials.credentials.read
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BridgetownCredentials
|
4
|
+
class Credentials
|
5
|
+
|
6
|
+
attr_reader :credentials
|
7
|
+
|
8
|
+
def initialize(root_dir:, env:)
|
9
|
+
@config_path = Pathname(root_dir).join('config') # NOTE: config dir is hardcoded as of bridgetown-1.2
|
10
|
+
@env = env
|
11
|
+
@credentials = credentials_path ? load : create
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def credentials_path
|
17
|
+
[
|
18
|
+
@config_path.join("credentials.yml.enc"),
|
19
|
+
default_credentials_path
|
20
|
+
].find do |path|
|
21
|
+
path.file?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def credentials_env
|
26
|
+
['BRIDGETOWN', credentials_path.basename('.yml.enc'), 'KEY']
|
27
|
+
.join('_')
|
28
|
+
.upcase
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_credentials_path
|
32
|
+
@config_path.join('credentials', "#{@env}.yml.enc")
|
33
|
+
end
|
34
|
+
|
35
|
+
def default_key_path
|
36
|
+
@config_path.join('credentials', "#{@env}.key")
|
37
|
+
end
|
38
|
+
|
39
|
+
def load
|
40
|
+
ActiveSupport::EncryptedConfiguration.new(
|
41
|
+
config_path: credentials_path,
|
42
|
+
env_key: credentials_env,
|
43
|
+
key_path: '---',
|
44
|
+
raise_if_missing_key: true
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def create
|
49
|
+
default_key_path.dirname.mkpath
|
50
|
+
default_key_path.write(ActiveSupport::EncryptedConfiguration.generate_key)
|
51
|
+
ActiveSupport::EncryptedConfiguration.new(
|
52
|
+
config_path: default_credentials_path,
|
53
|
+
env_key: '---',
|
54
|
+
key_path: default_key_path,
|
55
|
+
raise_if_missing_key: false
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bridgetown"
|
4
|
+
|
5
|
+
require 'tempfile'
|
6
|
+
require 'yaml'
|
7
|
+
require "active_support/encrypted_configuration"
|
8
|
+
|
9
|
+
require_relative "bridgetown_credentials/version"
|
10
|
+
require_relative "bridgetown_credentials/credentials"
|
11
|
+
require_relative "bridgetown_credentials/commands"
|
12
|
+
require_relative "bridgetown_credentials/commands/credentials"
|
13
|
+
require_relative "bridgetown_credentials/bridgetown"
|
14
|
+
|
15
|
+
Bridgetown.initializer :bridgetown_credentials do
|
16
|
+
Bridgetown.extend BridgetownCredentials::Bridgetown
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
9i/EtUJt1efCi00JI8zjhF0NLObmkgZYdz1AybNHLKc4Hr8=--TpvEzWdBo9BDIehP--58KgR6zZPV7ji2Ej4LKwtg==
|
@@ -0,0 +1 @@
|
|
1
|
+
S5RzJRMyPJ+0/yqQnDxSZ3ZZ6TVM21Uzt5rtj+77Tnkd--vny3NxIG5530Q2Cc--vqccEZ/3Jga3Jbc9G1knSA==
|
@@ -0,0 +1 @@
|
|
1
|
+
9i/EtUJt1efCi00JI8zjhF0NLObmkgZYdz1AybNHLKc4Hr8=--TpvEzWdBo9BDIehP--58KgR6zZPV7ji2Ej4LKwtg==
|
@@ -0,0 +1 @@
|
|
1
|
+
S5RzJRMyPJ+0/yqQnDxSZ3ZZ6TVM21Uzt5rtj+77Tnkd--vny3NxIG5530Q2Cc--vqccEZ/3Jga3Jbc9G1knSA==
|
@@ -0,0 +1 @@
|
|
1
|
+
iEiDBqdV97GT29DWsyuuiHSdPDOZjwwat5mn--Kw4OaG2ueY51rkD7--hwUIAa4Llvp2GoUaz+NPww==
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe BridgetownCredentials::Commands do
|
4
|
+
|
5
|
+
describe :edit do
|
6
|
+
it "generates the necessary files and writes the credentials via EDITOR" do
|
7
|
+
ENV['EDITOR'] = 'echo "foo: bar" >'
|
8
|
+
Dir.mktmpdir do |root_dir|
|
9
|
+
root_dir = Pathname(root_dir)
|
10
|
+
subject = BridgetownCredentials::Commands.new(root_dir: root_dir, env: 'staging')
|
11
|
+
subject.edit
|
12
|
+
ENV['BRIDGETOWN_STAGING_KEY'] = File.read(root_dir.join('config', 'credentials', 'staging.key'))
|
13
|
+
subject = BridgetownCredentials::Commands.new(root_dir: root_dir, env: 'staging')
|
14
|
+
_{ subject.show }.must_output "foo: bar\n"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe :show do
|
20
|
+
let :root_dir do
|
21
|
+
fixtures_path.join('separated')
|
22
|
+
end
|
23
|
+
|
24
|
+
subject do
|
25
|
+
ENV['BRIDGETOWN_PRODUCTION_KEY'] = KEYS[:production]
|
26
|
+
BridgetownCredentials::Commands.new(root_dir: root_dir, env: 'production')
|
27
|
+
end
|
28
|
+
|
29
|
+
it "prints the decrypted credentials without leading three dashes line" do
|
30
|
+
_{ subject.show }.must_output "production: PRODUCTION\n"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe BridgetownCredentials::Credentials do
|
4
|
+
context "unified credentials" do
|
5
|
+
let :root_dir do
|
6
|
+
fixtures_path.join('unified')
|
7
|
+
end
|
8
|
+
|
9
|
+
subject do
|
10
|
+
BridgetownCredentials::Credentials.new(root_dir: root_dir, env: 'development')
|
11
|
+
end
|
12
|
+
|
13
|
+
describe :credentials_path do
|
14
|
+
it "always discovers credentials.yml.enc" do
|
15
|
+
_(subject.send(:credentials_path)).must_equal root_dir.join('config', 'credentials.yml.enc')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe :credentials_env do
|
20
|
+
it "always returns BRIDGETOWN_CREDENTIALS_KEY" do
|
21
|
+
_(subject.send(:credentials_env)).must_equal 'BRIDGETOWN_CREDENTIALS_KEY'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe :credentials do
|
26
|
+
it "always decodes credentials.yml.enc" do
|
27
|
+
ENV['BRIDGETOWN_CREDENTIALS_KEY'] = KEYS[:unified]
|
28
|
+
_(subject.credentials).must_be_instance_of ActiveSupport::EncryptedConfiguration
|
29
|
+
end
|
30
|
+
|
31
|
+
it "fails if no key env var is set" do
|
32
|
+
ENV['BRIDGETOWN_CREDENTIALS_KEY'] = nil
|
33
|
+
_{ subject.credentials.config }.must_raise RuntimeError
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "separated credentials" do
|
39
|
+
let :root_dir do
|
40
|
+
fixtures_path.join('separated')
|
41
|
+
end
|
42
|
+
|
43
|
+
subject do
|
44
|
+
BridgetownCredentials::Credentials.new(root_dir: root_dir, env: 'production')
|
45
|
+
end
|
46
|
+
|
47
|
+
describe :credentials_path do
|
48
|
+
it "discovers .yml.enc for the current environment" do
|
49
|
+
_(subject.send(:credentials_path)).must_equal root_dir.join('config', 'credentials', 'production.yml.enc')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe :credentials_env do
|
54
|
+
it "returns the env var key for the current environment" do
|
55
|
+
_(subject.send(:credentials_env)).must_equal 'BRIDGETOWN_PRODUCTION_KEY'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe :credentials do
|
60
|
+
it "decodes .yml.enc for the current environment" do
|
61
|
+
ENV['BRIDGETOWN_PRODUCTION_KEY'] = KEYS[:production]
|
62
|
+
_(subject.credentials).must_be_instance_of ActiveSupport::EncryptedConfiguration
|
63
|
+
end
|
64
|
+
|
65
|
+
it "fails if no key env var is set" do
|
66
|
+
ENV['BRIDGETOWN_PRODUCTION_KEY'] = nil
|
67
|
+
_{ subject.credentials.config }.must_raise RuntimeError
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "new credentials" do
|
73
|
+
describe :initializer do
|
74
|
+
it "generate a key" do
|
75
|
+
Dir.mktmpdir do |root_dir|
|
76
|
+
root_dir = Pathname(root_dir)
|
77
|
+
BridgetownCredentials::Credentials.new(root_dir: root_dir, env: 'foobar')
|
78
|
+
_(root_dir.join('config', 'credentials', 'foobar.key')).path_must_exist
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
Binary file
|
Binary file
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
gem 'minitest'
|
4
|
+
|
5
|
+
require 'bridgetown'
|
6
|
+
Bridgetown::Site.new(Bridgetown.configuration())
|
7
|
+
|
8
|
+
require 'debug'
|
9
|
+
require 'pathname'
|
10
|
+
|
11
|
+
require 'minitest/autorun'
|
12
|
+
require Pathname(__dir__).join('..', 'lib', 'bridgetown_credentials')
|
13
|
+
|
14
|
+
require 'minitest/sound'
|
15
|
+
Minitest::Sound.success = Pathname(__dir__).join('sounds', 'success.mp3').to_s
|
16
|
+
Minitest::Sound.failure = Pathname(__dir__).join('sounds', 'failure.mp3').to_s
|
17
|
+
|
18
|
+
require 'minitest/focus'
|
19
|
+
class MiniTest::Spec
|
20
|
+
class << self
|
21
|
+
alias_method :context, :describe
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def fixtures_path
|
26
|
+
Pathname(__dir__).join('fixtures')
|
27
|
+
end
|
28
|
+
|
29
|
+
KEYS = {
|
30
|
+
unified: '4f9ab3ef4bddd3ad6d01886b6ffff49c',
|
31
|
+
development: 'e4af0afc87c885a430afa3c9691d8bf4',
|
32
|
+
production: '5f1380543df0a4c839324619e0acf0bf'
|
33
|
+
}
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,263 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bridgetown_credentials
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sven Schwyn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDODCCAiCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhydWJ5
|
14
|
+
L0RDPWJpdGNldGVyYS9EQz1jb20wHhcNMjIxMTA2MTIzNjUwWhcNMjMxMTA2MTIz
|
15
|
+
NjUwWjAjMSEwHwYDVQQDDBhydWJ5L0RDPWJpdGNldGVyYS9EQz1jb20wggEiMA0G
|
16
|
+
CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDcLg+IHjXYaUlTSU7R235lQKD8ZhEe
|
17
|
+
KMhoGlSUonZ/zo1OT3KXcqTCP1iMX743xYs6upEGALCWWwq+nxvlDdnWRjF3AAv7
|
18
|
+
ikC+Z2BEowjyeCCT/0gvn4ohKcR0JOzzRaIlFUVInlGSAHx2QHZ2N8ntf54lu7nd
|
19
|
+
L8CiDK8rClsY4JBNGOgH9UC81f+m61UUQuTLxyM2CXfAYkj/sGNTvFRJcNX+nfdC
|
20
|
+
hM9r2kH1+7wsa8yG7wJ2IkrzNACD8v84oE6qVusN8OLEMUI/NaEPVPbw2LUM149H
|
21
|
+
PVa0i729A4IhroNnFNmw4wOC93ARNbM1+LW36PLMmKjKudf5Exg8VmDVAgMBAAGj
|
22
|
+
dzB1MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBSfK8MtR62mQ6oN
|
23
|
+
yoX/VKJzFjLSVDAdBgNVHREEFjAUgRJydWJ5QGJpdGNldGVyYS5jb20wHQYDVR0S
|
24
|
+
BBYwFIEScnVieUBiaXRjZXRlcmEuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQAYG2na
|
25
|
+
ye8OE2DANQIFM/xDos/E4DaPWCJjX5xvFKNKHMCeQYPeZvLICCwyw2paE7Otwk6p
|
26
|
+
uvbg2Ks5ykXsbk5i6vxDoeeOLvmxCqI6m+tHb8v7VZtmwRJm8so0eSX0WvTaKnIf
|
27
|
+
CAn1bVUggczVdNoBXw9WAILKyw9bvh3Ft740XZrR74sd+m2pGwjCaM8hzLvrVbGP
|
28
|
+
DyYhlBeRWyQKQ0WDIsiTSRhzK8HwSTUWjvPwx7SEdIU/HZgyrk0ETObKPakVu6bH
|
29
|
+
kAyiRqgxF4dJviwtqI7mZIomWL63+kXLgjOjMe1SHxfIPo/0ji6+r1p4KYa7o41v
|
30
|
+
fwIwU1MKlFBdsjkd
|
31
|
+
-----END CERTIFICATE-----
|
32
|
+
date: 2022-12-29 00:00:00.000000000 Z
|
33
|
+
dependencies:
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: bridgetown
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.2.0.beta4
|
41
|
+
- - "<"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - '='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 1.2.0.beta4
|
51
|
+
- - "<"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.0'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: activesupport
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '7'
|
61
|
+
type: :runtime
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '7'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: debug
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: rake
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: minitest
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: minitest-sound
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
type: :development
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: minitest-focus
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
type: :development
|
132
|
+
prerelease: false
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
- !ruby/object:Gem::Dependency
|
139
|
+
name: guard
|
140
|
+
requirement: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
type: :development
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
- !ruby/object:Gem::Dependency
|
153
|
+
name: guard-minitest
|
154
|
+
requirement: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
type: :development
|
160
|
+
prerelease: false
|
161
|
+
version_requirements: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
- !ruby/object:Gem::Dependency
|
167
|
+
name: yard
|
168
|
+
requirement: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
type: :development
|
174
|
+
prerelease: false
|
175
|
+
version_requirements: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
description: |
|
181
|
+
Credentials like passwords, access tokens and other secrets are often passed
|
182
|
+
to sites each by it's own ENV variable. This is both uncool, non-atomic and
|
183
|
+
therefore unreliable. Use this plugin to store your credentials in encrypted
|
184
|
+
YAML files which you can safely commit to your source code repository. In
|
185
|
+
order to use all of them in Bridgetown, you have to set or pass exactly one
|
186
|
+
ENV variable holding the key to decrypt.
|
187
|
+
email:
|
188
|
+
- ruby@bitcetera.com
|
189
|
+
executables: []
|
190
|
+
extensions: []
|
191
|
+
extra_rdoc_files:
|
192
|
+
- README.md
|
193
|
+
- CHANGELOG.md
|
194
|
+
- LICENSE.txt
|
195
|
+
files:
|
196
|
+
- CHANGELOG.md
|
197
|
+
- LICENSE.txt
|
198
|
+
- README.md
|
199
|
+
- bridgetown.automation.rb
|
200
|
+
- lib/bridgetown_credentials.rb
|
201
|
+
- lib/bridgetown_credentials/bridgetown.rb
|
202
|
+
- lib/bridgetown_credentials/commands.rb
|
203
|
+
- lib/bridgetown_credentials/commands/credentials.rb
|
204
|
+
- lib/bridgetown_credentials/credentials.rb
|
205
|
+
- lib/bridgetown_credentials/version.rb
|
206
|
+
- spec/fixtures/separated/config/credentials/development.yml.enc
|
207
|
+
- spec/fixtures/separated/config/credentials/production.yml.enc
|
208
|
+
- spec/fixtures/unified/config/credentials.yml.enc
|
209
|
+
- spec/fixtures/unified/config/credentials/development.yml.enc
|
210
|
+
- spec/fixtures/unified/config/credentials/production.yml.enc
|
211
|
+
- spec/lib/bridgetown_credentials/commands_spec.rb
|
212
|
+
- spec/lib/bridgetown_credentials/credentials_spec.rb
|
213
|
+
- spec/lib/bridgetown_credentials/version_spec.rb
|
214
|
+
- spec/sounds/failure.mp3
|
215
|
+
- spec/sounds/success.mp3
|
216
|
+
- spec/spec_helper.rb
|
217
|
+
homepage: https://github.com/svoop/bridgetown_credentials
|
218
|
+
licenses:
|
219
|
+
- MIT
|
220
|
+
metadata:
|
221
|
+
homepage_uri: https://github.com/svoop/bridgetown_credentials
|
222
|
+
changelog_uri: https://github.com/svoop/bridgetown_credentials/blob/main/CHANGELOG.md
|
223
|
+
source_code_uri: https://github.com/svoop/bridgetown_credentials
|
224
|
+
documentation_uri: https://www.rubydoc.info/gems/bridgetown_credentials
|
225
|
+
bug_tracker_uri: https://github.com/svoop/bridgetown_credentials/issues
|
226
|
+
post_install_message:
|
227
|
+
rdoc_options:
|
228
|
+
- "--title"
|
229
|
+
- Credentials for Bridgetown
|
230
|
+
- "--main"
|
231
|
+
- README.md
|
232
|
+
- "--line-numbers"
|
233
|
+
- "--inline-source"
|
234
|
+
- "--quiet"
|
235
|
+
require_paths:
|
236
|
+
- lib
|
237
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
238
|
+
requirements:
|
239
|
+
- - ">="
|
240
|
+
- !ruby/object:Gem::Version
|
241
|
+
version: 3.0.0
|
242
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
|
+
requirements:
|
244
|
+
- - ">="
|
245
|
+
- !ruby/object:Gem::Version
|
246
|
+
version: '0'
|
247
|
+
requirements: []
|
248
|
+
rubygems_version: 3.4.1
|
249
|
+
signing_key:
|
250
|
+
specification_version: 4
|
251
|
+
summary: Rails-like encrypted credentials for Bridgetown
|
252
|
+
test_files:
|
253
|
+
- spec/fixtures/separated/config/credentials/development.yml.enc
|
254
|
+
- spec/fixtures/separated/config/credentials/production.yml.enc
|
255
|
+
- spec/fixtures/unified/config/credentials/development.yml.enc
|
256
|
+
- spec/fixtures/unified/config/credentials/production.yml.enc
|
257
|
+
- spec/fixtures/unified/config/credentials.yml.enc
|
258
|
+
- spec/lib/bridgetown_credentials/commands_spec.rb
|
259
|
+
- spec/lib/bridgetown_credentials/credentials_spec.rb
|
260
|
+
- spec/lib/bridgetown_credentials/version_spec.rb
|
261
|
+
- spec/sounds/failure.mp3
|
262
|
+
- spec/sounds/success.mp3
|
263
|
+
- spec/spec_helper.rb
|
metadata.gz.sig
ADDED
Binary file
|