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 ability to create new secret versions and edit #69

Merged
merged 8 commits into from
Jul 28, 2024
Merged
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: 1 addition & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
pull_request:
branches:
- "*"
workflow_dispatch:

permissions:
contents: write
Expand Down
8 changes: 4 additions & 4 deletions Desktop/Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<OutputType>WinExe</OutputType>
<!--If you are willing to use Windows/MacOS native APIs you will need to create 3 projects.
One for Windows with net7.0-windows TFM, one for MacOS with net7.0-macos and one with net7.0 TFM for Linux.-->
<TargetFramework>net8.0</TargetFramework>
<!-- <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net8.0-macos</TargetFrameworks> -->
<!--<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>-->
<TargetFrameworks>net8.0</TargetFrameworks>
<!-- <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net8.0-macos</TargetFrameworks> -->
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>false</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
Expand Down Expand Up @@ -42,7 +42,7 @@


<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="11.1.0-rc2" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.1" />
</ItemGroup>


Expand Down
19 changes: 1 addition & 18 deletions KeyVaultExplorer/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,7 @@ public App()
DataContext = new AppViewModel();
}

public static void ConfigureDesktopServices()
{
IServiceCollection serviceCollection = new ServiceCollection();
serviceCollection.AddMemoryCache();
serviceCollection.AddSingleton<AuthService>();
serviceCollection.AddSingleton<VaultService>();
serviceCollection.AddSingleton<TabViewPageViewModel>();
serviceCollection.AddSingleton<ToolBarViewModel>();
serviceCollection.AddSingleton<KeyVaultTreeListViewModel>();
serviceCollection.AddSingleton<SettingsPageViewModel>();
serviceCollection.AddSingleton<MainViewModel>();
serviceCollection.AddSingleton<NotificationViewModel>();
serviceCollection.AddSingleton<KvExplorerDb>();
serviceCollection.AddTransient<AppSettingReader>();
serviceCollection.AddSingleton<IClipboard, ClipboardService>();
serviceCollection.AddSingleton<IStorageProvider, StorageProviderService>();
}


public static void CreateDesktopResources()
{
Directory.CreateDirectory(Constants.LocalAppDataFolder);
Expand Down
Binary file added KeyVaultExplorer/Assets/Add.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 KeyVaultExplorer/Assets/Certificate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions KeyVaultExplorer/Assets/Certificate.svg
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 KeyVaultExplorer/Assets/Key.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions KeyVaultExplorer/Assets/Key.svg
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 KeyVaultExplorer/Assets/Lock.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 KeyVaultExplorer/Assets/Lock.svg
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 KeyVaultExplorer/Assets/NewKey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions KeyVaultExplorer/Database/KvExplorerDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public KvExplorerDb()

public static async void OpenSqlConnection()
{
string DataSource = Path.Combine(Constants.LocalAppDataFolder, "KeyVaultExplorer.db");
string DataSource = Path.Combine(Constants.DatabaseFilePath);
var pass = await DatabaseEncryptedPasswordManager.GetSecret();
var connection = new SqliteConnection($"Filename={DataSource}; Password={pass}");
connection.Open();
Expand Down Expand Up @@ -78,7 +78,7 @@ CREATE INDEX IF NOT EXISTS IX_QuickAccess_KeyVaultId ON QuickAccess (
await createTableCommand.ExecuteNonQueryAsync();
}

public IEnumerable<QuickAccess> GetQuickAccessItems()
public List<QuickAccess> GetQuickAccessItems()
{
var command = _connection.CreateCommand();
command.CommandText = "SELECT Id, Name, VaultUri, KeyVaultId, SubscriptionDisplayName, SubscriptionId, TenantId, Location FROM QuickAccess;";
Expand Down Expand Up @@ -128,7 +128,7 @@ public async IAsyncEnumerable<QuickAccess> GetQuickAccessItemsAsyncEnumerable()
}
}

public async Task<bool> QuickAccessItemByKeyVaultIdExists(string keyVaultId)
public async Task<bool> QuickAccessItemByKeyVaultIdExists(string? keyVaultId)
{
var command = _connection.CreateCommand();
command.CommandText = "SELECT 1 FROM QuickAccess WHERE KeyVaultId = @KeyVaultId LIMIT 1;";
Expand Down Expand Up @@ -193,7 +193,7 @@ public async Task<AppSettings> GetToggleSettings()
return settings;
}

public async Task<IEnumerable<Subscriptions>> GetStoredSubscriptions()
public async Task<List<Subscriptions>> GetStoredSubscriptions()
{
var command = _connection.CreateCommand();
command.CommandText = "SELECT DisplayName, SubscriptionId, TenantId FROM Subscriptions;";
Expand Down
26 changes: 22 additions & 4 deletions KeyVaultExplorer/Exceptions/KvExceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,36 @@ public KeyVaultItemNotFailedToUpdate(string message, Exception inner)
}
}

