dry-credentials 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +7 -0
- data/README.md +105 -0
- data/lib/dry/credentials/extension.rb +8 -0
- data/lib/dry/credentials/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +27 -15
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d4a73f1a9d55f7e32296e39d78e7ff5a6273226c25d10e97b0d2a10b9a00f1c
|
4
|
+
data.tar.gz: 56f39f76baf2a18dbc4bf163d5d12697687a2a026fcc9d01f6b632fef7dcf633
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caac2559ad90fadce9f4b56923d556687d8da8c54eaf16de502e5c2598c10fbb49c57ef5acf8bbe7aaf87434e17bf66d816b25a2cd282ab920b1da5e45b25a21
|
7
|
+
data.tar.gz: a443919baad7138e75beedb23709a45526a986be9225ff6f4f3456cde71c41d03b220de32c6e27ab489839f35d5e467b54a9531f075c1cea80b41f4d64a25dd1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -37,6 +37,8 @@ And then install the bundle:
|
|
37
37
|
bundle install --trust-policy MediumSecurity
|
38
38
|
```
|
39
39
|
|
40
|
+
See [Integrations](#integrations) below for how to integrate Dry::Credentials into frameworks.
|
41
|
+
|
40
42
|
## Usage
|
41
43
|
|
42
44
|
Extend any class with `Dry::Credentials` to use the [default settings](#defaults):
|
@@ -154,6 +156,109 @@ Setting | Default | Description
|
|
154
156
|
`digest` | `"sha256"` | sign digest used if the cipher doesn't support AEAD
|
155
157
|
`serializer` | `Marshal` | serializer responding to `dump` and `load`
|
156
158
|
|
159
|
+
## Integrations
|
160
|
+
|
161
|
+
### Bridgetown
|
162
|
+
|
163
|
+
The [bridgetown_credentials gem](https://github.com/svoop/bridgetown_credentials) integrates Dry::Credentials into your [Bridgetown](https://www.bridgetownrb.com) site.
|
164
|
+
|
165
|
+
### Hanami 2
|
166
|
+
|
167
|
+
To use credentials in a [Hanami 2](https//hanami.org) app, first add this gem to the gemfile of the app and then create a provider `config/providers/credentials.rb`:
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
# frozen_string_literal: true
|
171
|
+
|
172
|
+
Hanami.app.register_provider :credentials do
|
173
|
+
prepare do
|
174
|
+
require "dry-credentials"
|
175
|
+
|
176
|
+
Dry::Credentials::Extension.new.then do |credentials|
|
177
|
+
credentials[:env] = Hanami.env
|
178
|
+
credentials.load!
|
179
|
+
register "credentials", credentials
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
```
|
184
|
+
|
185
|
+
You might want to add a Rake task `lib/tasks/credentials.rake` as well:
|
186
|
+
|
187
|
+
```ruby
|
188
|
+
namespace :credentials do
|
189
|
+
desc "Edit (or create) the encrypted credentials file"
|
190
|
+
task :edit, [:env] => [:environment] do |_, args|
|
191
|
+
Hanami.app.prepare(:credentials)
|
192
|
+
Hanami.app['credentials'].edit! args[:env]
|
193
|
+
end
|
194
|
+
end
|
195
|
+
```
|
196
|
+
|
197
|
+
(As of Hanami 2.1, you have to [explicitly load such tasks in the Rakefile](https://github.com/hanami/hanami/issues/1375) yourself.)
|
198
|
+
|
199
|
+
You can now create a new credentials file for the development environment:
|
200
|
+
|
201
|
+
```
|
202
|
+
rake credentials:edit
|
203
|
+
```
|
204
|
+
|
205
|
+
This prints the credentials key you have to set in `.env`:
|
206
|
+
|
207
|
+
```
|
208
|
+
DEVELOPMENT_CREDENTIALS_KEY=...
|
209
|
+
```
|
210
|
+
|
211
|
+
The credentials are now available anywhere you inject them:
|
212
|
+
|
213
|
+
```ruby
|
214
|
+
module MyHanamiApp
|
215
|
+
class ApiKeyPrinter
|
216
|
+
include Deps[
|
217
|
+
"credentials"
|
218
|
+
]
|
219
|
+
|
220
|
+
def call
|
221
|
+
puts credentials.api_key
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
```
|
226
|
+
|
227
|
+
You can use the credentials in other providers. Say, you want to pass the [ROM](https://rom-rb.org/) database URL (which contains the connection password) using credentials instead of settings. Simply replace `target["settings"].database_url` with `target["credentials"].database_url` and you're good to go:
|
228
|
+
|
229
|
+
```ruby
|
230
|
+
Hanami.app.register_provider :persistence, namespace: true do
|
231
|
+
prepare do
|
232
|
+
require "rom"
|
233
|
+
|
234
|
+
config = ROM::Configuration.new(:sql, target["credentials"].database_url)
|
235
|
+
|
236
|
+
register "config", config
|
237
|
+
register "db", config.gateways[:default].connection
|
238
|
+
end
|
239
|
+
|
240
|
+
(...)
|
241
|
+
end
|
242
|
+
```
|
243
|
+
|
244
|
+
Finally, if you have trouble using the credentials in slices, you might have to [share this app component](https://www.rubydoc.info/gems/hanami/Hanami/Config#shared_app_component_keys-instance_method) in `config/app.rb`:
|
245
|
+
|
246
|
+
```ruby
|
247
|
+
module MyHanamiApp
|
248
|
+
class App < Hanami::App
|
249
|
+
config.shared_app_component_keys += ["credentials"]
|
250
|
+
end
|
251
|
+
end
|
252
|
+
```
|
253
|
+
|
254
|
+
### Ruby on Rails
|
255
|
+
|
256
|
+
ActiveSupport implements [encrypted configuration](https://www.rubydoc.info/gems/activesupport/ActiveSupport/EncryptedConfiguration) which is used by `rails credentials:edit` [out of the box]((https://guides.rubyonrails.org/security.html#custom-credentials)). There's no benefit from introducing an additional dependency like Dry::Credentials.
|
257
|
+
|
258
|
+
### Rodbot
|
259
|
+
|
260
|
+
Dry::Credentials is integrated into [Rodbot](https://github.com/svoop/rodbot) out of the box, see [the README for more](https://github.com/svoop/rodbot/blob/main/README.md#credentials).
|
261
|
+
|
157
262
|
## Development
|
158
263
|
|
159
264
|
To install the development dependencies and then run the test suite:
|
@@ -55,6 +55,14 @@ module Dry
|
|
55
55
|
@settings.send(setting)
|
56
56
|
end
|
57
57
|
|
58
|
+
# Change settings
|
59
|
+
#
|
60
|
+
# @param setting [String] name of the setting
|
61
|
+
# @param value [Object] new value of the setting
|
62
|
+
def []=(setting, value)
|
63
|
+
@settings.send(setting, value)
|
64
|
+
end
|
65
|
+
|
58
66
|
end
|
59
67
|
end
|
60
68
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-credentials
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Schwyn
|
@@ -10,27 +10,39 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MIIC+jCCAeKgAwIBAgIBAjANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhydWJ5
|
14
|
+
L0RDPWJpdGNldGVyYS9EQz1jb20wHhcNMjMxMTEwMTgyMzM2WhcNMjQxMTA5MTgy
|
15
|
+
MzM2WjAjMSEwHwYDVQQDDBhydWJ5L0RDPWJpdGNldGVyYS9EQz1jb20wggEiMA0G
|
16
16
|
CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDcLg+IHjXYaUlTSU7R235lQKD8ZhEe
|
17
17
|
KMhoGlSUonZ/zo1OT3KXcqTCP1iMX743xYs6upEGALCWWwq+nxvlDdnWRjF3AAv7
|
18
18
|
ikC+Z2BEowjyeCCT/0gvn4ohKcR0JOzzRaIlFUVInlGSAHx2QHZ2N8ntf54lu7nd
|
19
19
|
L8CiDK8rClsY4JBNGOgH9UC81f+m61UUQuTLxyM2CXfAYkj/sGNTvFRJcNX+nfdC
|
20
20
|
hM9r2kH1+7wsa8yG7wJ2IkrzNACD8v84oE6qVusN8OLEMUI/NaEPVPbw2LUM149H
|
21
21
|
PVa0i729A4IhroNnFNmw4wOC93ARNbM1+LW36PLMmKjKudf5Exg8VmDVAgMBAAGj
|
22
|
-
|
23
|
-
yoX/
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
kAyiRqgxF4dJviwtqI7mZIomWL63+kXLgjOjMe1SHxfIPo/0ji6+r1p4KYa7o41v
|
30
|
-
fwIwU1MKlFBdsjkd
|
22
|
+
OTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBSfK8MtR62mQ6oN
|
23
|
+
yoX/VKJzFjLSVDANBgkqhkiG9w0BAQsFAAOCAQEAXhT/LpMArF3JRcZSRkJDY+dU
|
24
|
+
GKCRqOefi2iydqh1yIqXyTA9PGR1w5O6O+WS1FvF+sHCwh8fFjCuStg2L8V2RSeo
|
25
|
+
aDtfZ5s80sL8wRFxg3kek69cBuI6ozU+rf9DaXlMES4i8+zASsdv9Y4a2BsbhEdE
|
26
|
+
9AtuMcWn5a45TOO0S4Q8OuV0v705V38Ow15J2RDRvkFRySt+//8/Vd57XAJxPXU0
|
27
|
+
k/QvZU05f6HMYBrPogJgIzHC/C5N/yeE4BVEuBDn+10Zb1iu3aDk8sd0uMgukCY8
|
28
|
+
TUmlP5A6NeGdeDJIoLgromAKs+nvI7TWzhQq9ODs51XhxgUFRCvBqUTpjTQigw==
|
31
29
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
30
|
+
date: 2024-03-06 00:00:00.000000000 Z
|
33
31
|
dependencies:
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: base64
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - "~>"
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - "~>"
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
34
46
|
- !ruby/object:Gem::Dependency
|
35
47
|
name: debug
|
36
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -203,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
215
|
- !ruby/object:Gem::Version
|
204
216
|
version: '0'
|
205
217
|
requirements: []
|
206
|
-
rubygems_version: 3.
|
218
|
+
rubygems_version: 3.5.6
|
207
219
|
signing_key:
|
208
220
|
specification_version: 4
|
209
221
|
summary: A mixin to use encrypted credentials in your classes
|
metadata.gz.sig
CHANGED
Binary file
|