Skip to content

Commit aa6b384

Browse files
committed
Add support for secrets encryption per machine
Add optional Elevated/Restricted user feature
1 parent fdf0985 commit aa6b384

28 files changed

+375
-63
lines changed

KeyManager.Library.KeyGen/KeyManager.Library.KeyGen.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PropertyGroup>
1111
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
1212
<PackageId>Leosac.$(AssemblyName)</PackageId>
13-
<Version>1.18.1</Version>
13+
<Version>1.19.0</Version>
1414
<Title>Leosac Key Manager Key Generation Library</Title>
1515
<Company>Leosac SAS</Company>
1616
<Product>Leosac Key Manager</Product>

KeyManager.Library.KeyStore.File.UI/FileKeyStoreImportExportControl.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
<ColumnDefinition />
1818
<ColumnDefinition />
1919
</Grid.ColumnDefinitions>
20-
<Button Grid.Column="0" Margin="5" Height="128" Command="{Binding ImportCommand}">
20+
<Button Grid.Column="0" Margin="5" Height="128" Command="{Binding ImportCommand}" IsEnabled="{x:Static libui:UIPreferences.IsUserElevated}">
2121
<Button.Content>
2222
<WrapPanel>
2323
<materialDesign:PackIcon Kind="Import" Width="64" Height="64" />
2424
<TextBlock Text="{x:Static properties:Resources.Import}" VerticalAlignment="Center" Margin="3" />
2525
</WrapPanel>
2626
</Button.Content>
2727
</Button>
28-
<Button Grid.Column="1" Margin="5" Height="128" Command="{Binding ExportCommand}">
28+
<Button Grid.Column="1" Margin="5" Height="128" Command="{Binding ExportCommand}" IsEnabled="{x:Static libui:UIPreferences.IsUserElevated}">
2929
<Button.Content>
3030
<WrapPanel>
3131
<materialDesign:PackIcon Kind="Export" Width="64" Height="64" />

KeyManager.Library.KeyStore.File/KeyManager.Library.KeyStore.File.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PropertyGroup>
1212
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
1313
<PackageId>Leosac.$(AssemblyName)</PackageId>
14-
<Version>1.18.1</Version>
14+
<Version>1.19.0</Version>
1515
<Title>Leosac Key Manager File Key Store Library</Title>
1616
<Company>Leosac SAS</Company>
1717
<Product>Leosac Key Manager</Product>

KeyManager.Library.KeyStore.LCP/KeyManager.Library.KeyStore.LCP.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PropertyGroup>
1212
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
1313
<PackageId>Leosac.$(AssemblyName)</PackageId>
14-
<Version>1.18.1</Version>
14+
<Version>1.19.0</Version>
1515
<Title>Leosac Key Manager LCP Key Store Library</Title>
1616
<Company>Leosac SAS</Company>
1717
<Product>Leosac Key Manager</Product>

KeyManager.Library.Plugin.UI/KeyManager.Library.Plugin.UI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PropertyGroup>
1111
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
1212
<PackageId>Leosac.$(AssemblyName)</PackageId>
13-
<Version>1.18.1</Version>
13+
<Version>1.19.0</Version>
1414
<Title>Leosac Key Manager Plugin UI Library</Title>
1515
<Company>Leosac SAS</Company>
1616
<Product>Leosac Key Manager</Product>

KeyManager.Library.Plugin/KeyManager.Library.Plugin.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<PropertyGroup>
1010
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
1111
<PackageId>Leosac.$(AssemblyName)</PackageId>
12-
<Version>1.18.1</Version>
12+
<Version>1.19.0</Version>
1313
<Title>Leosac Key Manager Plugin Library</Title>
1414
<Company>Leosac SAS</Company>
1515
<Product>Leosac Key Manager</Product>

