Skip to content

Commit

Permalink
Add fingerprint authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Radosław Skupnik committed Jan 6, 2019
1 parent d66779d commit 4e6962b
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion KeePass/Forms/MainForm.cs
Expand Up @@ -24,6 +24,7 @@
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Net;
using System.Media;
using System.Security;
using System.Text;
Expand Down Expand Up @@ -868,9 +869,11 @@ private void OnEntryCopyUserName(object sender, EventArgs e)
true, this, pe, m_docMgr.SafeFindContainerOf(pe)))
StartClipboardCountdown();
}

private void OnEntryCopyPassword(object sender, EventArgs e)
{
if (!IsAllowedToCopyPassword()) return;

PwEntry pe = GetSelectedEntry(false);
Debug.Assert(pe != null); if(pe == null) return;

Expand All @@ -885,6 +888,35 @@ private void OnEntryCopyPassword(object sender, EventArgs e)
StartClipboardCountdown();
}

private bool IsAllowedToCopyPassword()
{
SetStatusEx("Fingerprint verification...");

HttpWebResponse response = null;
try
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://raspberrypi.fritz.box");
request.Method = "GET";

response = (HttpWebResponse)request.GetResponse();
} catch (WebException e)
{
if (e.Status == WebExceptionStatus.ProtocolError)
{
response = (HttpWebResponse)e.Response;
Console.Write("Errorcode: {0}", (int)response.StatusCode);
}
else
{
Console.Write("Error: {0}", e.Status);
}
SetStatusEx("Fingerprint verification FAILED, denied access to password");
return false;
}

return response != null && response.StatusCode == HttpStatusCode.OK;
}

private void OnEntryOpenUrl(object sender, EventArgs e)
{
PerformDefaultUrlAction(null, true);
Expand Down

0 comments on commit 4e6962b

Please sign in to comment.