Skip to content

Commit

Permalink
Merge branch 'release/v1.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrodan committed Jun 2, 2017
2 parents ac96334 + a87f44d commit d24bb2e
Show file tree
Hide file tree
Showing 16 changed files with 141 additions and 26 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 1.4.1 (2017-06-02)

This is a bug-fixing release only

### Fixed

- \#86 Error when opening KeeAnywhere Settings 1.4.0
- \#87 Authentication failed with Google Drive
- \#88 Google Drive: can't open/save database to/from root folder


## 1.4.0 (2017-05-31)

This release brings two new features: Offline-Caching and Simple Automatic Backup.
Expand Down
3 changes: 3 additions & 0 deletions KeeAnywhere/Configuration/ConfigurationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ private void LoadPluginConfiguration()
this.PluginConfiguration.BackupToLocalFolder = Path.Combine(AppConfigSerializer.LocalAppDataDirectory,
"KeeAnywhereBackups");
}

if (this.PluginConfiguration.BackupCopies < 1)
this.PluginConfiguration.BackupCopies = 10;
}

private void SavePluginConfiguration()
Expand Down
1 change: 1 addition & 0 deletions KeeAnywhere/OAuth2/IOAuth2Provider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace KeeAnywhere.OAuth2
public interface IOAuth2Provider
{
Task Initialize();
bool CanClaim(Uri uri, string documentTitle);
Task<bool> Claim(Uri uri, string documentTitle);

Uri PreAuthorizationUrl { get; }
Expand Down
11 changes: 6 additions & 5 deletions KeeAnywhere/OAuth2/OAuth2Form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public partial class OAuth2Form : Form
{
private IOAuth2Provider m_provider;
private bool m_isPreAuthorization;
private bool m_isClaimed;

public OAuth2Form()
{
Expand Down Expand Up @@ -70,15 +71,16 @@ private async void OnNavigated(object sender, WebBrowserNavigatedEventArgs e)
return;
}


// we need to ignore all navigation that isn't to the redirect uri.
if (!e.Url.ToString().StartsWith(m_provider.RedirectionUrl.ToString(), StringComparison.OrdinalIgnoreCase))
// we need to ignore all navigation that is already claimed or could not be claimed (due to missing code).
if (m_isClaimed || !m_provider.CanClaim(e.Url, m_browser.DocumentTitle))
{
return;
}

m_pnlWait.Visible = true;
m_isClaimed = true;
m_browser.Stop();
m_browser.Visible = false;
m_pnlWait.Visible = true;

try
{
Expand All @@ -92,7 +94,6 @@ private async void OnNavigated(object sender, WebBrowserNavigatedEventArgs e)
}
finally
{
m_browser.Stop();
Close();
}
}
Expand Down
6 changes: 3 additions & 3 deletions KeeAnywhere/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
//[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0")]
[assembly: AssemblyVersion("1.4.1.0")]
[assembly: AssemblyFileVersion("1.4.1.0")]
[assembly: AssemblyInformationalVersion("1.4.1")]
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public async Task Initialize()
this.AuthorizationUrl = new Uri(loginUri);
}

public bool CanClaim(Uri uri, string documentTitle)
{
return uri.ToString().StartsWith(this.RedirectionUrl.ToString(), StringComparison.OrdinalIgnoreCase);
}

public async Task<bool> Claim(Uri uri, string documentTitle)
{
var error = HttpUtility.ParseQueryString(uri.Query).Get("error_description");
Expand Down
5 changes: 5 additions & 0 deletions KeeAnywhere/StorageProviders/Box/BoxStorageConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public async Task Initialize()
this.AuthorizationUrl = BoxHelper.Config.AuthCodeUri;
}

public bool CanClaim(Uri uri, string documentTitle)
{
return uri.ToString().StartsWith(this.RedirectionUrl.ToString(), StringComparison.OrdinalIgnoreCase);
}

public async Task<bool> Claim(Uri uri, string documentTitle)
{
IDictionary<string, string> keyDictionary = new Dictionary<string, string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public async Task Initialize()
_isAccessRestricted ? DropboxHelper.DropboxAppFolderOnlyClientId : DropboxHelper.DropboxFullAccessClientId, RedirectionUrl, _state);
}

public bool CanClaim(Uri uri, string documentTitle)
{
return uri.ToString().StartsWith(this.RedirectionUrl.ToString(), StringComparison.OrdinalIgnoreCase);
}

public Task<bool> Claim(Uri uri, string documentTitle)
{
var cs = new TaskCompletionSource<bool>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
Expand Down Expand Up @@ -45,18 +46,22 @@ public async Task Initialize()
this.RedirectionUrl = new Uri(GoogleAuthConsts.ApprovalUrl);
}

public async Task<bool> Claim(Uri uri, string documentTitle)
public bool CanClaim(Uri uri, string documentTitle)
{
var parts = HttpUtility.ParseQueryString(uri.Query);

if (parts.Count < 1 || parts.Get("response") == null)
if (!uri.ToString().StartsWith(this.RedirectionUrl.ToString(), StringComparison.OrdinalIgnoreCase))
return false;

var code = parts.Get("response");
if (!code.Contains("code"))
return false;
return GetCodeFromDocumentTitle(documentTitle) != null || GetCodeFromUri(uri) != null;
}

