pferd/PFERD/authenticators/tfa.py
Joscha 4b68fa771f Move logging logic to singleton
- Renamed module and class because "conductor" didn't make a lot of sense
- Used singleton approach (there's only one stdout after all)
- Redesigned progress bars (now with download speed!)
2021-05-18 22:45:19 +02:00

37 lines
1.0 KiB
Python

from typing import Tuple
from ..authenticator import Authenticator, AuthException, AuthSection
from ..config import Config
from ..logging import log
from ..utils import ainput
class TfaAuthenticator(Authenticator):
def __init__(
self,
name: str,
section: AuthSection,
config: Config,
) -> None:
super().__init__(name, section, config)
async def username(self) -> str:
raise AuthException("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 AuthException("TFA authenticator does not support usernames")
def invalidate_username(self) -> None:
raise AuthException("TFA authenticator does not support usernames")
def invalidate_password(self) -> None:
pass
def invalidate_credentials(self) -> None:
pass