public class KeyVaultInSufficientPrivileges : Exception
public class KeyVaultInsufficientPrivilegesException : Exception
{
public KeyVaultInSufficientPrivileges()
public KeyVaultInsufficientPrivilegesException()
{
}

public KeyVaultInSufficientPrivileges(string message)
public KeyVaultInsufficientPrivilegesException(string message)
: base(message)
{
}

public KeyVaultInSufficientPrivileges(string message, Exception inner)
public KeyVaultInsufficientPrivilegesException(string message, Exception inner)
: base(message, inner)
{
}
}


public class SubscriptionInsufficientPrivileges : Exception
{
public SubscriptionInsufficientPrivileges()
{
}

public SubscriptionInsufficientPrivileges(string message)
: base(message)
{
}

public SubscriptionInsufficientPrivileges(string message, Exception inner)
: base(message, inner)
{
}
Expand Down
24 changes: 16 additions & 8 deletions KeyVaultExplorer/KeyVaultExplorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,24 @@


<ItemGroup>
<None Remove="Assets\Add.png" />
<None Remove="Assets\AppIcon.ico" />
<None Remove="Assets\Certificate.png" />
<None Remove="Assets\Certificate.svg" />
<None Remove="Assets\Close.svg" />
<None Remove="Assets\Cloud.png" />
<None Remove="Assets\Cloud.svg" />
<None Remove="Assets\CollapseAll.svg" />
<None Remove="Assets\folder.png" />
<None Remove="Assets\FolderClosed.svg" />
<None Remove="Assets\ForeignKey.svg" />
<None Remove="Assets\Key.png" />
<None Remove="Assets\Key.svg" />
<None Remove="Assets\KeyVault.svg" />
<None Remove="Assets\kv-gray.png" />
<None Remove="Assets\Lock.png" />
<None Remove="Assets\Lock.svg" />
<None Remove="Assets\NewKey.png" />
<None Remove="Assets\Pin.png" />
<None Remove="Assets\Pin.svg" />
<None Remove="Assets\Refresh.svg" />
Expand All @@ -42,17 +50,17 @@


<ItemGroup>
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.1.0-rc2" />
<PackageReference Include="Avalonia.Svg.Skia" Version="11.1.0-rc1" />
<PackageReference Include="DeviceId" Version="6.6.0" />
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.1.1" />
<PackageReference Include="Avalonia.Svg.Skia" Version="11.1.0" />
<PackageReference Include="DeviceId" Version="6.7.0" />
<PackageReference Include="FluentAvaloniaUI" Version="2.1.0-preview6" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0-rc2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0-preview.5.24306.7" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="9.0.0-preview.5.24306.3" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0-preview.6.24327.7" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="9.0.0-preview.6.24327.4" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0-preview.5.24306.7" />
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.61.3" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0-preview.6.24327.7" />
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.62.0" />
<PackageReference Include="Azure.ResourceManager.KeyVault" Version="1.3.0" />
<PackageReference Include="Azure.Security.KeyVault.Certificates" Version="4.6.0" />
<PackageReference Include="Azure.Security.KeyVault.Keys" Version="4.6.0" />
Expand Down
20 changes: 10 additions & 10 deletions KeyVaultExplorer/Models/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ namespace KeyVaultExplorer.Models;
public static class Constants
{
// database password file name
public const string EncryptedSecretFileName = "keyvaultexplorer_database_password.txt";
public const string KeychainSecretName = "keyvaultexplorer_database_password";
public const string KeychainServiceName = "keyvaultexplorer";
public const string ProtectedKeyFileName = "keyvaultexplorer_database_key.bin";
public const string DeviceFileTokenName = "keyvaultexplorer_database_device-token.txt";
public const string EncryptedSecretFileName = "azurekeyvaultexplorer_database_password.txt";
public const string KeychainSecretName = "azurekeyvaultexplorer_database_password";
public const string KeychainServiceName = "azurekeyvaultexplorer";
public const string ProtectedKeyFileName = "azurekeyvaultexplorer_database_key.bin";
public const string DeviceFileTokenName = "azurekeyvaultexplorer_database_device-token.txt";

//The Application or Client ID will be generated while registering the app in the Azure portal. Copy and paste the GUID.
public static readonly string ClientId = "fdc1e6da-d735-4627-af3e-d40377f55713";
Expand All @@ -29,16 +29,16 @@ public static class Constants
// Cache settings
public const string CacheFileName = "keyvaultexplorer_msal_cache.txt";

public static readonly string LocalAppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\KeyVaultExplorer";
public static readonly string LocalAppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\AzureKeyVaultExplorer";

public static readonly string DatabaseFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\KeyVaultExplorer\\KeyVaultExplorer.db";
public static readonly string DatabaseFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\AzureKeyVaultExplorer\\AzureKeyVaultExplorer.db";

public const string KeyChainServiceName = "keyvaultexplorer_msal_service";
public const string KeyChainAccountName = "keyvaultexplorer_msal_account";
public const string KeyChainServiceName = "azurekeyvaultexplorer_msal_service";
public const string KeyChainAccountName = "azurekeyvaultexplorer_msal_account";

public const string LinuxKeyRingSchema = "us.sidesteplabs.keyvaultexplorer.tokencache";
public const string LinuxKeyRingCollection = MsalCacheHelper.LinuxKeyRingDefaultCollection;
public const string LinuxKeyRingLabel = "MSAL token cache for key vault explorer.";
public const string LinuxKeyRingLabel = "MSAL token cache for azure key vault explorer.";
public static readonly KeyValuePair<string, string> LinuxKeyRingAttr1 = new KeyValuePair<string, string>("Version", "1");
public static readonly KeyValuePair<string, string> LinuxKeyRingAttr2 = new KeyValuePair<string, string>("ProductGroup", "MyApps");
}
2 changes: 2 additions & 0 deletions KeyVaultExplorer/Models/SubscriptionDataItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public partial class SubscriptionDataItem : ObservableObject
{
public SubscriptionData Data { get; set; } = null!;

public SubscriptionResource Resource { get; set; } = null!;

[ObservableProperty]
private bool isPinned;

Expand Down
64 changes: 61 additions & 3 deletions KeyVaultExplorer/Resources/Resources.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@



<SolidColorBrush x:Key="DynamicActiveBackgroundFAColor" Color="{DynamicResource SolidBackgroundFillColorBase}" />
<SolidColorBrush x:Key="DynamicActiveBackgroundFAColor" Color="{DynamicResource SolidBackgroundFillColorBase}" />
<!--<StaticResource x:Key="TabViewItemHeaderBackgroundSelected" ResourceKey="SelectedTabViewColorKv" />
<SolidColorBrush x:Key="SelectedTabViewColorKv" Color="Transparent" />-->

Expand Down Expand Up @@ -102,7 +102,7 @@

<Grid>
<!-- Blurred border -->
<Border Margin="25" BoxShadow="0 6 10 0 #4F000000">
<Border Margin="25" BoxShadow="0 4 10 0 #44000000">
<Border.Effect>
<BlurEffect Radius="25" />
</Border.Effect>
Expand All @@ -122,7 +122,7 @@
Background="{TemplateBinding Background}"
BackgroundSizing="CenterBorder"
BorderBrush="{DynamicResource SurfaceStrokeColorFlyoutBrush}"
BorderThickness="2"
BorderThickness="1"
CornerRadius="{TemplateBinding CornerRadius}">
<Border.RenderTransform>
<TranslateTransform X="-10" Y="-20" />
Expand All @@ -146,6 +146,64 @@



<ControlTheme x:Key="{x:Type MenuFlyoutPresenter}" TargetType="MenuFlyoutPresenter">
<Setter Property="Background" Value="{DynamicResource MenuFlyoutPresenterBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource MenuFlyoutPresenterBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource MenuFlyoutPresenterBorderThemeThickness}" />
<Setter Property="Padding" Value="{DynamicResource MenuFlyoutPresenterThemePadding}" />
<Setter Property="MaxWidth" Value="{DynamicResource FlyoutThemeMaxWidth}" />
<Setter Property="MinHeight" Value="{DynamicResource MenuFlyoutThemeMinHeight}" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="CornerRadius" Value="{DynamicResource OverlayCornerRadius}" />
<Setter Property="Template">
<ControlTemplate>

<Grid>
<!-- Blurred border -->
<Border Margin="25" BoxShadow="0 4 10 0 #44000000">
<Border.Effect>
<BlurEffect Radius="25" />
</Border.Effect>
<Border.RenderTransform>
<TranslateTransform X="-10" Y="-25" />
</Border.RenderTransform>
</Border>

<!-- Content Y="-20" -->

<!-- BoxShadow="0 2 10 0 #56000000" -->
<Border
Name="LayoutRoot"
Margin="25"
Padding="{DynamicResource FlyoutBorderThemePadding}"
VerticalAlignment="Top"
Background="{TemplateBinding Background}"
BackgroundSizing="CenterBorder"
BorderBrush="{DynamicResource SurfaceStrokeColorFlyoutBrush}"
BorderThickness="1"
CornerRadius="{TemplateBinding CornerRadius}">
<Border.RenderTransform>
<TranslateTransform X="-10" Y="-25" />
</Border.RenderTransform>
<ScrollViewer
Margin="{TemplateBinding Padding}"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
<ItemsPresenter
Name="PART_ItemsPresenter"
Grid.IsSharedSizeScope="True"
ItemsPanel="{TemplateBinding ItemsPanel}"
KeyboardNavigation.TabNavigation="Continue" />
</ScrollViewer>
</Border>
</Grid>

</ControlTemplate>
</Setter>
</ControlTheme>




</ResourceDictionary>
Loading