Skip to content

Commit

Permalink
Add SoftLock feature
Browse files Browse the repository at this point in the history
SoftLock hides sensitive information while still allowing Auto-Type as well as other integration
  • Loading branch information
Rookiestyle committed Sep 4, 2021
1 parent 14bfbce commit 81dd9f3
Show file tree
Hide file tree
Showing 18 changed files with 863 additions and 99 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

LockAssist extends KeePass' lock/unlock mechanism in multiple ways:
- Quick Unlock
- Soft Lock (privacy mode)
- (Un)lock workspace can handle ALL databases or only the selected one

# Table of Contents
Expand All @@ -28,6 +29,18 @@ Have a look at the [Wiki](https://github.com/rookiestyle/lockassist/wiki/quick-u

<img src="images/LockAssist%20-%20quick%20unlock.png" alt="Options" height="50%" width="50%"/>

## SoftLock
SoftLock hides sensitive information while still allowing Auto-Type as well as other integration.
You can configure SoftLock to kick in after a certain inactivity or when minimizing KeePass.

When active, the following is hidden:
- group list
- entry list
- entry view
- all forms containing sensitive data (entry form, ...)

<img src="images/LockAssist%20-%20softlock.png" alt="Options" height="50%" width="50%"/>

## Lock workspace
By default, 'Lock workspace' will lock all loaded databases whereas 'Unlock workspace' will only unlock the currently selected database.

Expand Down
47 changes: 35 additions & 12 deletions Translations/LockAssist.de.language.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Increment the TranslationVersion every time the translation file is updated
Also update the version.info file
-->
<TranslationVersion>3</TranslationVersion>
<TranslationVersion>4</TranslationVersion>
<item>
<key>FirstTimeInfo</key>
<value>Quick Unlock bietet verschiedene Konfigurationsmöglichkeiten.
Expand Down Expand Up @@ -104,29 +104,52 @@ Bitte aktiviere diese Einstellung!</value>
Die Datenbank ist weiterhin gesperrt und kann nur mit dem vollständigen Hauptschlüssel entsperrt werden.</value>
</item>
<item>
<key>FirstTimeInfoRememberPassword</key>
<value>Quick Unlock bietet verschiedene Konfigurationsmöglichkeiten.
Bitte wähle eine der Möglichkeiten aus.</value>
<key>Hours</key>
<value>Stunden</value>
</item>
<item>
<key>Hours</key>
<value>Stunden</value>
<key>Minutes</key>
<value>Minuten</value>
</item>
<item>
<key>Minutes</key>
<value>Minuten</value>
<key>Seconds</key>
<value>Sekunden</value>
</item>
<item>
<key>OptionsLockWorkspace</key>
<value>Global '{0} / {1}'</value>
<key>OptionsLockWorkspace</key>
<value>Global '{0} / {1}'</value>
</item>
<item>
<key>OptionsLockWorkspaceDesc</key>
<value>Diese Option ändert das Verhalten des Buttons und des Menüeintrags '{0} / {1}'.
<key>OptionsLockWorkspaceDesc</key>
<value>Diese Option ändert das Verhalten des Buttons und des Menüeintrags '{0} / {1}'.

Ist sie aktiv, dann werden beim Nutzen dieser Kommandos ALLE Datenbanken gesperrt bzw. entsperrt.
Es hängt vom Sperrstatus der aktiven Datenbank ab, ob gesperrt oder entsperrt wird.

Halte die [Shift]-Taste gedrückt, um nur die aktive Datenbank zu sperren / entsperren.</value>
</item>
<item>
<key>SoftlockModeUnhide</key>
<value>SoftLock ist aktiv.

Zum Deaktivieren bitte klicken</value>
</item>
<item>
<key>SoftlockActive</key>
<value>SoftLock nach Inaktivität</value>
</item>
<item>
<key>SoftlockOnMinimize</key>
<value>SoftLock beim Minimieren von Keepass</value>
</item>
<item>
<key>SoftlockDesc</key>
<value>SoftLock ermöglicht das Nutzen von Auto-Type und andere Integrationsmöglichkeiten, während folgende Daten verborgen werden:
- Gruppenansicht
- Liste der vorhandenen Einträge
- Eintragsansicht
- Alle Formulare, die NICHT in der Konfigurationsdatei unter LockAssist.SoftlockExcludeForms aufgeführt sind

SoftLock setzt gültige Quick Unlock Einstellung voraus, Quick Unlock selbst muss NICHT aktiv sein.</value>
</item>
</Translation>
46 changes: 36 additions & 10 deletions Translations/LockAssist.template.language.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Please choose your preferred way of working.</value>
</item>
<item>
<key>KeyProvNoQuickUnlock</key>
<value>No Quick Unlock key found.
<value>No Quick Unlock key found.

Quick Unlock is not possible.</value>
</item>
Expand All @@ -46,7 +46,7 @@ An existing Quick Unlock entry will be used as fallback</value>
</item>
<item>
<key>OptionsQUEntryCreated</key>
<value>Quick Unlock entry created.
<value>Quick Unlock entry created.

Please edit and set Quick Unlock PIN as password</value>
</item>
Expand Down Expand Up @@ -103,24 +103,50 @@ Please don't forget to activate this setting.</value>
The database stays locked and can only be unlocked with the original masterkey</value>
</item>
<item>
<key>Hours</key>
<value>Hours</value>
<key>Hours</key>
<value>Hours</value>
</item>
<item>
<key>Minutes</key>
<value>Minutes</value>
<key>Minutes</key>
<value>Minutes</value>
</item>
<item>
<key>OptionsLockWorkspace</key>
<value>Global '{0} / {1}'</value>
<key>Seconds</key>
<value>Seconds</value>
</item>
<item>
<key>OptionsLockWorkspaceDesc</key>
<value>This option changes the behaviour of '{0} / {1}' for both the menu entry as well as the toolbar button.
<key>OptionsLockWorkspace</key>
<value>Global '{0} / {1}'</value>
</item>
<item>
<key>OptionsLockWorkspaceDesc</key>
<value>This option changes the behaviour of '{0} / {1}' for both the menu entry as well as the toolbar button.

If it's active ALL loaded databases are locked / unlocked by using these commands.
In this case it depends on the active document's state whether a global lock or global unlock is performed.

If the [Shift] key is pressed while using these commands only the active document is processed.</value>
</item>
<item>
<key>SoftlockModeUnhide</key>
<value>SoftLock active. Click to deactivate</value>
</item>
<item>
<key>SoftlockActive</key>
<value>SoftLock after inactivity</value>
</item>
<item>
<key>SoftlockOnMinimize</key>
<value>SoftLock when minimizing KeePass</value>
</item>
<item>
<key>SoftlockDesc</key>
<value>SoftLock hides following sensitive information while still allowing Auto-Type as well as other integration:
- group list
- entry list
- entry view
- all forms NOT mentioned in config file property LockAssist.SoftlockExcludeForms

Valid Quick Unlock settings are required, Quick Unlock itself does NOT need to be active</value>
</item>
</Translation>
Binary file modified images/LockAssist - options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/LockAssist - softlock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions src/Config/LockAssistConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using KeePassLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LockAssist
{
//Generic part
internal partial class LockAssistConfig
{
public static KeePass.App.Configuration.AceCustomConfig _config = KeePass.Program.Config.CustomConfig;
}
}
20 changes: 20 additions & 0 deletions src/Config/LockAssistConfig_LW.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using KeePassLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LockAssist
{
//Lock workspace part
internal partial class LockAssistConfig
{
private const string LockAssistLockWorkspaceActive = "LockAssist.LockWorkspaceActive";

public static bool LW_Active
{
get { return _config.GetBool(LockAssistLockWorkspaceActive, true); }
set { _config.SetBool(LockAssistLockWorkspaceActive, value); }
}
}
}
60 changes: 26 additions & 34 deletions src/LockAssistConfig.cs → src/Config/LockAssistConfig_QU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,24 @@

namespace LockAssist
{
internal class LockAssistConfig
//Quick Unlock Config
internal partial class LockAssistConfig
{
public static KeePass.App.Configuration.AceCustomConfig _config = KeePass.Program.Config.CustomConfig;
public bool QU_Active = false;
public bool QU_DBSpecific = false;
public bool QU_UsePassword = true;
public bool QU_UsePasswordFromEnd = true;
public int QU_PINLength = 4;
public int QU_ValiditySeconds = 0;

public static LockAssistConfig GetQuickUnlockOptions(PwDatabase db)
{
LockAssistConfig conf = new LockAssistConfig();
conf.GetOptionsInternal(db);
conf.GetQUOptionsInternal(db);
return conf;
}

private void GetOptionsInternal(PwDatabase db)
private void GetQUOptionsInternal(PwDatabase db)
{
QU_DBSpecific = (db != null) && (db.IsOpen) && db.CustomData.Exists(LockAssistQuickUnlockDBSpecific);
if (QU_DBSpecific)
Expand All @@ -37,31 +44,24 @@ private void GetOptionsInternal(PwDatabase db)
}
}

public static bool FirstTime
public static bool QU_FirstTime
{
get { return _config.GetBool(LockAssistFirstTime, true); }
set { _config.SetBool(LockAssistFirstTime, value); }
}

public bool QU_Active = false;
public bool QU_DBSpecific = false;
public bool QU_UsePassword = true;
public bool QU_UsePasswordFromEnd = true;
public int QU_PINLength = 4;
public int QU_ValiditySeconds = 0;

public bool ConfigChanged(LockAssistConfig comp, bool CheckDBSpecific)
public bool QU_ConfigChanged(LockAssistConfig comp, bool CheckDBSpecific)
{
if (QU_Active != comp.QU_Active) return true;
if (CheckDBSpecific && (QU_DBSpecific != comp.QU_DBSpecific)) return true;
if (QU_UsePassword != comp.QU_UsePassword) return true;
if (QU_PINLength != comp.QU_PINLength) return true;
if (QU_UsePasswordFromEnd != comp.QU_UsePasswordFromEnd) return true;
if (QU_ValiditySeconds != comp.QU_ValiditySeconds) return true;
if (QU_ValiditySeconds != comp.QU_ValiditySeconds) return true;
return false;
}

public bool CopyFrom(LockAssistConfig NewOptions)
public bool QU_CopyFrom(LockAssistConfig NewOptions)
{
bool SwitchToNoDBSpecific = QU_DBSpecific && !NewOptions.QU_DBSpecific;
QU_DBSpecific = NewOptions.QU_DBSpecific;
Expand All @@ -73,13 +73,13 @@ public bool CopyFrom(LockAssistConfig NewOptions)
return SwitchToNoDBSpecific;
}

public void WriteConfig()
public void QU_WriteConfig()
{
QU_DBSpecific = false;
WriteConfig(null);
QU_WriteConfig(null);
}

public void WriteConfig(PwDatabase db)
public void QU_WriteConfig(PwDatabase db)
{
if (QU_DBSpecific)
{
Expand All @@ -90,7 +90,7 @@ public void WriteConfig(PwDatabase db)
db.CustomData.Set(LockAssistKeyFromEnd, QU_UsePasswordFromEnd ? "true" : "false");
db.CustomData.Set(LockAssistQuickUnlockDBSpecific, "true");
db.CustomData.Set(LockAssistQU_ValiditySeconds, QU_ValiditySeconds.ToString());
FlagDBChanged(db);
QU_FlagDBChanged(db);
}
else
{
Expand All @@ -99,30 +99,30 @@ public void WriteConfig(PwDatabase db)
_config.SetLong(LockAssistKeyLength, QU_PINLength);
_config.SetBool(LockAssistKeyFromEnd, QU_UsePasswordFromEnd);
_config.SetLong(LockAssistQU_ValiditySeconds, QU_ValiditySeconds);
DeleteDBConfig(db);
QU_DeleteDBConfig(db);
}
}

private void FlagDBChanged(PwDatabase db)
private void QU_FlagDBChanged(PwDatabase db)
{
db.Modified = true;
db.SettingsChanged = DateTime.UtcNow;
KeePass.Program.MainForm.UpdateUI(false, KeePass.Program.MainForm.DocumentManager.FindDocument(db), false, null, false, null, true);
}

public void DeleteDBConfig(PwDatabase db)
public void QU_DeleteDBConfig(PwDatabase db)
{
if (db == null || !db.IsOpen) return;
bool deleted = db.CustomData.Remove(LockAssistActive);
deleted |= deleted = db.CustomData.Remove(LockAssistUsePassword);
deleted |= db.CustomData.Remove(LockAssistUsePassword);
deleted |= db.CustomData.Remove(LockAssistKeyLength);
deleted |= db.CustomData.Remove(LockAssistKeyFromEnd);
deleted |= db.CustomData.Remove(LockAssistQuickUnlockDBSpecific);
deleted |= db.CustomData.Remove(LockAssistQU_ValiditySeconds);
deleted |= db.CustomData.Remove(LockAssistQU_ValiditySeconds);
if (deleted)
{
FlagDBChanged(db);
GetOptionsInternal(db);
QU_FlagDBChanged(db);
GetQUOptionsInternal(db);
}
}

Expand All @@ -133,13 +133,5 @@ public void DeleteDBConfig(PwDatabase db)
private const string LockAssistQU_ValiditySeconds = "LockAssist.QU_validitySeconds";
private const string LockAssistFirstTime = "LockAssist.FirstTime";
private const string LockAssistQuickUnlockDBSpecific = "LockAssist.QuickUnlockDBSpecific";

private const string LockAssistLockWorkspaceActive = "LockAssist.LockWorkspaceActive";

public static bool LW_Active
{
get { return _config.GetBool(LockAssistLockWorkspaceActive, true); }
set { _config.SetBool(LockAssistLockWorkspaceActive, value); }
}
}
}
Loading

0 comments on commit 81dd9f3

Please sign in to comment.