Skip to content

Commit eb08315

Browse files
authored
Merge pull request #2 from nathan-v/Fix_reup_20180314
Fix bug in reup mode logic. Version bump to 0.2.1.
2 parents 3358ab6 + f5b34be commit eb08315

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

aws_okta_keyman/main.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def main(argv):
165165
# object to get a fresh SAMLResponse repeatedly and refresh our AWS
166166
# Credentials.
167167
session = None
168+
role_selection = None
168169
while True:
169170
# If an AWS Session object has been created already, lets check if its
170171
# still valid. If it is, sleep a bit and skip to the next execution of
@@ -174,16 +175,22 @@ def main(argv):
174175
time.sleep(15)
175176
continue
176177

178+
log.info('Getting SAML Assertion from {org}'.format(
179+
org=config.org))
180+
177181
try:
178-
# Only set up the session if it's still None
179-
if session is None:
180-
assertion = okta_client.get_assertion(appid=config.appid,
181-
apptype='amazon_aws')
182-
session = aws.Session(assertion, profile=config.name)
183-
184-
log.info('Getting SAML Assertion from {org}'.format(
185-
org=config.org))
182+
assertion = okta_client.get_assertion(appid=config.appid,
183+
apptype='amazon_aws')
184+
session = aws.Session(assertion, profile=config.name)
185+
186+
# If role_selection is set we're in a reup loop. Re-set the role on
187+
# the session to prevent the user being prompted for the role again
188+
# on each subsequent renewal.
189+
if role_selection is not None:
190+
session.set_role(role_selection)
191+
186192
session.assume_role()
193+
187194
except aws.MultipleRoles:
188195
log.warning('Multiple AWS roles found; please select one')
189196
roles = session.available_roles()

aws_okta_keyman/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Copyright 2018 Nathan V
1515

1616

17-
__version__ = '0.2.0'
17+
__version__ = '0.2.1'
1818
__desc__ = 'AWS Okta Keyman'
1919
__desc_long__ = ('''
2020
===============

0 commit comments

Comments
 (0)