Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add self to a shared folder issue. #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cli/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Threading.Tasks;
using CommandLine;
using CommandLine.Text;
using KeeperSecurity.Utils;

namespace Cli
{
Expand Down
12 changes: 11 additions & 1 deletion Commander/NotConnectedCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public class NotConnectedCliContext : StateCommands
{
private readonly AuthSync _auth;

private class AppLoadOptions
{
[Option("config", Required = false, HelpText = "configuration file name")]
public string Config { get; set; }
}

private class CreateOptions
{
[Value(0, Required = true, MetaName = "email", HelpText = "account email")]
Expand Down Expand Up @@ -50,7 +56,11 @@ private class LoginOptions

public NotConnectedCliContext(bool autologin)
{
var storage = Program.CommanderStorage.GetConfigurationStorage(null, new CommanderConfigurationProtection());
string configFileName = null;
var res = Parser.Default.ParseArguments<AppLoadOptions>(Environment.GetCommandLineArgs());
res.WithParsed(o => { configFileName = o.Config; });

var storage = Program.CommanderStorage.GetConfigurationStorage(configFileName, new CommanderConfigurationProtection());
_auth = new AuthSync(storage)
{
Endpoint = {DeviceName = "Commander C#", ClientVersion = "c16.5.0"}
Expand Down
2 changes: 1 addition & 1 deletion Commander/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using KeeperSecurity.Utils;
using KeeperSecurity.Vault;
using Cli;
using System.Collections.Generic;

namespace Commander
{
Expand Down Expand Up @@ -43,6 +42,7 @@ private static void Main()

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
CommanderStorage = StorageUtils.SetupCommanderStorage();

if (!CommanderStorage.VerifyDatabase())
{
throw new Exception("Database is invalid.");
Expand Down
6 changes: 3 additions & 3 deletions KeeperSdk/KeeperSdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
<LangVersion>7.1</LangVersion>
<Version>1.0.7-beta01</Version>
<Version>1.0.7-beta03</Version>
<Authors>Keeper Security Inc.</Authors>
<Product>.NET Keeper Sdk</Product>
<PackageTags>keeper password manager</PackageTags>
Expand All @@ -13,8 +13,8 @@
<RepositoryType>Github</RepositoryType>
<PackageProjectUrl>https://github.com/Keeper-Security/keeper-sdk-dotnet</PackageProjectUrl>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<AssemblyVersion>1.0.7.42</AssemblyVersion>
<FileVersion>1.0.7.42</FileVersion>
<AssemblyVersion>1.0.7.43</AssemblyVersion>
<FileVersion>1.0.7.43</FileVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
<IncludeSymbols>true</IncludeSymbols>
Expand Down
20 changes: 16 additions & 4 deletions KeeperSdk/vault/SharedFolderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,20 @@ public async Task PutUserToSharedFolder(string sharedFolderUid,
}
else
{
var keyTuple = await GetUserPublicKeys(userId);
var publicKey = CryptoUtils.LoadPublicKey(keyTuple.Item1);
byte[] encryptedKey;
EncryptedKeyType encryptedKeyType;
if (string.Equals(userId, Auth.Username, StringComparison.InvariantCultureIgnoreCase))
{
encryptedKey = CryptoUtils.EncryptAesV1(sharedFolder.SharedFolderKey, Auth.AuthContext.DataKey);
encryptedKeyType = EncryptedKeyType.EncryptedByDataKey;
}
else
{
var keyTuple = await GetUserPublicKeys(userId);
var publicKey = CryptoUtils.LoadPublicKey(keyTuple.Item1);
encryptedKey = CryptoUtils.EncryptRsa(sharedFolder.SharedFolderKey, publicKey);
encryptedKeyType = EncryptedKeyType.EncryptedByPublicKey;
}
request.SharedFolderAddUser.Add(new Folder.SharedFolderUpdateUser
{
Username = userId,
Expand All @@ -61,8 +73,8 @@ public async Task PutUserToSharedFolder(string sharedFolderUid,
: options.ManageRecords.Value ? SetBooleanValue.BooleanTrue : SetBooleanValue.BooleanFalse,
TypedSharedFolderKey = new EncryptedDataKey
{
EncryptedKey = ByteString.CopyFrom(CryptoUtils.EncryptRsa(sharedFolder.SharedFolderKey, publicKey)),
EncryptedKeyType = EncryptedKeyType.EncryptedByPublicKey
EncryptedKey = ByteString.CopyFrom(encryptedKey),
EncryptedKeyType = encryptedKeyType,
},
});
}
Expand Down
1 change: 0 additions & 1 deletion KeeperSdk/vault/VaultOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using Google.Protobuf;
using KeeperSecurity.Authentication;
Expand Down