code = code.Split('=')[1];
public async Task<bool> Claim(Uri uri, string documentTitle)
{
var code = GetCodeFromDocumentTitle(documentTitle);
if (code == null)
code = GetCodeFromUri(uri);

if (code == null)
return false;

try
{
Expand All @@ -76,5 +81,54 @@ public async Task<bool> Claim(Uri uri, string documentTitle)
public Uri AuthorizationUrl { get; protected set; }
public Uri RedirectionUrl { get; protected set; }
public string FriendlyProviderName { get { return "Google Drive"; } }

private string GetCodeFromDocumentTitle(string documentTitle)
{
try
{
if (string.IsNullOrEmpty(documentTitle) ||
!documentTitle.StartsWith("Success code="))
{
return null;
}

var parts = documentTitle.Split(' ');

//if (parts.Length < 1 || parts[0] != "Success")
// return null;

var code = parts[1].Split('=')[1];

return code;
}
catch
{
return null;
}
}

private string GetCodeFromUri(Uri uri)
{
try
{
var parts = HttpUtility.ParseQueryString(uri.Query);

if (parts.Count < 1 || parts.AllKeys.All(p => p != "response"))
return null;

var code = parts.Get("response");
if (code == null || !code.StartsWith("code="))
return null;

code = code.Split('=')[1];

return code;
}
catch
{
return null;
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,20 @@ public async Task Save(Stream stream, string path)
var folderName = CloudPath.GetDirectoryName(path);
var fileName = CloudPath.GetFileName(path);

var folder = await api.GetFileByPath(folderName);
if (folder == null)
throw new InvalidOperationException(string.Format("Folder does not exist: {0}", folderName));

file = new File()
{
Name = fileName,
Parents = new[] {folder.Id},
Name = fileName
};

if (!string.IsNullOrEmpty(folderName))
{
var folder = await api.GetFileByPath(folderName);
if (folder == null)
throw new InvalidOperationException(string.Format("Folder does not exist: {0}", folderName));

file.Parents = new[] {folder.Id};
}

progress = await api.Files.Create(file, stream, "application/octet-stream").UploadAsync();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public async Task Initialize()
this.RedirectionUrl = new Uri(HiDriveHelper.RedirectUri);
}

public bool CanClaim(Uri uri, string documentTitle)
{
return uri.ToString().StartsWith(this.RedirectionUrl.ToString(), StringComparison.OrdinalIgnoreCase);
}

public async Task<bool> Claim(Uri uri, string documentTitle)
{
var code = _authenticator.GetAuthorizationCodeFromResponseUrl(uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public async Task Initialize()
this.RedirectionUrl = new Uri(HubiCHelper.RedirectUri);
}

public bool CanClaim(Uri uri, string documentTitle)
{
return uri.ToString().StartsWith(this.RedirectionUrl.ToString(), StringComparison.OrdinalIgnoreCase);
}

public async Task<bool> Claim(Uri uri, string documentTitle)
{
//_token = HubiCHelper.GetAccessTokenFromFragment(uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public async Task Initialize()
this.AuthorizationUrl = new Uri(url);
}

public bool CanClaim(Uri uri, string documentTitle)
{
return uri.ToString().StartsWith(this.RedirectionUrl.ToString(), StringComparison.OrdinalIgnoreCase);
}

public async Task<bool> Claim(Uri uri, string documentTitle)
{
var authenticationResponseValues = UrlHelper.GetQueryOptions(uri);
Expand Down
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
set version=1.4.0
set version=1.4.1
set zip="packages\7-Zip.CommandLine.9.20.0\tools\7za.exe"
set msbuildcmd="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsMSBuildCmd.bat"

Expand Down
15 changes: 13 additions & 2 deletions chocolatey/keepass-plugin-keeanywhere.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>keepass-plugin-keeanywhere</id>
<title>KeePass Plugin KeeAnywhere</title>
<version>1.4.0</version>
<version>1.4.1</version>
<authors>Daniel Bölts</authors>
<owners>Kyrodan</owners>
<summary>Plugin for KeePass 2.x to to add support for cloud storage providers</summary>
Expand Down Expand Up @@ -31,7 +31,18 @@ Supported providers:
<copyright>© 2015-2017 Daniel Bölts</copyright>
<licenseUrl>https://github.com/Kyrodan/KeeAnywhere/blob/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>## 1.4.0 (2017-05-31)
<releaseNotes>## 1.4.1 (2017-06-02)

This is a bug-fixing release only

### Fixed

- \#86 Error when opening KeeAnywhere Settings 1.4.0
- \#87 Authentication failed with Google Drive
- \#88 Google Drive: can't open/save database to/from root folder


## 1.4.0 (2017-05-31)

This release brings two new features: Offline-Caching and Simple Automatic Backup.

Expand Down
2 changes: 1 addition & 1 deletion version_manifest.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
:
KeeAnywhere:1.4.0.0
KeeAnywhere:1.4.1.0
:

0 comments on commit d24bb2e

Please sign in to comment.