Class: Meroku::Secrets

Inherits:
Object
  • Object
show all
Defined in:
lib/meroku/secrets.rb

Overview

Logic related to api keys, passwords

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cached_aws_access_key_secretObject (readonly)

Returns the value of attribute cached_aws_access_key_secret.



6
7
8
# File 'lib/meroku/secrets.rb', line 6

def cached_aws_access_key_secret
  @cached_aws_access_key_secret
end

#cached_private_keyObject (readonly)

Returns the value of attribute cached_private_key.



6
7
8
# File 'lib/meroku/secrets.rb', line 6

def cached_private_key
  @cached_private_key
end

#meroku_secretObject

Returns the value of attribute meroku_secret.



7
8
9
# File 'lib/meroku/secrets.rb', line 7

def meroku_secret
  @meroku_secret
end

Instance Method Details

#aws_access_keyObject



9
10
11
# File 'lib/meroku/secrets.rb', line 9

def aws_access_key
  'AKIAIRTTOJ2NSX27XWFA'
end

#aws_access_key_secretObject



13
14
15
16
17
# File 'lib/meroku/secrets.rb', line 13

def aws_access_key_secret
  return @cached_aws_access_key_secret if @cached_aws_access_key_secret
  @cached_aws_access_key_secret = download_aws_access_key_secret
  @cached_aws_access_key_secret
end

#download_aws_access_key_secretObject



19
20
21
22
23
24
# File 'lib/meroku/secrets.rb', line 19

def download_aws_access_key_secret
  bucket = "http://s3.amazonaws.com/#{@meroku_secret}/"
  uri = URI("#{bucket}aws_access_key_secret")
  @cached_aws_access_key_secret = Net::HTTP.get(uri).chomp
  @cached_aws_access_key_secret
end

#download_private_keyObject



32
33
34
35
36
# File 'lib/meroku/secrets.rb', line 32

def download_private_key
  uri = URI("http://s3.amazonaws.com/#{@meroku_secret}/meroku.id_rsa")
  @cached_private_key = Net::HTTP.get(uri).chomp
  @cached_private_key
end

#private_keyObject



26
27
28
29
30
# File 'lib/meroku/secrets.rb', line 26

def private_key
  return @cached_private_key if @cached_private_key
  @cached_private_key = download_private_key
  @cached_private_key
end