pferd/PFERD/auth/tfa.py
Joscha 22c2259adb Clean up authenticator exceptions
- Renamed to *Error for consistency
- Treating AuthError like CrawlError
2021-05-25 14:23:38 +02:00

37 lines
1016 B
Python

from typing import Tuple
from ..config import Config
from ..logging import log
from ..utils import ainput
from .authenticator import Authenticator, AuthError, AuthSection
class TfaAuthenticator(Authenticator):
def __init__(
self,
name: str,
section: AuthSection,
config: Config,
) -> None:
super().__init__(name, section, config)
async def username(self) -> str:
raise AuthError("TFA authenticator does not support usernames")
async def password(self) -> str:
async with log.exclusive_output():
code = await ainput("TFA code: ")
return code
async def credentials(self) -> Tuple[str, str]:
raise AuthError("TFA authenticator does not support usernames")
def invalidate_username(self) -> None:
raise AuthError("TFA authenticator does not support usernames")
def invalidate_password(self) -> None:
pass
def invalidate_credentials(self) -> None:
pass