diff --git a/README.md b/README.md index 0b24bd9..60cd739 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# Tokendito +
@@ -26,11 +28,19 @@ tokens into your local `~/.aws/credentials` file. See [Releases](https://github.com/dowjones/tokendito/releases) for a detailed Changelog. +### Tokendito 2.4.0 + +Version 2.4.0 of Tokendito introduces the following new features: + +- Add support for Okta question MFA. +- Many bug fixes and contributions. + ### Tokendito 2.3.0 Version 2.3.0 of Tokendito introduces the following new features: - Basic OIE support while forcing Classic mode. +- Support for saving the Device Token ID for later reuse. - Misc bug fixes Note: This feature currently works with locally enabled OIE organizations, but it does not for Organizations with chained Authentication in mixed OIE/Classic environments. diff --git a/docs/README.md b/docs/README.md index b594179..c706b34 100644 --- a/docs/README.md +++ b/docs/README.md @@ -74,7 +74,8 @@ tokendito --profile engineer usage: tokendito [-h] [--version] [--configure] [--username OKTA_USERNAME] [--password OKTA_PASSWORD] [--profile USER_CONFIG_PROFILE] [--config-file USER_CONFIG_FILE] [--loglevel {DEBUG,INFO,WARN,ERROR}] [--log-output-file USER_LOG_OUTPUT_FILE] [--aws-config-file AWS_CONFIG_FILE] [--aws-output AWS_OUTPUT] [--aws-profile AWS_PROFILE] [--aws-region AWS_REGION] [--aws-role-arn AWS_ROLE_ARN] [--aws-shared-credentials-file AWS_SHARED_CREDENTIALS_FILE] - [--okta-org OKTA_ORG | --okta-tile OKTA_TILE] [--okta-mfa OKTA_MFA] [--okta-mfa-response OKTA_MFA_RESPONSE] [--use-device-token] [--use-profile-expiration] [--quiet] + [--okta-org OKTA_ORG | --okta-tile OKTA_TILE] [--okta-client-id OKTA_CLIENT_ID] [--okta-mfa OKTA_MFA] [--okta-mfa-response OKTA_MFA_RESPONSE] + [--use-device-token] [--use-profile-expiration] [--quiet] Gets an STS token to use with the AWS CLI and SDK. @@ -111,9 +112,9 @@ options: Okta tile URL to use. --okta-client-id OKTA_CLIENT_ID For OIE enabled Orgs this sets the Okta client ID to replace the value found by tokendito. It is used in the authorize code flow. - --okta-mfa OKTA_MFA Sets the MFA method + --okta-mfa OKTA_MFA Sets the MFA method. You can also use the TOKENDITO_OKTA_MFA environment variable. --okta-mfa-response OKTA_MFA_RESPONSE - Sets the MFA response to a challenge + Sets the MFA response to a challenge. You can also use the TOKENDITO_OKTA_MFA_RESPONSE environment variable. --use-device-token Use device token across sessions --use-profile-expiration Use profile expiration to bypass re-authenticating diff --git a/pyproject.toml b/pyproject.toml index 9d131ff..d77300e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ exclude_lines = [ "break", "except KeyboardInterrupt:", "if __name__ == .__main__.:", - "if __package__ is None:", + "if not __package__:", "logger.debug", "pragma: no cover", "print..Invalid input, try again...", diff --git a/tests/unit/test_okta.py b/tests/unit/test_okta.py index 4bddcd5..bcb7826 100644 --- a/tests/unit/test_okta.py +++ b/tests/unit/test_okta.py @@ -73,6 +73,7 @@ def test_bad_session_token(mocker, sample_json_response, sample_headers): {"_embedded": {"factor": {"factorType": "push"}}}, 345, ), # Changed expected value to 2 + ("OKTA", 321, {"_embedded": {"factor": {"factorType": "question"}}}, 321), ("GOOGLE", 456, {"_embedded": {"factor": {"factorType": "sms"}}}, 456), ], ) @@ -543,13 +544,16 @@ def test_create_authz_cookies(): """Test create_authz_cookies.""" from tokendito import okta - pytest_oauth2_session_data = {"state": "pyteststate"} + pytest_oauth2_session_data = {"state": "pyteststate", "nonce": "pytestnonce"} pytest_oauth2_config = { "client_id": "123", "org": "acme", "authorization_endpoint": "pytesturl", "token_endpoint": "tokeneurl", + "nonce": "pytest", + "issuer": "pytest", + "ln": "pytest", } assert okta.create_authz_cookies(pytest_oauth2_config, pytest_oauth2_session_data) is None from tokendito import okta @@ -637,6 +641,9 @@ def test_get_authorize_code(): response.url = "https://example.com?code=pytest" assert okta.get_authorize_code(response, "sessionToken") == "pytest" + response.url = "https//example.com?error=login_required" + assert okta.get_authorize_code(response, None) is None + def test_authorization_code_enabled(): """Test authorization_code_enabled.""" @@ -687,12 +694,33 @@ def test_authorize_request(mocker): assert okta.authorize_request(pytest_oauth2_config, pytest_oauth2_session_data) == "pytest" -def test_generate_oauth2_session_data(): - """Test generate_oauth2_session_data.""" +def test_get_nonce(mocker): + """Test get_nonce.""" + from tokendito import okta + + response = Mock() + response.text = """ + +