diff --git a/examples/auth_examples.py b/examples/auth_examples.py index 5a2312b..acf6c9f 100644 --- a/examples/auth_examples.py +++ b/examples/auth_examples.py @@ -10,8 +10,6 @@ def main(): """ OtfAuthConfig provides three options currently: - - cache_device_data: bool - Whether to register/cache device data with AWS Cognito - I'm not sure if there is any benefit to this at this point, but in general this is used to allow skipping MFA - cache_tokens_plaintext: bool - Whether to cache the tokens in plaintext in the config file - this is an obvious security risk, but it's useful for development purposes. If you want to do this, it is at your own risk. The benefit is that after you log in with your username/password once, you can use the cached tokens to log in @@ -20,7 +18,7 @@ def main(): # This is the most configurable way to access the API but also the most verbose - auth_config = OtfAuthConfig(cache_device_data=True, cache_tokens_plaintext=True) + auth_config = OtfAuthConfig(cache_tokens_plaintext=True) auth = OtfAuth.create(USERNAME, PASSWORD, config=auth_config) user = OtfUser(auth=auth) diff --git a/src/otf_api/auth/config.py b/src/otf_api/auth/config.py index 9285461..66a0dcb 100644 --- a/src/otf_api/auth/config.py +++ b/src/otf_api/auth/config.py @@ -12,7 +12,6 @@ class OtfAuthConfig: DEVICE_DATA_KEYS: ClassVar[list[str]] = ["device_key", "device_group_key", "device_password"] TOKEN_KEYS: ClassVar[list[str]] = ["access_token", "id_token", "refresh_token"] - cache_device_data: bool = True cache_tokens_plaintext: bool = False cache_path: Path = attrs.field(init=False) diff --git a/src/otf_api/auth/user.py b/src/otf_api/auth/user.py index 8490114..59f4950 100644 --- a/src/otf_api/auth/user.py +++ b/src/otf_api/auth/user.py @@ -1,15 +1,10 @@ -import typing from logging import getLogger import attrs -from otf_api.auth.auth import OTF_AUTH_TYPE, OtfAuth, OtfAuthConfig, OtfBasicAuth +from otf_api.auth.auth import OTF_AUTH_TYPE, OtfAuth, OtfAuthConfig, OtfBasicAuth, OtfCognito from otf_api.auth.utils import HttpxCognitoAuth -if typing.TYPE_CHECKING: - from pycognito import Cognito - - LOGGER = getLogger(__name__) @@ -42,7 +37,7 @@ def __init__(self, auth: OTF_AUTH_TYPE): self.httpx_auth = HttpxCognitoAuth(cognito=self.cognito) @property - def cognito(self) -> "Cognito": + def cognito(self) -> OtfCognito: """Get the Cognito instance.""" return self.otf_auth.cognito @@ -105,11 +100,11 @@ def from_tokens( return cls(auth) @classmethod - def from_cognito(cls, cognito: "Cognito", config: OtfAuthConfig | None = None) -> "OtfUser": - """Create a User instance from a Cognito instance. + def from_cognito(cls, cognito: OtfCognito, config: OtfAuthConfig | None = None) -> "OtfUser": + """Create a User instance from a OtfCognito instance. Args: - cognito (Cognito): The Cognito instance. + cognito (OtfCognito): The OtfCognito instance. config (OtfAuthConfig, optional): The configuration. Defaults to None. Returns: