ez-credentials 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +160 -0
- data/LICENSE.txt +21 -0
- data/README.md +60 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/credentials.gemspec +35 -0
- data/lib/credentials.rb +48 -0
- data/lib/credentials/version.rb +5 -0
- metadata +75 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8b91b27b01b4919fd5942d9fe3891176f6aedcadc7f09e6a3b4efa5cba40e841
|
4
|
+
data.tar.gz: fcbdd44fbb1b470d38634537a696aa698f094ab86374a8397f02201655805291
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0e1637275bf88b2f924f2a420dc155e3f2a00fc13c3aa8e6eed1eb4bdbc0508630bbb5db05599ecc84fc2900d1b7d5491cfc081ba6ebe2f8b22261a62aae0ad4
|
7
|
+
data.tar.gz: 617096be1c0491b50dd731121fdd7e3cb77813e4c9ef42cbb48feee397b1ca3392943ea80b4c51474c19156a997c3e6e1e969880b8f4f1f7c8ba6a2d4e75c2ad
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ez-credentials (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
actioncable (6.1.0)
|
10
|
+
actionpack (= 6.1.0)
|
11
|
+
activesupport (= 6.1.0)
|
12
|
+
nio4r (~> 2.0)
|
13
|
+
websocket-driver (>= 0.6.1)
|
14
|
+
actionmailbox (6.1.0)
|
15
|
+
actionpack (= 6.1.0)
|
16
|
+
activejob (= 6.1.0)
|
17
|
+
activerecord (= 6.1.0)
|
18
|
+
activestorage (= 6.1.0)
|
19
|
+
activesupport (= 6.1.0)
|
20
|
+
mail (>= 2.7.1)
|
21
|
+
actionmailer (6.1.0)
|
22
|
+
actionpack (= 6.1.0)
|
23
|
+
actionview (= 6.1.0)
|
24
|
+
activejob (= 6.1.0)
|
25
|
+
activesupport (= 6.1.0)
|
26
|
+
mail (~> 2.5, >= 2.5.4)
|
27
|
+
rails-dom-testing (~> 2.0)
|
28
|
+
actionpack (6.1.0)
|
29
|
+
actionview (= 6.1.0)
|
30
|
+
activesupport (= 6.1.0)
|
31
|
+
rack (~> 2.0, >= 2.0.9)
|
32
|
+
rack-test (>= 0.6.3)
|
33
|
+
rails-dom-testing (~> 2.0)
|
34
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
35
|
+
actiontext (6.1.0)
|
36
|
+
actionpack (= 6.1.0)
|
37
|
+
activerecord (= 6.1.0)
|
38
|
+
activestorage (= 6.1.0)
|
39
|
+
activesupport (= 6.1.0)
|
40
|
+
nokogiri (>= 1.8.5)
|
41
|
+
actionview (6.1.0)
|
42
|
+
activesupport (= 6.1.0)
|
43
|
+
builder (~> 3.1)
|
44
|
+
erubi (~> 1.4)
|
45
|
+
rails-dom-testing (~> 2.0)
|
46
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
47
|
+
activejob (6.1.0)
|
48
|
+
activesupport (= 6.1.0)
|
49
|
+
globalid (>= 0.3.6)
|
50
|
+
activemodel (6.1.0)
|
51
|
+
activesupport (= 6.1.0)
|
52
|
+
activerecord (6.1.0)
|
53
|
+
activemodel (= 6.1.0)
|
54
|
+
activesupport (= 6.1.0)
|
55
|
+
activestorage (6.1.0)
|
56
|
+
actionpack (= 6.1.0)
|
57
|
+
activejob (= 6.1.0)
|
58
|
+
activerecord (= 6.1.0)
|
59
|
+
activesupport (= 6.1.0)
|
60
|
+
marcel (~> 0.3.1)
|
61
|
+
mimemagic (~> 0.3.2)
|
62
|
+
activesupport (6.1.0)
|
63
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
64
|
+
i18n (>= 1.6, < 2)
|
65
|
+
minitest (>= 5.1)
|
66
|
+
tzinfo (~> 2.0)
|
67
|
+
zeitwerk (~> 2.3)
|
68
|
+
builder (3.2.4)
|
69
|
+
concurrent-ruby (1.1.8)
|
70
|
+
crass (1.0.6)
|
71
|
+
diff-lcs (1.4.4)
|
72
|
+
erubi (1.10.0)
|
73
|
+
globalid (0.4.2)
|
74
|
+
activesupport (>= 4.2.0)
|
75
|
+
i18n (1.8.9)
|
76
|
+
concurrent-ruby (~> 1.0)
|
77
|
+
loofah (2.9.0)
|
78
|
+
crass (~> 1.0.2)
|
79
|
+
nokogiri (>= 1.5.9)
|
80
|
+
mail (2.7.1)
|
81
|
+
mini_mime (>= 0.1.1)
|
82
|
+
marcel (0.3.3)
|
83
|
+
mimemagic (~> 0.3.2)
|
84
|
+
method_source (1.0.0)
|
85
|
+
mimemagic (0.3.6)
|
86
|
+
mini_mime (1.1.0)
|
87
|
+
minitest (5.14.4)
|
88
|
+
nio4r (2.5.7)
|
89
|
+
nokogiri (1.11.2-x86_64-darwin)
|
90
|
+
racc (~> 1.4)
|
91
|
+
racc (1.5.2)
|
92
|
+
rack (2.2.3)
|
93
|
+
rack-test (1.1.0)
|
94
|
+
rack (>= 1.0, < 3)
|
95
|
+
rails (6.1.0)
|
96
|
+
actioncable (= 6.1.0)
|
97
|
+
actionmailbox (= 6.1.0)
|
98
|
+
actionmailer (= 6.1.0)
|
99
|
+
actionpack (= 6.1.0)
|
100
|
+
actiontext (= 6.1.0)
|
101
|
+
actionview (= 6.1.0)
|
102
|
+
activejob (= 6.1.0)
|
103
|
+
activemodel (= 6.1.0)
|
104
|
+
activerecord (= 6.1.0)
|
105
|
+
activestorage (= 6.1.0)
|
106
|
+
activesupport (= 6.1.0)
|
107
|
+
bundler (>= 1.15.0)
|
108
|
+
railties (= 6.1.0)
|
109
|
+
sprockets-rails (>= 2.0.0)
|
110
|
+
rails-dom-testing (2.0.3)
|
111
|
+
activesupport (>= 4.2.0)
|
112
|
+
nokogiri (>= 1.6)
|
113
|
+
rails-html-sanitizer (1.3.0)
|
114
|
+
loofah (~> 2.3)
|
115
|
+
railties (6.1.0)
|
116
|
+
actionpack (= 6.1.0)
|
117
|
+
activesupport (= 6.1.0)
|
118
|
+
method_source
|
119
|
+
rake (>= 0.8.7)
|
120
|
+
thor (~> 1.0)
|
121
|
+
rake (13.0.3)
|
122
|
+
rspec (3.9.0)
|
123
|
+
rspec-core (~> 3.9.0)
|
124
|
+
rspec-expectations (~> 3.9.0)
|
125
|
+
rspec-mocks (~> 3.9.0)
|
126
|
+
rspec-core (3.9.3)
|
127
|
+
rspec-support (~> 3.9.3)
|
128
|
+
rspec-expectations (3.9.4)
|
129
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
130
|
+
rspec-support (~> 3.9.0)
|
131
|
+
rspec-mocks (3.9.1)
|
132
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
133
|
+
rspec-support (~> 3.9.0)
|
134
|
+
rspec-support (3.9.4)
|
135
|
+
sprockets (4.0.2)
|
136
|
+
concurrent-ruby (~> 1.0)
|
137
|
+
rack (> 1, < 3)
|
138
|
+
sprockets-rails (3.2.2)
|
139
|
+
actionpack (>= 4.0)
|
140
|
+
activesupport (>= 4.0)
|
141
|
+
sprockets (>= 3.0.0)
|
142
|
+
thor (1.1.0)
|
143
|
+
tzinfo (2.0.4)
|
144
|
+
concurrent-ruby (~> 1.0)
|
145
|
+
websocket-driver (0.7.3)
|
146
|
+
websocket-extensions (>= 0.1.0)
|
147
|
+
websocket-extensions (0.1.5)
|
148
|
+
zeitwerk (2.4.2)
|
149
|
+
|
150
|
+
PLATFORMS
|
151
|
+
x86_64-darwin-19
|
152
|
+
|
153
|
+
DEPENDENCIES
|
154
|
+
ez-credentials!
|
155
|
+
rails (>= 5.2.1)
|
156
|
+
rake (~> 13.0)
|
157
|
+
rspec (~> 3.0)
|
158
|
+
|
159
|
+
BUNDLED WITH
|
160
|
+
2.2.7
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 jimjoyce
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Credentials
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/credentials`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'credentials'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install credentials
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
This gem assumes you are in a rails application and are using one encrypted credential file with environmnet namespaces, like the example below:
|
25
|
+
|
26
|
+
```yml
|
27
|
+
development:
|
28
|
+
foo:
|
29
|
+
bar: baz
|
30
|
+
test:
|
31
|
+
foo:
|
32
|
+
bar: test-baz
|
33
|
+
staging:
|
34
|
+
foo:
|
35
|
+
bar: staging-baz
|
36
|
+
production:
|
37
|
+
foo:
|
38
|
+
bar: realsecret
|
39
|
+
```
|
40
|
+
|
41
|
+
To access credentials in the project for the correct environment, use one of the methods below (the `Credentials` class already takes the environment into account):
|
42
|
+
- `Credentials.get('foo.bar')`
|
43
|
+
- `Credentials.get(:foo, :bar)`
|
44
|
+
- `Credentials.get(:foo)[:bar]`
|
45
|
+
|
46
|
+
---
|
47
|
+
|
48
|
+
## Development
|
49
|
+
|
50
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
51
|
+
|
52
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
Bug reports and pull requests are welcome on BitBucket at https://bitbucket.org/eightbitdevelopers/credentials.
|
57
|
+
|
58
|
+
## License
|
59
|
+
|
60
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "credentials"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/credentials.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/credentials/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "ez-credentials"
|
7
|
+
spec.version = Credentials::VERSION
|
8
|
+
spec.authors = ["jimjoyce"]
|
9
|
+
spec.email = ["j.joyce92@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "A simple wrapper around Rails encrypted credentials"
|
12
|
+
spec.description = "A wrapper for encrypted credentials to return enivronment namepsaced credentials"
|
13
|
+
spec.homepage = "https://bitbucket.org/eightbitdevelopers/credentials"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
16
|
+
|
17
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://bitbucket.org/eightbitdevelopers/credentials"
|
21
|
+
spec.metadata["changelog_uri"] = "https://bitbucket.org/eightbitdevelopers/credentials/src/master/CHANGELOG.md"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
spec.add_development_dependency 'rails', '>= 5.2.1'
|
32
|
+
|
33
|
+
# For more information and examples about making a new gem, checkout our
|
34
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
35
|
+
end
|
data/lib/credentials.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "credentials/version"
|
3
|
+
|
4
|
+
module Credentials
|
5
|
+
class Error < StandardError; end
|
6
|
+
NESTING_DELIMINATOR = '.'
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
def get(*args)
|
11
|
+
keys = get_key_array(args)
|
12
|
+
get_value keys
|
13
|
+
end
|
14
|
+
|
15
|
+
def all
|
16
|
+
secrets
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def get_value(key_ary)
|
22
|
+
secrets.dig(*key_ary)
|
23
|
+
end
|
24
|
+
|
25
|
+
def secrets
|
26
|
+
# TODO: This should be swappable and configurable.
|
27
|
+
Rails.application.credentials[environment.to_sym] || Rails.application.credentials
|
28
|
+
end
|
29
|
+
|
30
|
+
def environment
|
31
|
+
Rails.env || ENV['RAILS_ENV'] || 'development'
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_key_array(args)
|
35
|
+
args.map do |arg|
|
36
|
+
case arg
|
37
|
+
when String
|
38
|
+
arg.split(NESTING_DELIMINATOR)
|
39
|
+
when Array
|
40
|
+
arg
|
41
|
+
when Symbol
|
42
|
+
[arg.to_s]
|
43
|
+
end.map(&:to_sym)
|
44
|
+
end.flatten
|
45
|
+
end
|
46
|
+
|
47
|
+
end # class << self
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ez-credentials
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jimjoyce
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-04-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.2.1
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.2.1
|
27
|
+
description: A wrapper for encrypted credentials to return enivronment namepsaced
|
28
|
+
credentials
|
29
|
+
email:
|
30
|
+
- j.joyce92@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".gitignore"
|
36
|
+
- ".rspec"
|
37
|
+
- CHANGELOG.md
|
38
|
+
- Gemfile
|
39
|
+
- Gemfile.lock
|
40
|
+
- LICENSE.txt
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- bin/console
|
44
|
+
- bin/setup
|
45
|
+
- credentials.gemspec
|
46
|
+
- lib/credentials.rb
|
47
|
+
- lib/credentials/version.rb
|
48
|
+
homepage: https://bitbucket.org/eightbitdevelopers/credentials
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata:
|
52
|
+
allowed_push_host: https://rubygems.org/
|
53
|
+
homepage_uri: https://bitbucket.org/eightbitdevelopers/credentials
|
54
|
+
source_code_uri: https://bitbucket.org/eightbitdevelopers/credentials
|
55
|
+
changelog_uri: https://bitbucket.org/eightbitdevelopers/credentials/src/master/CHANGELOG.md
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 2.4.0
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubygems_version: 3.1.4
|
72
|
+
signing_key:
|
73
|
+
specification_version: 4
|
74
|
+
summary: A simple wrapper around Rails encrypted credentials
|
75
|
+
test_files: []
|