Skip to content

Commit

Permalink
feat: add an unified way to generate otpauth url.
Browse files Browse the repository at this point in the history
  • Loading branch information
roddhjav committed Feb 14, 2024
1 parent 5498f8a commit e4823ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pass_import/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,14 @@ def duplicate(data: List[Dict[str, str]]):
entry['path'] = path
else:
seen.add(path)


def otp(data: List[Dict[str, str]]):
"""Format the otpauth url with sane default."""
for entry in data:
if 'otpauth' in entry:
if not entry['otpauth'].startswith('otpauth://'):
secret = entry['otpauth']
otp = f"otpauth://totp/{entry.get('title', 'otp-secret')}"
otp += f"?secret={secret}"
entry['otpauth'] = otp
2 changes: 2 additions & 0 deletions pass_import/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def clean(self, cmdclean: bool, convert: bool):
2. Clean the protocol's name in the title.
3. Clean group from unwanted values in Unix or Windows paths.
4. Duplicate paths.
5. Format the One-Time Password (OTP) url.
:param bool cmdclean:
If ``True``, make the paths more command line friendly.
Expand All @@ -163,6 +164,7 @@ def clean(self, cmdclean: bool, convert: bool):
clean.dpaths(self.data, cmdclean, convert)
clean.dpaths(self.data, cmdclean, convert)
clean.duplicate(self.data)
clean.otp(self.data)

def audit(self, hibp: bool = False):
"""Audit the parsed password for vulnerable passwords.
Expand Down

0 comments on commit e4823ee

Please sign in to comment.