1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import abc
from enum import Enum
from spectre.template import Template
class Scope(Enum):
AUTHENTICATION = "Authentication"
IDENTIFICATION = "Identification"
RECOVERY = "Recovery"
def default_template(self) -> Template:
if self == Scope.AUTHENTICATION:
return Template.LONG
elif self == Scope.IDENTIFICATION:
return Template.NAME
elif self == Scope.RECOVERY:
return Template.PHRASE
return Template.MAXIMUM
class Scoper(abc.ABC):
@abc.abstractmethod
def scope(self, scope: Scope) -> str:
pass
class SimpleScoper(Scoper):
def __init__(self, key: str):
self.key = key
def scope(self, scope: Scope) -> str:
if scope == Scope.AUTHENTICATION:
return self.key
elif scope == Scope.IDENTIFICATION:
return f"{self.key}.login"
elif scope == Scope.RECOVERY:
return f"{self.key}.answer"
return self.key
default_scoper = SimpleScoper("com.lyndir.masterpassword")
|