sekreto 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 740dfb4e957a3391c16a07fef0e8b2b4a5894c3f024c5ebed9479b04cc07b0a1
4
- data.tar.gz: 12762eb844417916b3ddd203cd3dc1a890b0e66a263a9fd6bf96602c80d3f2be
3
+ metadata.gz: 377252aece33da9b2a4bcb882921a5858d9482113e39a97e30922f951a1240e7
4
+ data.tar.gz: 3edd4cdc85dee0be3d0418004eeddb7d55437feda7a7ea8bbd09b2ab5d1bdb5e
5
5
  SHA512:
6
- metadata.gz: bc14a8a054c3d85f7dbe55da4200e1cd675f6dd98f9a3e207ab78f2d84c31bfd8b473bbdddf233afa22ec51765d5855889c83a83f92b946154659405a72bc7f7
7
- data.tar.gz: 88f2691b301e269b1aba1c410d06f40940cd18e08ea25fc2584670ff80dd81c3500317cd435d7f7d3ca46c6555a6d2e621f9139fc680f6cb638f81e1867b8f91
6
+ metadata.gz: e52439c6b4460510de465501d741d4c2972ecffb75007a4e8a83ceb670fbb7cbf2ecd05897ff228d3b08a2c60aa1bff8c6e5dae356780740fc4c5e90c0b45bab
7
+ data.tar.gz: abe64a6f163be84b3178de0e3e53c1e8187da6e4615f08cebe97695c46b13cef03c75da10ff49db549320c3f21aed373cdc173c5043dfe2a178766cb93620f3a
data/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/sekreto.svg)](https://badge.fury.io/rb/sekreto)
4
4
  [![Build Status](https://travis-ci.org/autolist/sekreto.svg?branch=master)](https://travis-ci.org/autolist/sekreto)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/3f03647e9b305f1626de/maintainability)](https://codeclimate.com/github/autolist/sekreto/maintainability)
6
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/3f03647e9b305f1626de/test_coverage)](https://codeclimate.com/github/autolist/sekreto/test_coverage)
7
+ [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=autolist/sekreto)](https://dependabot.com)
5
8
 
6
9
  Use AWS Secrets Manager from Ruby, with rails support
7
10
 
@@ -79,6 +82,15 @@ puts secret
79
82
  # Output: { some: 'json', data: 'here' }
80
83
  ```
81
84
 
85
+ Getting secrets with a custom prefix. Useful for shared secrets or secrets
86
+ across apps, namespaces, etc.
87
+
88
+ ```ruby
89
+ # Will query for "shared-secrets/MY-SECRET-CONFIG"
90
+ secret = Sekreto.get_json_value('MY-SECRET-CONFIG', 'shared-secrets')
91
+ puts secret
92
+ # Output: { some: 'json', data: 'here' }
93
+ ```
82
94
 
83
95
  ## Development
84
96
 
@@ -88,7 +100,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
88
100
 
89
101
  ## Contributing
90
102
 
91
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sekreto. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
103
+ Bug reports and pull requests are welcome on GitHub at https://github.com/autolist/sekreto. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
92
104
 
93
105
  ## License
94
106
 
@@ -1,3 +1,3 @@
1
1
  module Sekreto
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
data/lib/sekreto.rb CHANGED
@@ -29,11 +29,13 @@ module Sekreto
29
29
  # Get the value given a secret
30
30
  #
31
31
  # @param secret_id [String] - The secret ID to get the value for
32
+ # @param prefix [String] - An optional override of the prefix
32
33
  # @return [String] - The value of the stored secret
33
- def get_value(secret_id)
34
+ def get_value(secret_id, prefix = nil)
34
35
  fail 'Not allowed env' unless config.is_allowed_env.call
35
- response = secrets_manager.get_secret_value(secret_id: secret_name(secret_id))
36
- response.secret_string
36
+ secrets_manager.get_secret_value(
37
+ secret_id: secret_name(secret_id, prefix)
38
+ ).secret_string
37
39
  rescue StandardError => err
38
40
  logger.warn("[Sekreto] Failed to get value!\n#{err}")
39
41
  config.fallback_lookup.call(secret_id)
@@ -44,9 +46,10 @@ module Sekreto
44
46
  # Get the JSON value of a secret
45
47
  #
46
48
  # @param secret_id [String] - The secret ID to get the value for
49
+ # @param prefix [String] - An optional override of the prefix
47
50
  # @return [Hash] - The parsed JSON value of the secret
48
- def get_json_value(secret_id)
49
- response = get_value(secret_id)
51
+ def get_json_value(secret_id, prefix = nil)
52
+ response = get_value(secret_id, prefix)
50
53
  MultiJson.load(response)
51
54
  end
52
55
 
@@ -61,8 +64,9 @@ module Sekreto
61
64
 
62
65
  private
63
66
 
64
- def secret_name(secret_id)
65
- [config.prefix, secret_id].join('/')
67
+ def secret_name(secret_id, prefix = nil)
68
+ prefix ||= config.prefix
69
+ [prefix, secret_id].join('/')
66
70
  end
67
71
 
68
72
  def secrets_manager
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sekreto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Autolist Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-24 00:00:00.000000000 Z
11
+ date: 2018-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-secretsmanager
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '10.0'
89
+ version: '12.3'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '10.0'
96
+ version: '12.3'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '3.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.16.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.16.1
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: stub_env
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -184,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
198
  version: '0'
185
199
  requirements: []
186
200
  rubyforge_project:
187
- rubygems_version: 2.7.3
201
+ rubygems_version: 2.7.6
188
202
  signing_key:
189
203
  specification_version: 4
190
204
  summary: AwsSecretsManager for Ruby