mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Remove section and config parameter from Authenticator
This commit is contained in:
parent
d905e95dbb
commit
0096a0c077
@ -15,9 +15,9 @@ AuthConstructor = Callable[[
|
|||||||
|
|
||||||
AUTHENTICATORS: Dict[str, AuthConstructor] = {
|
AUTHENTICATORS: Dict[str, AuthConstructor] = {
|
||||||
"simple": lambda n, s, c:
|
"simple": lambda n, s, c:
|
||||||
SimpleAuthenticator(n, SimpleAuthSection(s), c),
|
SimpleAuthenticator(n, SimpleAuthSection(s)),
|
||||||
"tfa": lambda n, s, c:
|
"tfa": lambda n, s, c:
|
||||||
TfaAuthenticator(n, AuthSection(s), c),
|
TfaAuthenticator(n),
|
||||||
"keyring": lambda n, s, c:
|
"keyring": lambda n, s, c:
|
||||||
KeyringAuthenticator(n, KeyringAuthSection(s), c)
|
KeyringAuthenticator(n, KeyringAuthSection(s))
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
from ..config import Config, Section
|
from ..config import Section
|
||||||
|
|
||||||
|
|
||||||
class AuthLoadError(Exception):
|
class AuthLoadError(Exception):
|
||||||
@ -19,9 +19,7 @@ class AuthSection(Section):
|
|||||||
class Authenticator(ABC):
|
class Authenticator(ABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str
|
||||||
section: AuthSection,
|
|
||||||
config: Config,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Initialize an authenticator from its name and its section in the config
|
Initialize an authenticator from its name and its section in the config
|
||||||
|
@ -2,7 +2,6 @@ from typing import Optional, Tuple
|
|||||||
|
|
||||||
import keyring
|
import keyring
|
||||||
|
|
||||||
from ..config import Config
|
|
||||||
from ..logging import log
|
from ..logging import log
|
||||||
from ..utils import agetpass, ainput
|
from ..utils import agetpass, ainput
|
||||||
from ..version import NAME
|
from ..version import NAME
|
||||||
@ -23,9 +22,8 @@ class KeyringAuthenticator(Authenticator):
|
|||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
section: KeyringAuthSection,
|
section: KeyringAuthSection,
|
||||||
config: Config,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(name, section, config)
|
super().__init__(name)
|
||||||
|
|
||||||
self._username = section.username()
|
self._username = section.username()
|
||||||
self._password: Optional[str] = None
|
self._password: Optional[str] = None
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from typing import Optional, Tuple
|
from typing import Optional, Tuple
|
||||||
|
|
||||||
from ..config import Config
|
|
||||||
from ..logging import log
|
from ..logging import log
|
||||||
from ..utils import agetpass, ainput
|
from ..utils import agetpass, ainput
|
||||||
from .authenticator import Authenticator, AuthError, AuthSection
|
from .authenticator import Authenticator, AuthError, AuthSection
|
||||||
@ -19,9 +18,8 @@ class SimpleAuthenticator(Authenticator):
|
|||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
section: SimpleAuthSection,
|
section: SimpleAuthSection,
|
||||||
config: Config,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(name, section, config)
|
super().__init__(name)
|
||||||
|
|
||||||
self._username = section.username()
|
self._username = section.username()
|
||||||
self._password = section.password()
|
self._password = section.password()
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
from ..config import Config
|
|
||||||
from ..logging import log
|
from ..logging import log
|
||||||
from ..utils import ainput
|
from ..utils import ainput
|
||||||
from .authenticator import Authenticator, AuthError, AuthSection
|
from .authenticator import Authenticator, AuthError
|
||||||
|
|
||||||
|
|
||||||
class TfaAuthenticator(Authenticator):
|
class TfaAuthenticator(Authenticator):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
section: AuthSection,
|
|
||||||
config: Config,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(name, section, config)
|
super().__init__(name)
|
||||||
|
|
||||||
async def username(self) -> str:
|
async def username(self) -> str:
|
||||||
raise AuthError("TFA authenticator does not support usernames")
|
raise AuthError("TFA authenticator does not support usernames")
|
||||||
|
Loading…
Reference in New Issue
Block a user