~sircmpwn/pass-rotate

ref: 7a0f1572c61de44c5ceed81c5d65c6830bc45865 pass-rotate/passrotate/provider.py -rw-r--r-- 762 bytes
7a0f1572 — Matthias Gabriel add option to override the pass name to be used when rotating the password 4 years ago
                                                                                
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
from enum import Enum

_providers = list()
_provider_map = dict()
_provider_domains = dict()

def register_provider(provider):
    _providers.append(provider)
    _provider_map[provider.name] = provider
    for d in provider.domains:
        _provider_domains[d] = provider

def get_provider(domain):
    return _provider_map.get(domain) or _provider_domains.get(domain)

def get_providers():
    return _providers

class PromptType(Enum):
    generic = "generic"
    totp = "totp"
    sms = "sms"

class ProviderOption:
    def __init__(self, type, doc, optional=False):
        self.type = type
        self.doc = doc
        self.optional = optional

class Provider:
    def prompt(self, prompt, prompt_type):
        return self._prompt(prompt, prompt_type)