Implement pass-otp compatible TOTP and HOTP
This commit is contained in:
@@ -83,6 +83,14 @@ pub struct EntryCommit {
|
||||
}
|
||||
|
||||
impl EntryCommit {
|
||||
pub(crate) fn new(path: EntryPath, action: EntryAction, message: String) -> Self {
|
||||
Self {
|
||||
path,
|
||||
action,
|
||||
message,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn path(&self) -> &EntryPath {
|
||||
&self.path
|
||||
}
|
||||
@@ -205,11 +213,11 @@ impl<'a> VaultWriter<'a> {
|
||||
.keys
|
||||
.encrypt(contents.into_secret(), recipients.recipients())?;
|
||||
self.repository.write_entry(&path, &ciphertext)?;
|
||||
let change = EntryCommit {
|
||||
path: path.clone(),
|
||||
action: EntryAction::Insert,
|
||||
message: format!("Add given password for {path} to store."),
|
||||
};
|
||||
let change = EntryCommit::new(
|
||||
path.clone(),
|
||||
EntryAction::Insert,
|
||||
format!("Add given password for {path} to store."),
|
||||
);
|
||||
if let Err(error) = committer.commit(&change) {
|
||||
if let Err(rollback) = self.restore(&path, original.as_ref()) {
|
||||
return Err(WriteError::RollbackFailed {
|
||||
@@ -270,11 +278,11 @@ impl<'a> VaultWriter<'a> {
|
||||
.resolve_for_entry(path, signing)?;
|
||||
let ciphertext = self.keys.encrypt(contents, recipients.recipients())?;
|
||||
self.repository.write_entry(path, &ciphertext)?;
|
||||
let change = EntryCommit {
|
||||
path: path.clone(),
|
||||
action: EntryAction::Insert,
|
||||
message: format!("Add generated password for {path}."),
|
||||
};
|
||||
let change = EntryCommit::new(
|
||||
path.clone(),
|
||||
EntryAction::Insert,
|
||||
format!("Add generated password for {path}."),
|
||||
);
|
||||
if let Err(error) = committer.commit(&change) {
|
||||
if let Err(rollback) = self.restore(path, original.as_ref()) {
|
||||
return Err(WriteError::RollbackFailed {
|
||||
@@ -320,11 +328,11 @@ impl<'a> VaultWriter<'a> {
|
||||
.resolve_for_entry(&session.path, signing)?;
|
||||
let ciphertext = self.keys.encrypt(replacement, recipients.recipients())?;
|
||||
self.repository.write_entry(&session.path, &ciphertext)?;
|
||||
let change = EntryCommit {
|
||||
path: session.path.clone(),
|
||||
action: EntryAction::Edit,
|
||||
message: format!("Edit password for {} using {}.", session.path, editor_name),
|
||||
};
|
||||
let change = EntryCommit::new(
|
||||
session.path.clone(),
|
||||
EntryAction::Edit,
|
||||
format!("Edit password for {} using {}.", session.path, editor_name),
|
||||
);
|
||||
if let Err(error) = committer.commit(&change) {
|
||||
if let Err(rollback) = self.restore(&session.path, session.original_ciphertext.as_ref())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user