Skip to content

Commit 5803b1d

Browse files
author
Peter Benjamin
committed
Fix auth bug
1 parent a141012 commit 5803b1d

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

source/lib/auth.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ class Auth
88
# TODO use keychain to save creds
99
def self.login(options, config, location)
1010
auth_file = "#{CREDS_FILE}.#{location}"
11-
region = RestackerConfig.default_region
12-
profile_name = options[:profile] || RestackerConfig.default_profile
13-
username = options.fetch(:username)
11+
region = config.fetch(:region)
12+
profile_name = RestackerConfig.find_profile(options)
13+
username = RestackerConfig.find_user(options)
1414

1515
# if no ctrl plane specified, authenticate directly
1616
return target_plane_auth(region, profile_name) if config[:ctrl].nil?
@@ -42,7 +42,7 @@ def self.get_mfa_code
4242
end
4343

4444
def self.get_creds(username, config)
45-
region = RestackerConfig.default_region(config)
45+
region = config.fetch(:region)
4646
target = RestackerConfig.target_config(config) # target account will always exist in restacker.yml
4747

4848
if config[:ctrl].nil?
@@ -90,11 +90,9 @@ def self.valid_session?(region, creds)
9090
Aws::CloudFormation::Client.new(region: region, credentials: creds).list_stacks
9191
return true
9292
rescue Aws::CloudFormation::Errors::ExpiredToken => expired
93-
raise expired.message
94-
rescue => e
95-
raise e.message
93+
puts expired.message
94+
return false
9695
end
97-
return false
9896
end
9997

10098
def self.get_auth_session(profile_name, username, config)

0 commit comments

Comments
 (0)