-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add access policy creation/deletion to vault viewer
- Loading branch information
1 parent
a7e2c86
commit 09966e2
Showing
7 changed files
with
336 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<controls:MetroWindow x:Class="AzureKeyVaultManager.CreateAccessPolicy" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:AzureKeyVaultManager" | ||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls" | ||
mc:Ignorable="d" | ||
BorderBrush="{StaticResource AccentColorBrush}" | ||
WindowStartupLocation="CenterOwner" | ||
Title="Create Access Policy" Height="450" Width="400"> | ||
<Window.Resources> | ||
<Style x:Key="defaultMessageStyle" TargetType="TextBox"> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="TextBox"> | ||
<Grid> | ||
<TextBox Text="{Binding Text, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" /> | ||
<TextBlock HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Text="Enter Azure Active Directory 'Display Name' search" | ||
Margin="5,0,5,0" | ||
Foreground="#FF808080" | ||
FontStyle="Italic" | ||
IsHitTestVisible="False" | ||
x:Name="UserMessage" | ||
Visibility="Hidden"/> | ||
</Grid> | ||
<ControlTemplate.Triggers> | ||
<MultiTrigger> | ||
<MultiTrigger.Conditions> | ||
<Condition Property="Text" Value=""/> | ||
<Condition Property="IsKeyboardFocusWithin" Value="False"/> | ||
</MultiTrigger.Conditions> | ||
<Setter Property="Visibility" TargetName="UserMessage" Value="Visible"/> | ||
</MultiTrigger> | ||
</ControlTemplate.Triggers> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
</Window.Resources> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="25" /> | ||
<RowDefinition MinHeight="100" Height="100" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
<TextBox Name="searchFilter" Style="{StaticResource defaultMessageStyle}" TextChanged="FilterTextChanged"></TextBox> | ||
<ListBox Name="adObjects" Grid.Row="1"> | ||
<ListBox.ItemTemplate> | ||
<DataTemplate> | ||
<Grid Margin="0,2"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="100" /> | ||
<ColumnDefinition Width="10" /> | ||
<ColumnDefinition Width="200" /> | ||
<ColumnDefinition Width="10" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
<TextBlock Grid.Column="0" Text="{Binding ObjectType}" /> | ||
<TextBlock Grid.Column="2" Text="{Binding DisplayName}" /> | ||
<TextBlock Grid.Column="4" Text="{Binding ObjectId}" /> | ||
</Grid> | ||
</DataTemplate> | ||
</ListBox.ItemTemplate> | ||
</ListBox> | ||
|
||
<GridSplitter Grid.Row="2" Height="10" ResizeDirection="Rows" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> | ||
|
||
<StackPanel Orientation="Vertical" Grid.Row="3"> | ||
<GroupBox Header="Keys" Name="keyGroup"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="25" /> | ||
<RowDefinition Height="25" /> | ||
<RowDefinition Height="25" /> | ||
<RowDefinition Height="25" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
<CheckBox Grid.Row="0" Grid.Column="0" IsChecked="{Binding CanEncrypt}">Encrypt</CheckBox> | ||
<CheckBox Grid.Row="1" Grid.Column="0" IsChecked="{Binding CanDecrypt}">Decrypt</CheckBox> | ||
<CheckBox Grid.Row="0" Grid.Column="1" IsChecked="{Binding CanWrap}">Wrap</CheckBox> | ||
<CheckBox Grid.Row="1" Grid.Column="1" IsChecked="{Binding CanUnwrap}">Unwrap</CheckBox> | ||
<CheckBox Grid.Row="0" Grid.Column="2" IsChecked="{Binding CanSign}">Sign</CheckBox> | ||
<CheckBox Grid.Row="1" Grid.Column="2" IsChecked="{Binding CanVerify}">Verify</CheckBox> | ||
|
||
<CheckBox Grid.Row="2" Grid.Column="0" IsChecked="{Binding CanCreate}">Create</CheckBox> | ||
<CheckBox Grid.Row="2" Grid.Column="1" IsChecked="{Binding CanUpdate}">Update</CheckBox> | ||
<CheckBox Grid.Row="2" Grid.Column="2" IsChecked="{Binding CanDelete}">Delete</CheckBox> | ||
|
||
<CheckBox Grid.Row="3" Grid.Column="0" IsChecked="{Binding CanBackup}">Backup</CheckBox> | ||
<CheckBox Grid.Row="3" Grid.Column="1" IsChecked="{Binding CanRestore}">Restore</CheckBox> | ||
<CheckBox Grid.Row="3" Grid.Column="2" IsChecked="{Binding CanImport}">Import</CheckBox> | ||
</Grid> | ||
</GroupBox> | ||
|
||
<GroupBox Header="Secrets" Name="secretGroup"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="25" /> | ||
<RowDefinition Height="25" /> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
<CheckBox Grid.Row="0" Grid.Column="0" IsChecked="{Binding CanGet}">Get</CheckBox> | ||
<CheckBox Grid.Row="0" Grid.Column="1" IsChecked="{Binding CanList}">List</CheckBox> | ||
<CheckBox Grid.Row="1" Grid.Column="0" IsChecked="{Binding CanSet}">Set</CheckBox> | ||
<CheckBox Grid.Row="1" Grid.Column="1" IsChecked="{Binding CanDelete}">Delete</CheckBox> | ||
</Grid> | ||
</GroupBox> | ||
<Button Width="120" Click="CreateClicked">Create</Button> | ||
</StackPanel> | ||
</Grid> | ||
</controls:MetroWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System.Timers; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using AzureKeyVaultManager.KeyVaultWrapper.Policies; | ||
using MahApps.Metro.Controls; | ||
using Microsoft.Azure.ActiveDirectory.GraphClient; | ||
using Application = Microsoft.Azure.ActiveDirectory.GraphClient.Application; | ||
|
||
namespace AzureKeyVaultManager | ||
{ | ||
/// <summary> | ||
/// Interaction logic for CreateAccessPolicy.xaml | ||
/// </summary> | ||
public partial class CreateAccessPolicy : MetroWindow | ||
{ | ||
public string ObjectId { get; set; } | ||
public string ApplicationId { get; set; } | ||
public KeyAccessPolicy KeyAccessPolicy { get; set; } | ||
public SecretAccessPolicy SecretAccessPolicy { get; set; } | ||
|
||
private Timer FilterChangedTimer { get; } | ||
private bool FilterChangedTimerElapsed { get; set; } | ||
private string LastRequest { get; set; } | ||
|
||
public CreateAccessPolicy() | ||
{ | ||
InitializeComponent(); | ||
|
||
FilterChangedTimer = new Timer(1000); | ||
FilterChangedTimer.Elapsed += (sender, args) => | ||
{ | ||
FilterChangedTimer.Enabled = false; | ||
FilterChangedTimerElapsed = true; | ||
Dispatcher.Invoke(() => | ||
{ | ||
if (LastRequest != searchFilter.Text) | ||
FilterTextChanged(null, null); | ||
}); | ||
}; | ||
FilterChangedTimer.Enabled = true; | ||
|
||
Loaded += (sender, args) => | ||
{ | ||
keyGroup.DataContext = new KeyAccessPolicy(); | ||
secretGroup.DataContext = new SecretAccessPolicy(); | ||
}; | ||
} | ||
|
||
private async void FilterTextChanged(object sender, TextChangedEventArgs e) | ||
{ | ||
if (!FilterChangedTimer.Enabled) | ||
FilterChangedTimer.Enabled = true; | ||
else | ||
{ | ||
FilterChangedTimer.Enabled = false; | ||
FilterChangedTimer.Enabled = true; | ||
return; | ||
} | ||
|
||
LastRequest = searchFilter.Text; | ||
|
||
if (searchFilter.Text != null && !string.IsNullOrWhiteSpace(searchFilter.Text) && searchFilter.Text.Length > 4) | ||
adObjects.ItemsSource = await AzureServiceAdapter.Instance.GetAllDirectoryObjects(searchFilter.Text); | ||
} | ||
|
||
private void CreateClicked(object sender, RoutedEventArgs e) | ||
{ | ||
KeyAccessPolicy = (KeyAccessPolicy) keyGroup.DataContext; | ||
SecretAccessPolicy = (SecretAccessPolicy)secretGroup.DataContext; | ||
|
||
var selectedObject = (IDirectoryObject) adObjects.SelectedItem; | ||
if (selectedObject is Application) | ||
ApplicationId = ((Application) selectedObject).AppId; | ||
if (selectedObject is ServicePrincipal) | ||
ApplicationId = ((ServicePrincipal)selectedObject).AppId; | ||
|
||
ObjectId = selectedObject.ObjectId; | ||
|
||
DialogResult = true; | ||
this.Close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.