sekreto 0.1.3 → 0.2.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: ab381faa21b251cd3abadcc6c2d854dac68a4f9af5d2a507b6eb060f67bdd385
4
- data.tar.gz: 97760f0f1a7cecf45bfa98263b3be0a0f7144227f82fbc0eff2fd8e930b97b76
3
+ metadata.gz: 740dfb4e957a3391c16a07fef0e8b2b4a5894c3f024c5ebed9479b04cc07b0a1
4
+ data.tar.gz: 12762eb844417916b3ddd203cd3dc1a890b0e66a263a9fd6bf96602c80d3f2be
5
5
  SHA512:
6
- metadata.gz: 7e68a1eb57ce8c74025391b1856211e3bd1458003bc12f618e1a08bad9f0448ee1f1b8800d8294e20cfd10f82aba8adef0525b3edadbd6316f22cb874aea20f9
7
- data.tar.gz: 7a05fbb69de6d2952fce1477d72daee5601ee6c52c46436b0eeb25aff59fe180375b17b849300c3609f0456deb5f650378dd6cdc6d3960a75c3ec5f45d9260c9
6
+ metadata.gz: bc14a8a054c3d85f7dbe55da4200e1cd675f6dd98f9a3e207ab78f2d84c31bfd8b473bbdddf233afa22ec51765d5855889c83a83f92b946154659405a72bc7f7
7
+ data.tar.gz: 88f2691b301e269b1aba1c410d06f40940cd18e08ea25fc2584670ff80dd81c3500317cd435d7f7d3ca46c6555a6d2e621f9139fc680f6cb638f81e1867b8f91
data/lib/sekreto.rb CHANGED
@@ -6,13 +6,30 @@ require 'sekreto/config'
6
6
 
7
7
  require 'sekreto/railtie' if defined?(Rails)
8
8
 
9
- # Sekreto holds configuration and interface for getting secrets
9
+ # Sekreto allows you to interact with the AWS Secrets Manager to
10
+ # retrieve your secrets from Ruby. This exposes a thin wrapper around
11
+ # the AWS SecretsManager SDK.
10
12
  module Sekreto
11
13
  class << self
14
+ ##
15
+ # Set up the Sekreto gem configuration
16
+ #
17
+ # @yieldreturn [Sekreto::Config]
18
+ #
19
+ # @example Configuring Sekreto
20
+ # Sekreto.setup do |setup|
21
+ # setup.prefix = 'app-prefix'
22
+ # end
12
23
  def setup
13
24
  yield config if block_given?
14
25
  end
15
26
 
27
+ ##
28
+ #
29
+ # Get the value given a secret
30
+ #
31
+ # @param secret_id [String] - The secret ID to get the value for
32
+ # @return [String] - The value of the stored secret
16
33
  def get_value(secret_id)
17
34
  fail 'Not allowed env' unless config.is_allowed_env.call
18
35
  response = secrets_manager.get_secret_value(secret_id: secret_name(secret_id))
@@ -22,11 +39,22 @@ module Sekreto
22
39
  config.fallback_lookup.call(secret_id)
23
40
  end
24
41
 
42
+ ##
43
+ #
44
+ # Get the JSON value of a secret
45
+ #
46
+ # @param secret_id [String] - The secret ID to get the value for
47
+ # @return [Hash] - The parsed JSON value of the secret
25
48
  def get_json_value(secret_id)
26
49
  response = get_value(secret_id)
27
50
  MultiJson.load(response)
28
51
  end
29
52
 
53
+ ##
54
+ #
55
+ # Get the configuration for Sekreto
56
+ #
57
+ # @return [Sekreto::Config] - The configuration
30
58
  def config
31
59
  @config ||= Config.new
32
60
  end
@@ -1,6 +1,8 @@
1
1
  require 'logger'
2
2
 
3
3
  module Sekreto
4
+ ##
5
+ # Config class for setting up Sekreto for usage
4
6
  class Config
5
7
  attr_accessor :prefix
6
8
  attr_accessor :is_allowed_env
@@ -8,6 +10,11 @@ module Sekreto
8
10
  attr_accessor :secrets_manager
9
11
  attr_accessor :logger
10
12
 
13
+ ##
14
+ #
15
+ # Initialize a new Config
16
+ #
17
+ # @return [Sekreto::Config]
11
18
  def initialize
12
19
  @prefix = 'secrets'
13
20
  @is_allowed_env = -> { true }
@@ -1,7 +1,11 @@
1
1
  module Sekreto
2
2
  # Rails Railtie to set up the Sekreto configuration
3
+ #
4
+ # Defaults the secrets Manager to Aws::SecretsManager::Client.new
5
+ # Defaults the prefix to Rails app name and Rails.env e.g. foo-staging
6
+ # Defaults allowed envs to check Rails.env is production or staging
3
7
  class Railtie < ::Rails::Railtie
4
- config.after_initialize do
8
+ config.before_initialize do
5
9
  app_name = ::Rails.application.class.to_s.split('::').first.downcase
6
10
 
7
11
  Sekreto.setup do |setup|
@@ -1,3 +1,3 @@
1
1
  module Sekreto
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
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.1.3
4
+ version: 0.2.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-01 00:00:00.000000000 Z
11
+ date: 2018-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-secretsmanager
@@ -38,26 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rails
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '4.1'
48
- - - "<"
49
- - !ruby/object:Gem::Version
50
- version: '5.3'
51
- type: :runtime
52
- prerelease: false
53
- version_requirements: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: '4.1'
58
- - - "<"
59
- - !ruby/object:Gem::Version
60
- version: '5.3'
61
41
  - !ruby/object:Gem::Dependency
62
42
  name: autocop
63
43
  requirement: !ruby/object:Gem::Requirement
@@ -156,7 +136,21 @@ dependencies:
156
136
  - - "~>"
157
137
  - !ruby/object:Gem::Version
158
138
  version: '1.0'
159
- description: Manage AWS Secrets from Rails
139
+ - !ruby/object:Gem::Dependency
140
+ name: yard
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.9.11
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.9.11
153
+ description: Manage AWS Secrets from Ruby
160
154
  email:
161
155
  - dev@autolist.com
162
156
  executables: []
@@ -193,5 +187,5 @@ rubyforge_project:
193
187
  rubygems_version: 2.7.3
194
188
  signing_key:
195
189
  specification_version: 4
196
- summary: AwsSecretsManager for Rails
190
+ summary: AwsSecretsManager for Ruby
197
191
  test_files: []