Class: Himari::Aws::SecretsmanagerSigningKeyProvider::Provider
- Inherits:
-
Object
- Object
- Himari::Aws::SecretsmanagerSigningKeyProvider::Provider
- Defined in:
- lib/himari/aws/secretsmanager_signing_key_provider.rb
Instance Method Summary collapse
- #collect(id: nil, active: nil, group: nil, **_remainder) ⇒ Object
-
#initialize(client: ::Aws::SecretsManager::Client.new, secret_id:, group: nil, kid_prefix:) ⇒ Provider
constructor
A new instance of Provider.
Constructor Details
#initialize(client: ::Aws::SecretsManager::Client.new, secret_id:, group: nil, kid_prefix:) ⇒ Provider
Returns a new instance of Provider.
20 21 22 23 24 25 |
# File 'lib/himari/aws/secretsmanager_signing_key_provider.rb', line 20 def initialize(client: ::Aws::SecretsManager::Client.new, secret_id:, group: nil, kid_prefix:) @client = client @secret_id = secret_id @group = group @kid_prefix = kid_prefix end |
Instance Method Details
#collect(id: nil, active: nil, group: nil, **_remainder) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/himari/aws/secretsmanager_signing_key_provider.rb', line 27 def collect(id: nil, active: nil, group: nil, **_remainder) return [] if group && group != @group case when id return [] unless id.start_with?("#{@kid_prefix}_") version_id = id[(@kid_prefix.size+1)..-1] || '' [secret_value_to_signing_key(@client.get_secret_value(secret_id: @secret_id, version_id: version_id))].compact when active [secret_value_to_signing_key(@client.get_secret_value(secret_id: @secret_id, version_stage: 'AWSCURRENT'))].compact else values = @client.describe_secret(secret_id: @secret_id) .then { |secret| [secret, secret.version_ids_to_stages.keys] } .then { |(secret, versions)| versions.map { |v| @client.get_secret_value(secret_id: secret.arn, version_id: v) } } values.map { |v| secret_value_to_signing_key(v) }.compact end rescue ::Aws::SecretsManager::Errors::ResourceNotFoundException [] end |