KeyManager.Library.UI/FavoriteKeyStoreSelectionControl.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
<materialDesign:DialogHost DialogTheme="Inherit"
1414
Identifier="FavSelectionDialog">
1515
<DockPanel LastChildFill="True">
16-
<Button DockPanel.Dock="Right" x:Name="btnNew" Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}" Width="24" Height="24" Margin="10" ToolTip="{x:Static properties:Resources.NewFavorite}" Click="BtnNew_Click">
16+
<Button DockPanel.Dock="Right" x:Name="btnNew" Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}" Width="24" Height="24" Margin="10" ToolTip="{x:Static properties:Resources.NewFavorite}" Click="BtnNew_Click"
17+
IsEnabled="{x:Static local:UIPreferences.IsUserElevated}">
1718
<materialDesign:PackIcon Kind="CreateNewFolderOutline" Height="16" Width="16"/>
1819
</Button>
1920
<ComboBox ItemsSource="{Binding Favorites.KeyStores, ElementName=userControl}" SelectedItem="{Binding SelectedKeyStoreFavorite, ElementName=userControl}" Margin="5"

KeyManager.Library.UI/KMSettings.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
using Leosac.SharedServices;
2+
using Newtonsoft.Json;
3+
using System.Security.Cryptography;
4+
using System.Text;
25

36
namespace Leosac.KeyManager.Library.UI
47
{
@@ -10,5 +13,35 @@ public string? FavoritesPath
1013
get => _favoritesPath;
1114
set => SetProperty(ref _favoritesPath, value);
1215
}
16+
17+
public string? ElevationCode { get; set; }
18+
19+
private string? _elevationCodePlain;
20+
[JsonIgnore]
21+
public string? ElevationCodePlain
22+
{
23+
get => _elevationCodePlain;
24+
set => SetProperty(ref _elevationCodePlain, value);
25+
}
26+
27+
public StoredSecretEncryptionType EncryptionType { get; set; } = StoredSecretEncryptionType.CustomKey;
28+
29+
public static string? ComputeCodeHash(string? code)
30+
{
31+
if (string.IsNullOrEmpty(code))
32+
{
33+
return null;
34+
}
35+
36+
return Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes("LKM;" + code)));
37+
}
38+
39+
public void Elevate(string code)
40+
{
41+
if (!string.IsNullOrEmpty(ElevationCode) && ComputeCodeHash(code) == ElevationCode)
42+
{
43+
UIPreferences.IsUserElevated = true;
44+
}
45+
}
1346
}
1447
}

KeyManager.Library.UI/KeyEntriesControl.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<ColumnDefinition />
3030
<ColumnDefinition />
3131
</Grid.ColumnDefinitions>
32-
<WrapPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Center">
32+
<WrapPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Center" IsEnabled="{x:Static local:UIPreferences.IsUserElevated}">
3333
<materialDesign:PopupBox
3434
PlacementMode="BottomAndAlignCentres"
3535
ToolTip="{x:Static properties:Resources.NewKeyEntry}" Margin="5"
@@ -147,7 +147,7 @@
147147
</Grid.ColumnDefinitions>
148148
<CheckBox Grid.Column="0" VerticalAlignment="Center" IsChecked="{Binding Selected}" Visibility="{Binding DataContext.ShowSelection, ElementName=keyStoreControl, Converter={StaticResource BooleanToVisibilityConverter}}" />
149149
<DockPanel Grid.Column="1" LastChildFill="True">
150-
<WrapPanel DockPanel.Dock="Right" Orientation="Horizontal">
150+
<WrapPanel DockPanel.Dock="Right" Orientation="Horizontal" IsEnabled="{x:Static local:UIPreferences.IsUserElevated}">
151151
<Button x:Name="btnEditKeyEntry" Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}" Command="{Binding DataContext.EditKeyEntryCommand, ElementName=keyStoreControl}" CommandParameter="{Binding}" ToolTip="{x:Static properties:Resources.EditKeyEntry}" Margin="3">
152152
<materialDesign:PackIcon Kind="Edit" Height="24" Width="24" Cursor="Hand" />
153153
</Button>

KeyManager.Library.UI/KeyManager.Library.UI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PropertyGroup>
1212
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
1313
<PackageId>Leosac.$(AssemblyName)</PackageId>
14-
<Version>1.18.1</Version>
14+
<Version>1.19.0</Version>
1515
<Title>Leosac Key Manager UI Library</Title>
1616
<Company>Leosac SAS</Company>
1717
<Product>Leosac Key Manager</Product>

0 commit comments

Comments
 (0)