Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implements MasterKeyChangeForce Meta key #279

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions pykeepass/pykeepass.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,32 @@ def delete_binary(self, id):
for reference in binaries_gt:
reference.id = reference.id - 1

@property
def needs_password_change(self):
"""Check whether a password change is necessary."""
return self.password_change_force_days >= 0

@property
def password_change_force_days(self):
"""Check amount of days until password force reset."""
path = '/KeePassFile/Meta/MasterKeyChangeForce'
item = self._xpath(path, first=True)
value = item.text

assert value # should be always present and non-empty
return int(value)

@password_change_force_days.setter
def password_change_force_days(self, value):
"""Set amount of days until password force reset.

Args:
value (`int`): Number of days until reset (-1 to disable)
"""
path = '/KeePassFile/Meta/MasterKeyChangeForce'
item = self._xpath(path, first=True)
item.text = repr(value)


def create_database(
filename, password=None, keyfile=None, transformed_key=None
Expand Down