2020-04-13 18:03:01 +00:00
|
|
|
class BaseOTPProvider:
|
|
|
|
'''OTP providers must be subclasses of BaseOTPProvider and implement at least validate_token().'''
|
|
|
|
|
|
|
|
@property
|
|
|
|
def get_name(self):
|
|
|
|
return "Base OTP Provider"
|
|
|
|
|
|
|
|
@property
|
|
|
|
def get_logo(self):
|
|
|
|
return ""
|
|
|
|
|
2020-04-15 20:19:03 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.get_name
|
|
|
|
|
2020-04-13 18:03:01 +00:00
|
|
|
@property
|
|
|
|
def is_active(self):
|
|
|
|
'''Returns True if the provider is properly configured and ready to use.'''
|
|
|
|
raise NotImplementedError(f"{type(self)} does not implement is_active!")
|
|
|
|
|
|
|
|
def start_authentication(self, user):
|
|
|
|
return "Authentication started, please enter your 2FA token."
|
|
|
|
|
|
|
|
def validate_token(self, user, token):
|
|
|
|
raise NotImplementedError(f"{type(self)} does not implement validate_token()!")
|