Skip to content

Commit

Permalink
return TOTP regardless of KphOnly option, also prevent it from sendin…
Browse files Browse the repository at this point in the history
…g the TOTP secret to the browser
  • Loading branch information
smorks committed Nov 9, 2018
1 parent 41af380 commit 53ef89e
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions KeePassNatMsg/Entry/EntrySearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,14 @@ private IEnumerable<KeyValuePair<string, string>> GetFields(ConfigOpt configOpt,
// follow references
sfValue = SprEngine.Compile(sfValue, ctx);

if (configOpt.ReturnStringFieldsWithKphOnly)
// KeeOtp support through keepassxc-browser
// KeeOtp stores the TOTP config in a string field "otp" and provides a placeholder "{TOTP}"
// keepassxc-browser needs the value in a string field named "KPH: {TOTP}"
if (sf.Key == "otp")
{
fields.Add(new KeyValuePair<string, string>("KPH: {TOTP}", SprEngine.Compile("{TOTP}", ctx)));
}
else if (configOpt.ReturnStringFieldsWithKphOnly)
{
if (sf.Key.StartsWith("KPH: "))
{
Expand All @@ -268,14 +275,6 @@ private IEnumerable<KeyValuePair<string, string>> GetFields(ConfigOpt configOpt,
}
}

// KeeOtp support through keepassxc-browser
// KeeOtp stores the TOTP config in a string field "otp" and provides a placeholder "{TOTP}"
// keepassxc-browser needs the value in a string field named "KPH: {TOTP}"
if (fields.Exists(p => p.Key == "otp"))
{
fields.Add(new KeyValuePair<string, string>("KPH: {TOTP}", SprEngine.Compile("{TOTP}", ctx)));
}

if (fields.Count > 0)
{
var sorted = from e2 in fields orderby e2.Key ascending select e2;
Expand Down

0 comments on commit 53ef89e

Please sign in to comment.