Class: Heirloom::Authorizer

Inherits:
Object
  • Object
show all
Includes:
Utils::Email
Defined in:
lib/heirloom/archive/authorizer.rb

Instance Method Summary collapse

Methods included from Utils::Email

#valid_email?

Constructor Details

#initialize(args) ⇒ Authorizer

Returns a new instance of Authorizer.



7
8
9
10
11
12
# File 'lib/heirloom/archive/authorizer.rb', line 7

def initialize(args)
  @config = args[:config]
  @name   = args[:name]
  @id     = args[:id]
  @logger = @config.logger
end

Instance Method Details

#authorize(args) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/heirloom/archive/authorizer.rb', line 14

def authorize(args)
  @accounts = args[:accounts]
  regions = args[:regions]

  return false unless validate_format_of_accounts

  @logger.info "Authorizing #{@accounts.join(', ')}."

  @key_name = reader.key_name

  regions.each do |region|
    @bucket = reader.get_bucket :region => region

    return false unless grant_read_access region
  end

  @logger.info "Authorization complete."
  true
end