Try to add support for Shibboleth TFA token

This commit is contained in:
I-Al-Istannen
2020-05-08 21:51:33 +02:00
parent c9deca19ca
commit 755e9aa0d3
2 changed files with 53 additions and 1 deletions

View File

@@ -6,6 +6,30 @@ import getpass
from typing import Optional, Tuple
class TfaAuthenticator:
# pylint: disable=too-few-public-methods
"""
An authenticator for a TFA token. Always prompts the user, as the token can not be cached.
"""
def __init__(self, reason: str):
"""
Create a new tfa authenticator.
Arguments:
reason {str} -- the reason for obtaining the credentials
"""
self._reason = reason
def get_token(self) -> str:
# pylint: disable=no-self-use
"""
Prompts the user for the token and returns it.
"""
print(f"Enter credentials ({self._reason})")
return getpass.getpass("TFA Token: ")
class UserPassAuthenticator:
"""
An authenticator for username-password combinations that prompts the user