Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
6676986
x509: add utils to find certs by thumbprint
mjcheetham Aug 7, 2023
b627044
msauth: rename GetTokenAsync to GetTokenForUserAsync
mjcheetham Aug 3, 2023
89b099e
msauth: abstract token cache init helpers
mjcheetham Aug 8, 2023
6a90c36
msauth: add support for service principal auth
mjcheetham Aug 7, 2023
bfa87db
msauth: add support for managed identity
mjcheetham Aug 7, 2023
f00c859
msauth: add MSAL app token cache support for CCAs
mjcheetham Aug 8, 2023
aafbda4
azrepos: support service principals and managed IDs
mjcheetham Aug 7, 2023
eff4ea6
azrepos: add tests of MID and SP get credential
mjcheetham Aug 15, 2023
0704b42
release.yml: use correct target_commitish arg
mjcheetham Aug 16, 2023
a74fe18
release.yml: use correct target_commitish arg (#1381)
mjcheetham Aug 16, 2023
488aa48
Support managed identities and service principals (#1372)
mjcheetham Aug 16, 2023
527c41b
Use Avalonia 11.0.3
de1acr0ix Aug 17, 2023
cd0a34c
Update to Avalonia 11.0.4
de1acr0ix Aug 19, 2023
3fb216d
release: update homebrew deployment
ldennington Aug 19, 2023
e076f58
release: update homebrew deployment (#1386)
ldennington Aug 21, 2023
9902e8f
dependencies: update to Avalonia 11.0.4 (#1383)
ldennington Aug 28, 2023
b501b8b
github: support gist remote URLs for GitHub
mjcheetham Sep 5, 2023
afcb6b8
Support gist remote URLs for GitHub (#1402)
mjcheetham Sep 6, 2023
3774413
bitbucket: drop WPF-based UI helper for Bitbucket
mjcheetham Sep 11, 2023
7828213
github: drop WPF-based UI helper for GitHub
mjcheetham Sep 11, 2023
63133c9
gitlab: drop WPF-based UI helper for GitLab
mjcheetham Sep 11, 2023
11b5d50
gcm-ui: drop WPF-based UI helper for shared UI
mjcheetham Sep 11, 2023
8a098a4
wpf: drop shared WPF library
mjcheetham Sep 11, 2023
5c50a73
Support linux install path from src
m4ss1m0g Sep 12, 2023
53e2b48
install from source: custom install location edits
ldennington Sep 18, 2023
03a23a1
docs: update dev.azure.com product page URLs
mjcheetham Sep 18, 2023
e66805c
Merge pull request #1 from ldennington/install-from-source-suggestions
m4ss1m0g Sep 19, 2023
fde8bbd
Update dev.azure.com product page URLs (#1416)
mjcheetham Sep 19, 2023
c99ef6d
build(deps): bump DavidAnson/markdownlint-cli2-action
dependabot[bot] Sep 19, 2023
01ce22b
build(deps): bump DavidAnson/markdownlint-cli2-action from 11.0.0 to …
mjcheetham Sep 19, 2023
8f925d3
build(deps): bump actions/checkout from 3 to 4
dependabot[bot] Sep 19, 2023
6fbc243
build(deps): bump actions/checkout from 3 to 4 (#1397)
mjcheetham Sep 19, 2023
1e904d1
msauth: replace WPF progress window with Avalonia
mjcheetham Sep 11, 2023
24c1883
build(deps): bump DavidAnson/markdownlint-cli2-action
dependabot[bot] Sep 20, 2023
6e49d9e
build(deps): bump DavidAnson/markdownlint-cli2-action from 12.0.0 to …
ldennington Sep 21, 2023
ac0b264
Drop WPF-based UI helpers on Windows (#1417)
mjcheetham Sep 21, 2023
3b6b07d
install from source: refactor install location
ldennington Sep 25, 2023
720d347
install from source: correct path addition
ldennington Sep 25, 2023
e1064f3
avalonia: remove workaround for devtools and app lifetime
mjcheetham Sep 26, 2023
54f6b46
Merge pull request #2 from ldennington/linux-install-fixes
m4ss1m0g Oct 2, 2023
f4f3689
recognise GitLab hosts by WWW-Authenticate header
hickford Oct 3, 2023
531d7ed
release: change dotnet to .NET and loosen version requirements
ldennington Oct 6, 2023
5562307
release: add permissions and prereqs
ldennington Oct 6, 2023
27d7636
release: update Linux to use GPG signing
ldennington Oct 7, 2023
16e628a
release: update macOS signing
ldennington Oct 12, 2023
4d3a8f1
release: update Windows to use Azure Code Signing
ldennington Oct 10, 2023
961a213
release: update .NET tool azure connection/variables
ldennington Oct 7, 2023
8f93d56
release: validate linux signatures
ldennington Oct 16, 2023
d0ae441
recognise GitLab hosts by WWW-Authenticate header (#1428)
ldennington Oct 18, 2023
12ab89b
recognise BitBucket hosts by WWW-Authenticate header
hickford Oct 19, 2023
ba2dcec
recognise BitBucket hosts by WWW-Authenticate header (#1441)
mjcheetham Oct 19, 2023
62eb6ab
Support linux install path from src (#1409)
ldennington Oct 19, 2023
c512d1b
use universal Gitea OAuth configuration
hickford Oct 19, 2023
46810df
avalonia: introduce flag to switch to SW rendering
mjcheetham Sep 28, 2023
2fd111b
release: update Linux, macOS, and Windows signing (#1431)
ldennington Oct 21, 2023
ee35d7b
default OAuth redirect URI to http://127.0.0.1
hickford Oct 20, 2023
66292a9
Apply suggestions from code review
hickford Oct 23, 2023
6e06153
use universal Gitea OAuth configuration (#1442)
mjcheetham Oct 24, 2023
e549586
default OAuth redirect URI to http://127.0.0.1 (#1444)
mjcheetham Oct 24, 2023
3183801
settings: default SW rendering on Windows+ARM
mjcheetham Oct 23, 2023
81211fb
platformutils: drop unnecessary netfx #ifdefs
mjcheetham Oct 25, 2023
b30eab3
Add software rendering flag for Windows (#1445)
mjcheetham Oct 25, 2023
59f01d9
platformutils: drop unnecessary netfx #ifdefs (#1447)
mjcheetham Oct 25, 2023
d928878
avalonia: actually setup Avalonia before starting
mjcheetham Oct 30, 2023
97a217d
avalonia: actually setup Avalonia before starting (#1453)
mjcheetham Oct 30, 2023
3a60ecf
version: bump to 2.4.0
mjcheetham Nov 1, 2023
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
Prev Previous commit
Next Next commit
msauth: replace WPF progress window with Avalonia
  • Loading branch information
mjcheetham committed Sep 20, 2023
commit 1e904d1035641393ce87c8297670574ff0197f32
96 changes: 10 additions & 86 deletions src/shared/Core/Authentication/MicrosoftAuthentication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
using System.Text;
using System.Threading;
using GitCredentialManager.UI;
using GitCredentialManager.UI.Controls;
using GitCredentialManager.UI.ViewModels;
using GitCredentialManager.UI.Views;
using Microsoft.Identity.Client.AppConfig;

#if NETFRAMEWORK
using System.Drawing;
using System.Windows.Forms;
using Microsoft.Identity.Client.Broker;
#endif

Expand Down Expand Up @@ -118,10 +117,6 @@ public class MicrosoftAuthentication : AuthenticationBase, IMicrosoftAuthenticat
"live", "liveconnect", "liveid",
};

#if NETFRAMEWORK
private DummyWindow _dummyWindow;
#endif

public MicrosoftAuthentication(ICommandContext context)
: base(context) { }

Expand All @@ -130,6 +125,8 @@ public MicrosoftAuthentication(ICommandContext context)
public async Task<IMicrosoftAuthenticationResult> GetTokenForUserAsync(
string authority, string clientId, Uri redirectUri, string[] scopes, string userName, bool msaPt)
{
var uiCts = new CancellationTokenSource();

// Check if we can and should use OS broker authentication
bool useBroker = CanUseBroker();
Context.Trace.WriteLine(useBroker
Expand All @@ -144,7 +141,7 @@ public async Task<IMicrosoftAuthenticationResult> GetTokenForUserAsync(
try
{
// Create the public client application for authentication
IPublicClientApplication app = await CreatePublicClientApplicationAsync(authority, clientId, redirectUri, useBroker, msaPt);
IPublicClientApplication app = await CreatePublicClientApplicationAsync(authority, clientId, redirectUri, useBroker, msaPt, uiCts);

AuthenticationResult result = null;

Expand Down Expand Up @@ -261,10 +258,8 @@ public async Task<IMicrosoftAuthenticationResult> GetTokenForUserAsync(
}
finally
{
#if NETFRAMEWORK
// If we created a dummy window during authentication we should dispose of it now that we're done
_dummyWindow?.Dispose();
#endif
// If we created some global UI (e.g. progress) during authentication we should dismiss them now that we're done
uiCts.Cancel();
}
}

Expand Down Expand Up @@ -451,8 +446,8 @@ private async Task<AuthenticationResult> GetAccessTokenSilentlyAsync(
}
}

private async Task<IPublicClientApplication> CreatePublicClientApplicationAsync(
string authority, string clientId, Uri redirectUri, bool enableBroker, bool msaPt)
private async Task<IPublicClientApplication> CreatePublicClientApplicationAsync(string authority,
string clientId, Uri redirectUri, bool enableBroker, bool msaPt, CancellationTokenSource uiCts)
{
var httpFactoryAdaptor = new MsalHttpClientFactoryAdaptor(Context.HttpClientFactory);

Expand Down Expand Up @@ -495,11 +490,8 @@ private async Task<IPublicClientApplication> CreatePublicClientApplicationAsync(
}
else if (enableBroker) // Only actually need to set a parent window when using the Windows broker
{
#if NETFRAMEWORK
Context.Trace.WriteLine($"Using dummy parent window for MSAL authentication dialogs.");
_dummyWindow = new DummyWindow();
appBuilder.WithParentActivityOrWindow(_dummyWindow.ShowAndGetHandle);
#endif
Context.Trace.WriteLine("Using progress parent window for MSAL authentication dialogs.");
appBuilder.WithParentActivityOrWindow(() => ProgressWindow.ShowAndGetHandle(uiCts.Token));
}
}
}
Expand Down Expand Up @@ -899,73 +891,5 @@ public MsalResult(AuthenticationResult msalResult)
public string AccessToken => _msalResult.AccessToken;
public string AccountUpn => _msalResult.Account?.Username;
}

#if NETFRAMEWORK
private class DummyWindow : IDisposable
{
private readonly Thread _staThread;
private readonly ManualResetEventSlim _readyEvent;
private Form _window;
private IntPtr _handle;

public DummyWindow()
{
_staThread = new Thread(ThreadProc);
_staThread.SetApartmentState(ApartmentState.STA);
_readyEvent = new ManualResetEventSlim();
}

public IntPtr ShowAndGetHandle()
{
_staThread.Start();
_readyEvent.Wait();
return _handle;
}

public void Dispose()
{
_window?.Invoke(() => _window.Close());

if (_staThread.IsAlive)
{
_staThread.Join();
}
}

private void ThreadProc()
{
System.Windows.Forms.Application.EnableVisualStyles();
_window = new Form
{
TopMost = true,
ControlBox = false,
MaximizeBox = false,
MinimizeBox = false,
ClientSize = new Size(182, 46),
FormBorderStyle = FormBorderStyle.None,
StartPosition = FormStartPosition.CenterScreen,
};

var progress = new ProgressBar
{
Style = ProgressBarStyle.Marquee,
Location = new Point(12, 12),
Size = new Size(158, 23),
MarqueeAnimationSpeed = 30,
};

_window.Controls.Add(progress);
_window.Shown += (s, e) =>
{
_handle = _window.Handle;
_readyEvent.Set();
};

_window.ShowDialog();
_window.Dispose();
_window = null;
}
}
#endif
}
}
14 changes: 14 additions & 0 deletions src/shared/Core/UI/Controls/ProgressWindow.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Window xmlns="https://github.com/avaloniaui"
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"
mc:Ignorable="d" d:DesignWidth="182" d:DesignHeight="46"
SizeToContent="WidthAndHeight" CanResize="False" Topmost="True"
ExtendClientAreaChromeHints="NoChrome" ExtendClientAreaToDecorationsHint="True"
ShowInTaskbar="False" Title="Git Credential Manager" WindowStartupLocation="CenterScreen"
x:Class="GitCredentialManager.UI.Controls.ProgressWindow">
<ProgressBar Orientation="Horizontal"
IsIndeterminate="True"
Margin="20"
Width="158" Height="23" />
</Window>
37 changes: 37 additions & 0 deletions src/shared/Core/UI/Controls/ProgressWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace GitCredentialManager.UI.Controls;

public partial class ProgressWindow : Window
{
public ProgressWindow()
{
InitializeComponent();
}

private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}

public static IntPtr ShowAndGetHandle(CancellationToken ct)
{
var tsc = new TaskCompletionSource<IntPtr>();

Window CreateWindow()
{
var window = new ProgressWindow();
window.Loaded += (s, e) => tsc.SetResult(window.TryGetPlatformHandle()?.Handle ?? IntPtr.Zero);
return window;
}

Task _ = AvaloniaUi.ShowWindowAsync(CreateWindow, IntPtr.Zero, ct);

return tsc.Task.GetAwaiter().GetResult();
}
}