planet-auth 2.2.0__tar.gz → 2.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {planet_auth-2.2.0 → planet_auth-2.3.0}/.gitignore +1 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/PKG-INFO +1 -1
- planet_auth-2.3.0/docs/changelog.md +31 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client/oauth/make-oauth-authenticated-httpx-request.py +1 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client/oauth/make-oauth-authenticated-requests-request.py +1 -0
- planet_auth-2.3.0/docs/examples/auth-client/oauth/perform-oauth-initial-login-2.py +13 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/pyproject.toml +1 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/__init__.py +2 -1
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/auth.py +117 -5
- planet_auth-2.3.0/src/planet_auth/credential.py +93 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/multi_validator.py +1 -1
- planet_auth-2.3.0/src/planet_auth/oidc/oidc_credential.py +120 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/request_authenticator.py +42 -32
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/token_validator.py +14 -5
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/request_authenticator.py +2 -2
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/storage_utils.py +6 -5
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth.egg-info/PKG-INFO +1 -1
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth.egg-info/SOURCES.txt +9 -1
- planet_auth-2.3.0/tests/test_planet_auth/data/keys/oidc_test_credential_jwt_tokens_no_lifespan_augmented.json +10 -0
- planet_auth-2.3.0/tests/test_planet_auth/data/keys/oidc_test_credential_jwt_tokens_no_lifespan_non_augmented.json +8 -0
- planet_auth-2.3.0/tests/test_planet_auth/data/keys/oidc_test_credential_jwt_tokens_with_lifespan_augmented.json +11 -0
- planet_auth-2.3.0/tests/test_planet_auth/data/keys/oidc_test_credential_jwt_tokens_with_lifespan_non_augmented.json +9 -0
- planet_auth-2.3.0/tests/test_planet_auth/data/keys/oidc_test_credential_opaque_tokens_no_lifespan_augmented.json +10 -0
- planet_auth-2.3.0/tests/test_planet_auth/data/keys/oidc_test_credential_opaque_tokens_no_lifespan_non_augmented.json +8 -0
- planet_auth-2.3.0/tests/test_planet_auth/data/keys/oidc_test_credential_opaque_tokens_with_lifespan_augmented.json +11 -0
- planet_auth-2.2.0/tests/test_planet_auth/data/keys/oidc_test_credential.json → planet_auth-2.3.0/tests/test_planet_auth/data/keys/oidc_test_credential_opaque_tokens_with_lifespan_non_augmented.json +2 -1
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/test_oidc_request_authenticator.py +62 -2
- planet_auth-2.3.0/tests/test_planet_auth/unit/auth/auth_clients/oidc/test_oidc_token_credential.py +244 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/test_token_validator.py +132 -36
- planet_auth-2.3.0/tests/test_planet_auth/unit/auth/test_auth.py +386 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/util.py +6 -3
- planet_auth-2.3.0/version.txt +1 -0
- planet_auth-2.2.0/docs/changelog.md +0 -19
- planet_auth-2.2.0/src/planet_auth/credential.py +0 -28
- planet_auth-2.2.0/src/planet_auth/oidc/oidc_credential.py +0 -55
- planet_auth-2.2.0/tests/test_planet_auth/unit/auth/auth_clients/oidc/test_oidc_token_credential.py +0 -43
- planet_auth-2.2.0/tests/test_planet_auth/unit/auth/test_auth.py +0 -68
- planet_auth-2.2.0/version.txt +0 -1
- {planet_auth-2.2.0 → planet_auth-2.3.0}/.github/actions/python-build-env-setup/action.yml +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/.github/actions/version-dot-buildnum-fetch/action.yml +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/.github/actions/version-dot-buildnum-generate/action.yml +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/.github/workflows/release-build.yml +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/.github/workflows/release-orchestrate.yml +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/.github/workflows/release-publish.yml +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/.github/workflows/test.yml +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/.readthedocs.yaml +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/CONTRIBUTING.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/DESIGN.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/DEVELOPMENT.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/LICENSE +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/MANIFEST.in +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/README.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/RELEASE.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/api-planet-auth-config-injection.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/api-planet-auth-utils.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/api-planet-auth.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/built-ins.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/cli-plauth.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/configuration.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/custom_theme/partials/header.html +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/design.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client/oauth/initialize-client-lib-in-memory.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client/oauth/initialize-client-lib-on-disk-profile.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client/oauth/perform-oauth-device-login.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client/oauth/perform-oauth-initial-login.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client/planet-legacy/make-legacy-authenticated-requests-request.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client/planet-legacy/perform-legacy-initial-login.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client-config/oauth-auth-code-grant-confidential-client-pubkey.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client-config/oauth-auth-code-grant-confidential-client-secret.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client-config/oauth-auth-code-grant-public-client.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client-config/oauth-client-credentials-grant-confidential-client-pubkey.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client-config/oauth-client-credentials-grant-confidential-client-secret.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client-config/oauth-client-validator.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client-config/oauth-password-grant-confidential-client-pubkey.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client-config/oauth-password-grant-confidential-client-secret.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client-config/oauth-password-grant-public-client.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/auth-client-config/planet-legacy.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/cli/embed-plauth-click.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/service/fastapi.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/service/flask--connexion.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/service/flask--oidc-multi-issuer--local-and-remote-validation.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/service/flask--oidc-multi-issuer--local-only-validation.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/snippets/auth-client-context-from-saved-profile.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/snippets/auth-client-context-oauth-direct.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples/snippets/auth-client-context-pl-legacy-direct.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples-cli.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples-client.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples-installation.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/examples-service.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/hooks/mkdocs_hooks.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/img/logo-color-dark-150.png +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/img/logo-color-dark.svg +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/img/logo-color-light-150.png +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/img/logo-color-light.svg +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/img/logo-color.svg +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/img/logo-white-150.png +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/img/logo-white.svg +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/img/logo.svg +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/index.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/library-overview.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/docs/readme.md +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/mkdocs.yml +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/noxfile.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/setup.cfg +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/setup.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/auth_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/auth_exception.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/constants.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/internal/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/logging/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/logging/auth_logger.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/logging/events.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/none/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/none/noop_auth.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/api_clients/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/api_clients/api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/api_clients/authorization_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/api_clients/device_authorization_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/api_clients/discovery_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/api_clients/introspect_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/api_clients/jwks_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/api_clients/oidc_request_auth.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/api_clients/revocation_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/api_clients/token_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/api_clients/userinfo_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/auth_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/auth_client_default_authenticators.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/auth_client_with_client_pubkey.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/auth_client_with_client_secret.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/auth_clients/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/auth_clients/auth_code_flow.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/auth_clients/client_credentials_flow.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/auth_clients/client_validator.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/auth_clients/device_code_flow.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/auth_clients/resource_owner_flow.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/resources/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/resources/callback_acknowledgement.html +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/oidc/util.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/planet_legacy/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/planet_legacy/auth_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/planet_legacy/legacy_api_key.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/planet_legacy/request_authenticator.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/py.typed +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/static_api_key/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/static_api_key/auth_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/static_api_key/request_authenticator.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/static_api_key/static_api_key.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth/util.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth.egg-info/dependency_links.txt +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth.egg-info/entry_points.txt +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth.egg-info/requires.txt +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth.egg-info/top_level.txt +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_config_injection/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_config_injection/builtins_provider.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_config_injection/py.typed +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/builtins.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/commands/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/commands/cli/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/commands/cli/jwt_cmd.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/commands/cli/main.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/commands/cli/oauth_cmd.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/commands/cli/options.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/commands/cli/planet_legacy_auth_cmd.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/commands/cli/profile_cmd.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/commands/cli/prompts.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/commands/cli/util.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/constants.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/internal/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/plauth_factory.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/plauth_user_config.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/profile.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/src/planet_auth_utils/py.typed +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/live_service/oauth_client_credentials_client_secret.sops.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/live_service/oauth_client_credentials_pubkey_literal.sops.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/live_service/oauth_pkce_auth_code.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/live_service/oauth_pkce_auth_code_client_secret.sops.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/live_service/oauth_pkce_auth_code_pubkey.sops.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/live_service/oauth_resource_owner.sops.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/live_service/oauth_resource_owner_client_pubkey.sops.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/live_service/oauth_resource_owner_client_secret.sops.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/auth_code.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/auth_code_pubkey.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/auth_code_secret.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/client_credentials_client_secret.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/client_credentials_pubkey_file.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/client_credentials_pubkey_literal.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/client_validator.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/device_auth.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/device_auth_pubkey.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/device_auth_secret.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/invalid_client_config.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/none.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/planet_legacy.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/planet_legacy_with_apikey.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/resource_owner.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/resource_owner_pubkey.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/resource_owner_secret.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/static_api_key.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/auth_client_configs/utest/static_api_key_with_key.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/README.txt +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/base_test_credential.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/invalid_test_credential.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair1_priv.test_pem +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair1_priv_nopassword.test_pem +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair1_pub.test_pem +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair1_pub_jwk.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair2_priv.test_pem +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair2_priv_nopassword.test_pem +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair2_pub.test_pem +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair2_pub_jwk.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair3_priv_nopassword.test_pem +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair3_pub.test_pem +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair3_pub_jwk.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair4_priv_jwk.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair4_priv_nopassword.test_pem +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair4_pub.test_pem +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/keypair4_pub_jwk.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/planet_legacy_test_credential.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/static_api_key_test_credential.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/keys/static_api_key_test_credential_2.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/data/resources/authorization_callback_acknowledgement.html +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/live_service/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/live_service/auth/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/live_service/auth/auth_clients/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/live_service/auth/auth_clients/oidc/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/live_service/auth/auth_clients/oidc/test_all_oidc_clients_live.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/none/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/none/test_noop_auth.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/api_clients/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/api_clients/test_api_client_base.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/api_clients/test_authorization_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/api_clients/test_device_authorization_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/api_clients/test_discovery_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/api_clients/test_introspect_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/api_clients/test_jwks_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/api_clients/test_revocation_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/api_clients/test_token_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/api_clients/test_userinfo_api_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/auth_clients/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/auth_clients/test_auth_code.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/auth_clients/test_client_credentials.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/auth_clients/test_client_validator.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/auth_clients/test_device_code.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/auth_clients/test_resource_owner.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/test_multi_validator.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/oidc/test_oidc_auth_client_baseclass.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/planet_legacy/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/planet_legacy/test_legacy_api_auth_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/planet_legacy/test_legacy_api_key_credential.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/planet_legacy/test_planet_legacy_request_authenticator.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/static_api_key/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/static_api_key/test_static_api_key_auth_client.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/static_api_key/test_static_api_key_credential.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/static_api_key/test_static_api_key_request_authenticator.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/auth_clients/test_auth_client_baseclass.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/test_auth_exception.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/test_auth_is_initialized.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/test_auth_logger.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/test_auth_utils.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/test_request_authenticator.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/test_resources.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/unit/auth/test_storage_utils_file_backed_json_object.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth/util.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth_utils/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth_utils/data/auth_client_configs/utest/invalid_client_config.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth_utils/data/auth_client_configs/utest/static_api_key.json +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth_utils/unit/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth_utils/unit/auth_utils/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth_utils/unit/auth_utils/builtins_test_impl.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth_utils/unit/auth_utils/test_builtins.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth_utils/unit/auth_utils/test_plauth_factory.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth_utils/unit/auth_utils/test_profile.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth_utils/unit/commands/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth_utils/unit/commands/plauth_cli/__init__.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth_utils/unit/commands/plauth_cli/test_cli_cmds.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth_utils/unit/commands/plauth_cli/test_utils.py +0 -0
- {planet_auth-2.2.0 → planet_auth-2.3.0}/tests/test_planet_auth_utils/util.py +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 2.3.0 - 2025-10-20
|
|
4
|
+
- Improve the user experience around old stale sessions that appear to be
|
|
5
|
+
initialized, but are actually expired. This is done by providing the new
|
|
6
|
+
utility method: `Auth.ensure_request_authenticator_is_ready()`.
|
|
7
|
+
- Save computed expiration time and issued time in token files. This allows
|
|
8
|
+
for the persistence of this information when dealing with opaque tokens.
|
|
9
|
+
- **Note**: Previously saved OAuth access tokens that are not JWTs with
|
|
10
|
+
an `exp` claim that can be inspected will be considered to expire in
|
|
11
|
+
`expires_in` seconds from the time they are loaded, since the time
|
|
12
|
+
they were issued was not saved in the past.
|
|
13
|
+
- Support non-expiring tokens.
|
|
14
|
+
|
|
15
|
+
## 2.2.0 - 2025-10-02
|
|
16
|
+
- Update supported python versions.
|
|
17
|
+
Support for 3.9 dropped. Support through 3.14 added.
|
|
18
|
+
|
|
19
|
+
## 2.1.1 - 2025-08-11
|
|
20
|
+
- Add py.typed to all top level packages
|
|
21
|
+
|
|
22
|
+
## 2.1.0 - 2025-07-09
|
|
23
|
+
- Initial public release targeting integration with the
|
|
24
|
+
[Planet Client for Python](https://github.com/planetlabs/planet-client-python).
|
|
25
|
+
|
|
26
|
+
## 2.0.11 - 2025-07-09
|
|
27
|
+
- Final 2.0 series development release.
|
|
28
|
+
|
|
29
|
+
## [Unreleased: 2.0.*]
|
|
30
|
+
- All releases in the 2.0.X series are development releases, even if not
|
|
31
|
+
tagged as such. This work included some shakedowns of the release pipelines.
|
|
@@ -6,6 +6,7 @@ import planet_auth_utils
|
|
|
6
6
|
def main():
|
|
7
7
|
logging.basicConfig(level=logging.DEBUG)
|
|
8
8
|
auth_ctx = planet_auth_utils.PlanetAuthFactory.initialize_auth_client_context(auth_profile_opt="my-custom-profile")
|
|
9
|
+
auth_ctx.ensure_request_authenticator_is_ready(allow_open_browser=True, allow_tty_prompt=True)
|
|
9
10
|
result = httpx.get(
|
|
10
11
|
url="https://api.planet.com/basemaps/v1/mosaics",
|
|
11
12
|
auth=auth_ctx.request_authenticator(),
|
|
@@ -6,6 +6,7 @@ import planet_auth_utils
|
|
|
6
6
|
def main():
|
|
7
7
|
logging.basicConfig(level=logging.DEBUG)
|
|
8
8
|
auth_ctx = planet_auth_utils.PlanetAuthFactory.initialize_auth_client_context(auth_profile_opt="my-custom-profile")
|
|
9
|
+
auth_ctx.ensure_request_authenticator_is_ready(allow_open_browser=True, allow_tty_prompt=True)
|
|
9
10
|
result = requests.get(
|
|
10
11
|
url="https://api.planet.com/basemaps/v1/mosaics",
|
|
11
12
|
auth=auth_ctx.request_authenticator(),
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import planet_auth_utils
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def main():
|
|
6
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
7
|
+
auth_ctx = planet_auth_utils.PlanetAuthFactory.initialize_auth_client_context(auth_profile_opt="my-custom-profile")
|
|
8
|
+
|
|
9
|
+
auth_ctx.ensure_request_authenticator_is_ready(allow_open_browser=True, allow_tty_prompt=True)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
if __name__ == "__main__":
|
|
13
|
+
main()
|
|
@@ -56,7 +56,7 @@ The primary interfaces implemented for users of this package are as follows:
|
|
|
56
56
|
class exists.
|
|
57
57
|
"""
|
|
58
58
|
|
|
59
|
-
from .auth import Auth
|
|
59
|
+
from .auth import Auth, AuthClientContextException
|
|
60
60
|
from .auth_exception import AuthException
|
|
61
61
|
from .auth_client import AuthClientConfig, AuthClient
|
|
62
62
|
from .credential import Credential
|
|
@@ -145,6 +145,7 @@ __all__ = [
|
|
|
145
145
|
"Auth",
|
|
146
146
|
"AuthClient",
|
|
147
147
|
"AuthClientConfig",
|
|
148
|
+
"AuthClientContextException",
|
|
148
149
|
"AuthCodeAuthClient",
|
|
149
150
|
"AuthCodeClientConfig",
|
|
150
151
|
"AuthCodeWithClientSecretAuthClient",
|
|
@@ -18,6 +18,7 @@ import pathlib
|
|
|
18
18
|
from typing import Optional, Union
|
|
19
19
|
|
|
20
20
|
from planet_auth.auth_client import AuthClient, AuthClientConfig
|
|
21
|
+
from planet_auth.auth_exception import AuthException
|
|
21
22
|
from planet_auth.credential import Credential
|
|
22
23
|
from planet_auth.request_authenticator import CredentialRequestAuthenticator
|
|
23
24
|
from planet_auth.storage_utils import ObjectStorageProvider
|
|
@@ -25,9 +26,10 @@ from planet_auth.logging.auth_logger import getAuthLogger
|
|
|
25
26
|
|
|
26
27
|
auth_logger = getAuthLogger()
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
|
|
30
|
+
class AuthClientContextException(AuthException):
|
|
31
|
+
def __init__(self, **kwargs):
|
|
32
|
+
super().__init__(**kwargs)
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
class Auth:
|
|
@@ -113,10 +115,108 @@ class Auth:
|
|
|
113
115
|
For example, simple API key clients only need an API key in their
|
|
114
116
|
configuration. OAuth2 user clients need to have performed
|
|
115
117
|
a user login and obtained access or refresh tokens.
|
|
118
|
+
|
|
119
|
+
Note: This will not detect when a credential is expired or
|
|
120
|
+
otherwise invalid.
|
|
116
121
|
"""
|
|
117
122
|
return self._request_authenticator.is_initialized() or self._auth_client.can_login_unattended()
|
|
118
123
|
|
|
119
|
-
def
|
|
124
|
+
def ensure_request_authenticator_is_ready(
|
|
125
|
+
self, allow_open_browser: Optional[bool] = False, allow_tty_prompt: Optional[bool] = False
|
|
126
|
+
) -> None:
|
|
127
|
+
"""
|
|
128
|
+
Do everything necessary to ensure the request authenticator is ready for use,
|
|
129
|
+
while still biasing towards just-in-time operations and not making
|
|
130
|
+
unnecessary network requests or prompts for user interaction.
|
|
131
|
+
|
|
132
|
+
This can be more complex than it sounds given the variations in the
|
|
133
|
+
capabilities of authentication clients and possible session states.
|
|
134
|
+
Clients may be initialized with active sessions, initialized with stale
|
|
135
|
+
but still valid sessions, initialized with invalid or expired
|
|
136
|
+
sessions, or completely uninitialized. The process taken to ensure
|
|
137
|
+
client readiness with as little user disruption as possible
|
|
138
|
+
is as follows:
|
|
139
|
+
|
|
140
|
+
1. If the client has been logged in and has a non-expired
|
|
141
|
+
short-term access token, the client will be considered
|
|
142
|
+
ready without prompting the user or probing the network.
|
|
143
|
+
This will not require user interaction.
|
|
144
|
+
2. If the client has not been logged in and is a type that
|
|
145
|
+
can do so without prompting the user, the client will be
|
|
146
|
+
considered ready without prompting the user or probing
|
|
147
|
+
the network. This will not require user interaction.
|
|
148
|
+
Login will be delayed until it is required.
|
|
149
|
+
3. If the client has been logged in and has an expired
|
|
150
|
+
short-term access token, the network will be probed to attempt
|
|
151
|
+
a refresh of the session. This should not require user interaction.
|
|
152
|
+
If refresh fails, the user will be prompted to perform a fresh
|
|
153
|
+
login, requiring user interaction.
|
|
154
|
+
4. If the client has never been logged in and is a type that
|
|
155
|
+
requires a user interactive login, a user interactive
|
|
156
|
+
login will be initiated.
|
|
157
|
+
|
|
158
|
+
There still may be conditions where we believe we are
|
|
159
|
+
ready, but requests still ultimately fail. For example, if
|
|
160
|
+
the auth context holds a static API key or username/password, it is
|
|
161
|
+
assumed to be ready but the credentials could be bad. Even when ready
|
|
162
|
+
with valid credentia, requests could fail if the service
|
|
163
|
+
rejects the request due to its own policy configuration.
|
|
164
|
+
|
|
165
|
+
Parameters:
|
|
166
|
+
allow_open_browser: specify whether login is permitted to open
|
|
167
|
+
a browser window.
|
|
168
|
+
allow_tty_prompt: specify whether login is permitted to request
|
|
169
|
+
input from the terminal.
|
|
170
|
+
"""
|
|
171
|
+
|
|
172
|
+
def _has_credential() -> bool:
|
|
173
|
+
# Does not do any JIT checks
|
|
174
|
+
return self._request_authenticator.is_initialized()
|
|
175
|
+
|
|
176
|
+
def _can_obtain_credentials_unattended() -> bool:
|
|
177
|
+
# Does not do any JIT checks
|
|
178
|
+
return self._auth_client.can_login_unattended()
|
|
179
|
+
|
|
180
|
+
def _is_expired() -> bool:
|
|
181
|
+
# Does not do any JIT check
|
|
182
|
+
new_cred = self._request_authenticator.credential(refresh_if_needed=False)
|
|
183
|
+
if new_cred:
|
|
184
|
+
return new_cred.is_expired()
|
|
185
|
+
return True
|
|
186
|
+
|
|
187
|
+
# Case #1 above.
|
|
188
|
+
if _has_credential() and not _is_expired():
|
|
189
|
+
return
|
|
190
|
+
|
|
191
|
+
# Case #2 above.
|
|
192
|
+
if _can_obtain_credentials_unattended():
|
|
193
|
+
# Should we fetch one? We do not by default because the bias is towards
|
|
194
|
+
# JIT operations and silent operations. This so programs can initialize and
|
|
195
|
+
# not fail for auth reasons unless the credential is actually needed.
|
|
196
|
+
return
|
|
197
|
+
|
|
198
|
+
# Case #3 above.
|
|
199
|
+
if _has_credential() and _is_expired():
|
|
200
|
+
try:
|
|
201
|
+
# This takes care of making sure the authenticator's credential is
|
|
202
|
+
# current with the update. No further action needed on our part.
|
|
203
|
+
new_cred = self._request_authenticator.credential(refresh_if_needed=True)
|
|
204
|
+
if not new_cred:
|
|
205
|
+
raise RuntimeError("Unable to refresh credentials - Unknown error")
|
|
206
|
+
if new_cred.is_expired():
|
|
207
|
+
raise RuntimeError("Unable to refresh credentials - Refreshed credentials are still expired.")
|
|
208
|
+
return
|
|
209
|
+
except Exception as e:
|
|
210
|
+
auth_logger.warning(
|
|
211
|
+
msg=f"Failed to refresh expired credentials (Error: {str(e)}). Attempting interactive login."
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
# Case #4 above.
|
|
215
|
+
self.login(allow_open_browser=allow_open_browser, allow_tty_prompt=allow_tty_prompt)
|
|
216
|
+
|
|
217
|
+
def login(
|
|
218
|
+
self, allow_open_browser: Optional[bool] = False, allow_tty_prompt: Optional[bool] = False, **kwargs
|
|
219
|
+
) -> Credential:
|
|
120
220
|
"""
|
|
121
221
|
Perform a login with the configured auth client.
|
|
122
222
|
This higher level function will ensure that the token is saved to
|
|
@@ -124,8 +224,20 @@ class Auth:
|
|
|
124
224
|
storage path. Otherwise, the token will be held only in memory.
|
|
125
225
|
In all cases, the request authenticator will also be updated with
|
|
126
226
|
the new credentials.
|
|
227
|
+
|
|
228
|
+
Parameters:
|
|
229
|
+
allow_open_browser: specify whether login is permitted to open
|
|
230
|
+
a browser window.
|
|
231
|
+
allow_tty_prompt: specify whether login is permitted to request
|
|
232
|
+
input from the terminal.
|
|
127
233
|
"""
|
|
128
|
-
new_credential = self._auth_client.login(
|
|
234
|
+
new_credential = self._auth_client.login(
|
|
235
|
+
allow_open_browser=allow_open_browser, allow_tty_prompt=allow_tty_prompt, **kwargs
|
|
236
|
+
)
|
|
237
|
+
if not new_credential:
|
|
238
|
+
# AuthClient.login() is supposed to raise on failure.
|
|
239
|
+
raise AuthClientContextException(message="Unknown login failure. No credentials and no error returned.")
|
|
240
|
+
|
|
129
241
|
new_credential.set_path(self._token_file_path)
|
|
130
242
|
new_credential.set_storage_provider(self._storage_provider)
|
|
131
243
|
new_credential.save()
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Copyright 2024-2025 Planet Labs PBC.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
import time
|
|
16
|
+
from typing import Optional
|
|
17
|
+
|
|
18
|
+
from planet_auth.storage_utils import FileBackedJsonObject
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Credential(FileBackedJsonObject):
|
|
22
|
+
"""
|
|
23
|
+
A storage backed credential.
|
|
24
|
+
A credential is expected to be a json dict. Per the base class default
|
|
25
|
+
storage provider implementation, clear-text .json files or .sops.json files
|
|
26
|
+
with field level encryption are supported. Custom storage providers may
|
|
27
|
+
offer different functionality.
|
|
28
|
+
|
|
29
|
+
Subclass Implementor Notes:
|
|
30
|
+
The `Credential` class reserves the data fields `_iat` and `_exp` for
|
|
31
|
+
internal use. These are used to record the time the credential was
|
|
32
|
+
issued and the time that it expires respectively, expressed as seconds
|
|
33
|
+
since the epoch. A None or NULL value for `_exp` indicates that
|
|
34
|
+
the credential never expires.
|
|
35
|
+
|
|
36
|
+
This base class does not set these values. It is the responsibility
|
|
37
|
+
of subclasses to set these values as appropriate. If left unset,
|
|
38
|
+
the credential will be treated as a non-expiring credential with an
|
|
39
|
+
indeterminate issued time.
|
|
40
|
+
|
|
41
|
+
Subclasses that wish to provide values should do so in their
|
|
42
|
+
constructor and in their `set_data()` methods.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def __init__(self, data=None, file_path=None, storage_provider=None):
|
|
46
|
+
super().__init__(data=data, file_path=file_path, storage_provider=storage_provider)
|
|
47
|
+
|
|
48
|
+
def expiry_time(self) -> Optional[int]:
|
|
49
|
+
"""
|
|
50
|
+
The time that the credential expires, expressed as seconds since the epoch.
|
|
51
|
+
"""
|
|
52
|
+
return self.lazy_get("_exp")
|
|
53
|
+
|
|
54
|
+
def issued_time(self) -> Optional[int]:
|
|
55
|
+
"""
|
|
56
|
+
The time that the credential was issued, expressed as seconds since the epoch.
|
|
57
|
+
"""
|
|
58
|
+
return self.lazy_get("_iat")
|
|
59
|
+
|
|
60
|
+
def is_expiring(self) -> bool:
|
|
61
|
+
"""
|
|
62
|
+
Return true if the credential has an expiry time.
|
|
63
|
+
"""
|
|
64
|
+
return self.expiry_time() is not None
|
|
65
|
+
|
|
66
|
+
def is_non_expiring(self) -> bool:
|
|
67
|
+
"""
|
|
68
|
+
Return true if the credential never expires.
|
|
69
|
+
"""
|
|
70
|
+
return not self.is_expiring()
|
|
71
|
+
|
|
72
|
+
def is_expired(self, at_time: Optional[int] = None) -> bool:
|
|
73
|
+
"""
|
|
74
|
+
Return true if the credential is expired at the specified time.
|
|
75
|
+
If no time is specified, the current time is used.
|
|
76
|
+
Non-expiring credentials will always return false.
|
|
77
|
+
"""
|
|
78
|
+
if self.is_non_expiring():
|
|
79
|
+
return False
|
|
80
|
+
|
|
81
|
+
if at_time is None:
|
|
82
|
+
at_time = int(time.time())
|
|
83
|
+
|
|
84
|
+
exp = self.expiry_time()
|
|
85
|
+
return bool(at_time >= exp) # type: ignore[operator]
|
|
86
|
+
|
|
87
|
+
def is_not_expired(self, at_time: Optional[int] = None) -> bool:
|
|
88
|
+
"""
|
|
89
|
+
Return true if the credential is not expired at the specified time.
|
|
90
|
+
If no time is specified, the current time is used.
|
|
91
|
+
Non-expiring credentials will always return true.
|
|
92
|
+
"""
|
|
93
|
+
return not self.is_expired(at_time)
|
|
@@ -286,7 +286,7 @@ class OidcMultiIssuerValidator:
|
|
|
286
286
|
"""
|
|
287
287
|
|
|
288
288
|
if not token:
|
|
289
|
-
raise InvalidArgumentException(message="Cannot
|
|
289
|
+
raise InvalidArgumentException(message="Cannot decode empty string as a token")
|
|
290
290
|
|
|
291
291
|
validator = self._select_validator(token)
|
|
292
292
|
local_validation, remote_validation = self._check_access_token(
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Copyright 2024-2025 Planet Labs PBC.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
import time
|
|
16
|
+
from typing import Optional
|
|
17
|
+
|
|
18
|
+
from planet_auth.credential import Credential
|
|
19
|
+
from planet_auth.storage_utils import InvalidDataException, ObjectStorageProvider
|
|
20
|
+
from planet_auth.oidc.token_validator import TokenValidator, InvalidArgumentException
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class FileBackedOidcCredential(Credential):
|
|
24
|
+
"""
|
|
25
|
+
Credential object for storing OAuth/OIDC tokens.
|
|
26
|
+
Credential should conform to the "token" response
|
|
27
|
+
defined in RFC 6749 for OAuth access tokens with OIDC extensions
|
|
28
|
+
for ID tokens.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self, data=None, credential_file=None, storage_provider: Optional[ObjectStorageProvider] = None):
|
|
32
|
+
super().__init__(data=data, file_path=credential_file, storage_provider=storage_provider)
|
|
33
|
+
self._augment_rfc6749_data()
|
|
34
|
+
|
|
35
|
+
def check_data(self, data):
|
|
36
|
+
"""
|
|
37
|
+
Check that the supplied data represents a valid OAuth/OIDC token object.
|
|
38
|
+
"""
|
|
39
|
+
super().check_data(data)
|
|
40
|
+
if not data.get("access_token") and not data.get("id_token") and not data.get("refresh_token"):
|
|
41
|
+
raise InvalidDataException(
|
|
42
|
+
message="'access_token', 'id_token', or 'refresh_token' not found in file {}".format(self._file_path)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
def _augment_rfc6749_data(self):
|
|
46
|
+
# RFC 6749 includes an optional "expires_in" expressing the lifespan of
|
|
47
|
+
# the token. But without knowing when a token was issued it tells us
|
|
48
|
+
# nothing about whether a token is actually valid.
|
|
49
|
+
#
|
|
50
|
+
# This function lest us augment our representation of this data to
|
|
51
|
+
# make this credential useful when reconstructed from saved data
|
|
52
|
+
# at a time that is distant from when the token was obtained from the
|
|
53
|
+
# authorization server.
|
|
54
|
+
#
|
|
55
|
+
# Edge case - It's possible that a JWT ID token has an expiration time
|
|
56
|
+
# that is different from the access token. It's also possible that
|
|
57
|
+
# we have a refresh token and not any other tokens (this state could
|
|
58
|
+
# be used for bootstrapping). We are really only tracking
|
|
59
|
+
# access token expiration at this time.
|
|
60
|
+
if not self._data:
|
|
61
|
+
return
|
|
62
|
+
|
|
63
|
+
try:
|
|
64
|
+
access_token_str = self.access_token()
|
|
65
|
+
if access_token_str:
|
|
66
|
+
(_, jwt_hazmat_body, _) = TokenValidator.hazmat_unverified_decode(access_token_str)
|
|
67
|
+
else:
|
|
68
|
+
jwt_hazmat_body = None
|
|
69
|
+
except InvalidArgumentException:
|
|
70
|
+
# Proceed as if it's not a JWT.
|
|
71
|
+
jwt_hazmat_body = None
|
|
72
|
+
|
|
73
|
+
# It's possible for the combination of a transparent bearer token,
|
|
74
|
+
# saved iat and exp values, and a expires_in value to be
|
|
75
|
+
# over-constrained. We apply the following priority, from highest
|
|
76
|
+
# to lowest:
|
|
77
|
+
# - Bearer token claims
|
|
78
|
+
# - Saved values in the credential file
|
|
79
|
+
# - Newly calculated values
|
|
80
|
+
# If a reasonable expiration time cannot be derived,
|
|
81
|
+
# tokens are assumed to never expire.
|
|
82
|
+
rfc6749_lifespan = self._data.get("expires_in", 0)
|
|
83
|
+
if jwt_hazmat_body:
|
|
84
|
+
_iat = jwt_hazmat_body.get("iat", self._data.get("_iat", int(time.time())))
|
|
85
|
+
_exp = jwt_hazmat_body.get("exp", self._data.get("_exp", None))
|
|
86
|
+
else:
|
|
87
|
+
_iat = self._data.get("_iat", int(time.time()))
|
|
88
|
+
_exp = self._data.get("_exp", None)
|
|
89
|
+
|
|
90
|
+
if _exp is None and rfc6749_lifespan > 0:
|
|
91
|
+
_exp = _iat + rfc6749_lifespan
|
|
92
|
+
|
|
93
|
+
self._data["_iat"] = _iat
|
|
94
|
+
self._data["_exp"] = _exp
|
|
95
|
+
|
|
96
|
+
def set_data(self, data, copy_data: bool = True):
|
|
97
|
+
"""
|
|
98
|
+
Set credential data for an OAuth/OIDC credential. The data structure is expected
|
|
99
|
+
to be an RFC 6749 /token response structure.
|
|
100
|
+
"""
|
|
101
|
+
super().set_data(data, copy_data)
|
|
102
|
+
self._augment_rfc6749_data()
|
|
103
|
+
|
|
104
|
+
def access_token(self):
|
|
105
|
+
"""
|
|
106
|
+
Get the current access token.
|
|
107
|
+
"""
|
|
108
|
+
return self.lazy_get("access_token")
|
|
109
|
+
|
|
110
|
+
def id_token(self):
|
|
111
|
+
"""
|
|
112
|
+
Get the current ID token.
|
|
113
|
+
"""
|
|
114
|
+
return self.lazy_get("id_token")
|
|
115
|
+
|
|
116
|
+
def refresh_token(self):
|
|
117
|
+
"""
|
|
118
|
+
Get the current refresh token.
|
|
119
|
+
"""
|
|
120
|
+
return self.lazy_get("refresh_token")
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
import jwt
|
|
16
15
|
import time
|
|
17
16
|
from typing import Dict, Optional
|
|
18
17
|
|
|
@@ -53,29 +52,19 @@ class RefreshingOidcTokenRequestAuthenticator(CredentialRequestAuthenticator):
|
|
|
53
52
|
self._auth_client = auth_client
|
|
54
53
|
self._refresh_at = 0
|
|
55
54
|
|
|
56
|
-
def
|
|
55
|
+
def _load_and_prime(self):
|
|
57
56
|
if self._credential.path():
|
|
58
57
|
# allow in memory operation.
|
|
59
58
|
self._credential.load()
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
# OAuth server, which would work for non-JWT opaque OAuth
|
|
70
|
-
# tokens. Since that is a relative time, we would also need
|
|
71
|
-
# to augment our FileBackedOidcCredential with an issued
|
|
72
|
-
# at time.
|
|
73
|
-
unverified_decoded_atoken = jwt.decode(access_token_str, options={"verify_signature": False}) # nosemgrep
|
|
74
|
-
iat = unverified_decoded_atoken.get("iat") or 0
|
|
75
|
-
exp = unverified_decoded_atoken.get("exp") or 0
|
|
76
|
-
# refresh at the 3/4 life
|
|
77
|
-
self._refresh_at = int(iat + (3 * (exp - iat) / 4))
|
|
78
|
-
self._token_body = access_token_str
|
|
60
|
+
self._token_body = self._credential.access_token()
|
|
61
|
+
iat = self._credential.issued_time() or 0
|
|
62
|
+
exp = self._credential.expiry_time()
|
|
63
|
+
if exp is None:
|
|
64
|
+
# Never expires.
|
|
65
|
+
self._refresh_at = None
|
|
66
|
+
else:
|
|
67
|
+
self._refresh_at = int(iat + (3 * (exp - iat) / 4))
|
|
79
68
|
|
|
80
69
|
def _refresh(self):
|
|
81
70
|
if self._auth_client:
|
|
@@ -91,15 +80,31 @@ class RefreshingOidcTokenRequestAuthenticator(CredentialRequestAuthenticator):
|
|
|
91
80
|
|
|
92
81
|
# self.update_credential(new_credential=new_credentials)
|
|
93
82
|
self._credential = new_credentials
|
|
94
|
-
self.
|
|
83
|
+
self._load_and_prime()
|
|
84
|
+
|
|
85
|
+
def _refresh_needed(self, check_time: Optional[int] = None) -> bool:
|
|
86
|
+
if self._token_body is None:
|
|
87
|
+
# Always consider not having the token loaded and primed to be
|
|
88
|
+
# in need of a refresh. In _refresh_if_needed(), this will
|
|
89
|
+
# trigger a reload before doing a network refresh.
|
|
90
|
+
return True
|
|
91
|
+
|
|
92
|
+
if self._refresh_at is None:
|
|
93
|
+
# Non-expiring token is currently loaded.
|
|
94
|
+
return False
|
|
95
|
+
|
|
96
|
+
if check_time is None:
|
|
97
|
+
check_time = int(time.time())
|
|
98
|
+
|
|
99
|
+
return check_time > self._refresh_at
|
|
95
100
|
|
|
96
101
|
def _refresh_if_needed(self):
|
|
97
|
-
# Reload the file before
|
|
98
|
-
# have done it for us, and save us the
|
|
102
|
+
# Reload the file before doing a refresh with the auth server.
|
|
103
|
+
# Another process might have done it for us, and save us the
|
|
104
|
+
# network call.
|
|
99
105
|
#
|
|
100
|
-
# Also,
|
|
101
|
-
#
|
|
102
|
-
# invalid depending on server configuration.
|
|
106
|
+
# Also, we should always try to use a fresh refresh token.
|
|
107
|
+
# Refresh might be configured to be one time use.
|
|
103
108
|
#
|
|
104
109
|
# Also, it's possible that we have a valid refresh token,
|
|
105
110
|
# but not an access token. When that's true, we should
|
|
@@ -107,15 +112,17 @@ class RefreshingOidcTokenRequestAuthenticator(CredentialRequestAuthenticator):
|
|
|
107
112
|
#
|
|
108
113
|
# If everything fails, continue with what we have. Let the API
|
|
109
114
|
# we are calling decide if it's good enough.
|
|
115
|
+
|
|
110
116
|
now = int(time.time())
|
|
111
|
-
if
|
|
117
|
+
if self._refresh_needed(now):
|
|
112
118
|
try:
|
|
113
|
-
self.
|
|
119
|
+
self._load_and_prime()
|
|
114
120
|
except Exception as e: # pylint: disable=broad-exception-caught
|
|
115
121
|
auth_logger.warning(
|
|
116
122
|
msg=f"Error loading auth token. Continuing with old configuration and token data. Load error: {str(e)}"
|
|
117
123
|
)
|
|
118
|
-
|
|
124
|
+
|
|
125
|
+
if self._refresh_needed(now):
|
|
119
126
|
try:
|
|
120
127
|
self._refresh()
|
|
121
128
|
except Exception as e: # pylint: disable=broad-exception-caught
|
|
@@ -146,8 +153,11 @@ class RefreshingOidcTokenRequestAuthenticator(CredentialRequestAuthenticator):
|
|
|
146
153
|
f"{type(self).__name__} does not support {type(new_credential)} credentials. Use FileBackedOidcCredential."
|
|
147
154
|
)
|
|
148
155
|
super().update_credential(new_credential=new_credential)
|
|
156
|
+
# Mimic __init__.
|
|
157
|
+
# Set refresh_at to 0 to force a JIT check.
|
|
158
|
+
# Do not load the credential at this time. Let that happen JIT.
|
|
149
159
|
self._refresh_at = 0
|
|
150
|
-
# self.
|
|
160
|
+
# self._load_and_prime()
|
|
151
161
|
|
|
152
162
|
def update_credential_data(self, new_credential_data: Dict) -> None:
|
|
153
163
|
# This is more different than update_credential() than it may
|
|
@@ -158,7 +168,7 @@ class RefreshingOidcTokenRequestAuthenticator(CredentialRequestAuthenticator):
|
|
|
158
168
|
# has already taken place or a _load() is in progress, and we
|
|
159
169
|
# should behave as if we are finishing a _refresh() call.
|
|
160
170
|
super().update_credential_data(new_credential_data=new_credential_data)
|
|
161
|
-
self.
|
|
171
|
+
self._load_and_prime()
|
|
162
172
|
|
|
163
173
|
def credential(self, refresh_if_needed: bool = False) -> Optional[Credential]:
|
|
164
174
|
if refresh_if_needed:
|
|
@@ -201,4 +211,4 @@ class RefreshOrReloginOidcTokenRequestAuthenticator(RefreshingOidcTokenRequestAu
|
|
|
201
211
|
|
|
202
212
|
# self.update_credential(new_credential=new_credentials)
|
|
203
213
|
self._credential = new_credentials
|
|
204
|
-
self.
|
|
214
|
+
self._load_and_prime()
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import jwt
|
|
16
16
|
import time
|
|
17
|
-
from typing import Dict, List
|
|
17
|
+
from typing import Any, Dict, List, Tuple
|
|
18
18
|
|
|
19
19
|
import planet_auth.logging.auth_logger
|
|
20
20
|
from planet_auth.auth_exception import AuthException, InvalidTokenException
|
|
@@ -181,7 +181,7 @@ class TokenValidator:
|
|
|
181
181
|
"""
|
|
182
182
|
# PyJWT should enforce this, but we have unit tests in case...
|
|
183
183
|
if not token_str:
|
|
184
|
-
raise InvalidArgumentException(message="Cannot
|
|
184
|
+
raise InvalidArgumentException(message="Cannot decode empty string as a token")
|
|
185
185
|
if not issuer:
|
|
186
186
|
# PyJWT does not seem to raise if the issuer is explicitly None, even when
|
|
187
187
|
# verify_iss was selected.
|
|
@@ -257,9 +257,18 @@ class TokenValidator:
|
|
|
257
257
|
return validated_claims
|
|
258
258
|
|
|
259
259
|
@staticmethod
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
@InvalidArgumentException.recast(jwt.exceptions.DecodeError)
|
|
261
|
+
def hazmat_unverified_decode(token_str) -> Tuple[Dict, Dict, Any]:
|
|
262
|
+
"""
|
|
263
|
+
Decode a JWT without verifying the signature or any claims.
|
|
264
|
+
|
|
265
|
+
!!! Warning
|
|
266
|
+
Treat unverified token claims with extreme caution.
|
|
267
|
+
Nothing can be trusted until the token is verified.
|
|
268
|
+
|
|
269
|
+
Returns:
|
|
270
|
+
Returns the decoded JWT header, payload, and signature
|
|
271
|
+
"""
|
|
263
272
|
unverified_complete = jwt.decode_complete(token_str, options={"verify_signature": False}) # nosemgrep
|
|
264
273
|
return unverified_complete["header"], unverified_complete["payload"], unverified_complete["signature"]
|
|
265
274
|
|