Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Custom Session Name Using Okta Username #481

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion gimme_aws_creds/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _get_partition_and_region_from_saml_acs(saml_acs_url):
raise errors.GimmeAWSCredsError("{} is an unknown ACS URL".format(saml_acs_url))

@staticmethod
def _get_sts_creds(partition, region, assertion, idp, role, duration=3600):
def _get_sts_creds(partition, region, assertion, idp, role, duration=3600, session_name="default-session"):
""" using the assertion and arns return aws sts creds """

session = boto3.session.Session(profile_name=None)
Expand Down Expand Up @@ -754,13 +754,15 @@ def prepare_data(self, role, generate_credentials=False):
aws_creds = {}
if generate_credentials:
try:
okta_username = self.auth_session['username']
aws_creds = self._get_sts_creds(
self.aws_partition,
self.conf_dict.get('aws_region'),
self.saml_data['SAMLResponse'],
role.idp,
role.role,
self.config.aws_default_duration,
session_name=okta_username,
)
except ClientError as ex:
if 'requested DurationSeconds exceeds the MaxSessionDuration' in ex.response['Error']['Message']:
Expand All @@ -773,6 +775,7 @@ def prepare_data(self, role, generate_credentials=False):
role.idp,
role.role,
3600,
session_name=okta_username,
)
else:
self.ui.error('Failed to generate credentials for {} due to {}'.format(role.role, ex))
Expand Down