Skip to content

Commit

Permalink
Merge pull request #72 from dclayton-godaddy/hide-tokens
Browse files Browse the repository at this point in the history
switch tokens to use getpass
  • Loading branch information
thoward-godaddy authored Sep 6, 2024
2 parents 2bd61dc + 85f731f commit 850cd2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
8 changes: 3 additions & 5 deletions aws_okta_processor/core/okta.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(
self.user_name = input_tty()

if not user_pass:
user_pass = getpass.getpass()
user_pass = getpass.getpass("Password: ")

if not self.organization:
print_tty(string="Organization: ", newline=False)
Expand Down Expand Up @@ -449,8 +449,7 @@ def __init__(self, link=None):

@staticmethod
def payload():
print_tty("Token: ", newline=False)
return {"passCode": input_tty()}
return {"passCode": getpass.getpass("Token: ")}

def retry(self, response):
return False
Expand All @@ -464,8 +463,7 @@ def __init__(self, link=None):

@staticmethod
def payload():
print_tty("Hardware Token: ", newline=False)
return {"passCode": input_tty()}
return {"passCode": getpass.getpass("Hardware Token: ")}

def retry(self, response):
return False
12 changes: 6 additions & 6 deletions tests/core/test_okta.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def test_okta_mfa_push_challenge(
self.assertEqual(okta.organization, "organization.okta.com")
self.assertEqual(okta.okta_session_id, "session_token")

@patch('aws_okta_processor.core.okta.input_tty')
@patch('aws_okta_processor.core.okta.getpass.getpass')
@patch('aws_okta_processor.core.okta.os.chmod')
@patch('aws_okta_processor.core.okta.open')
@patch('aws_okta_processor.core.okta.os.makedirs')
Expand All @@ -264,9 +264,9 @@ def test_okta_mfa_totp_challenge(
mock_makedirs,
mock_open,
mock_chmod,
mock_input
mock_get_pass
):
mock_input.return_value = "123456"
mock_get_pass.return_value = "123456"

responses.add(
responses.POST,
Expand Down Expand Up @@ -368,7 +368,7 @@ def test_set_okta_session_should_write_session_data(
call('}')
])

@patch('aws_okta_processor.core.okta.input_tty')
@patch('aws_okta_processor.core.okta.getpass.getpass')
@patch('aws_okta_processor.core.okta.os.chmod')
@patch('aws_okta_processor.core.okta.open')
@patch('aws_okta_processor.core.okta.os.makedirs')
Expand All @@ -380,9 +380,9 @@ def test_okta_mfa_hardware_token_challenge(
mock_makedirs,
mock_open,
mock_chmod,
mock_input
mock_getpass
):
mock_input.return_value = "123456"
mock_getpass.return_value = "123456"

responses.add(
responses.POST,
Expand Down

0 comments on commit 850cd2e

Please sign in to comment.