Skip to content

Commit

Permalink
Merge pull request #293 from microsoft/staging
Browse files Browse the repository at this point in the history
Release - 12/12/23
  • Loading branch information
EricJohnson327 authored Dec 11, 2023
2 parents 90abdf8 + 621ebfc commit 866b2a3
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 25 deletions.
9 changes: 6 additions & 3 deletions build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ parameters:
- release

variables:
MSIXVersion: '0.700'
MSIXVersion: '0.800'
solution: '**/GitHubExtension.sln'
appxPackageDir: 'AppxPackages'
testOutputArtifactDir: 'TestResults'
Expand Down Expand Up @@ -235,8 +235,11 @@ extends:
- task: PublishSymbols@2
displayName: Publish Symbols
inputs:
SearchPattern: '**/BuildOutput/**/*.pdb'
IndexSources: false
SearchPattern: >-
$(Build.SourcesDirectory)\BuildOutput\**\*.pdb
$(Build.SourcesDirectory)\obj\**\*.r2r.ni.pdb
IndexSources: true
SymbolServerType: TeamServices
SymbolsProduct: DevHomeGitHubExtension

Expand Down
2 changes: 1 addition & 1 deletion build/scripts/CreateBuildInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Param(
)

$Major = "0"
$Minor = "7"
$Minor = "8"
$Patch = "99" # default to 99 for local builds

$versionSplit = $Version.Split(".");
Expand Down
49 changes: 43 additions & 6 deletions src/GitHubExtension/DeveloperId/DeveloperIdProvider.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

using System.Security;
using Microsoft.UI;
using Microsoft.Windows.DevHome.SDK;
using Octokit;
Expand Down Expand Up @@ -93,7 +94,7 @@ public IAsyncOperation<IDeveloperId> LoginNewDeveloperIdAsync()

oauthRequest.AwaitCompletion();

var devId = CreateOrUpdateDeveloperId(oauthRequest);
var devId = CreateOrUpdateDeveloperIdFromOauthRequest(oauthRequest);
oauthRequest.Dispose();

Log.Logger()?.ReportInfo($"New DeveloperId logged in");
Expand All @@ -102,6 +103,28 @@ public IAsyncOperation<IDeveloperId> LoginNewDeveloperIdAsync()
}).AsAsyncOperation();
}

private DeveloperId LoginNewDeveloperIdWithPAT(Uri hostAddress, SecureString personalAccessToken)
{
try
{
GitHubClient gitHubClient = new (new ProductHeaderValue(Constants.DEV_HOME_APPLICATION_NAME), hostAddress);
var credentials = new Credentials(new System.Net.NetworkCredential(string.Empty, personalAccessToken).Password);
gitHubClient.Credentials = credentials;
var newUser = gitHubClient.User.Current().Result;
DeveloperId developerId = new (newUser.Login, newUser.Name, newUser.Email, newUser.Url, gitHubClient);
SaveOrOverwriteDeveloperId(developerId, personalAccessToken);

Log.Logger()?.ReportInfo($"{developerId.LoginId} logged in with PAT flow to {developerId.GetHostAddress()}");

return developerId;
}
catch (Exception ex)
{
Log.Logger()?.ReportError($"Error while logging in with PAT to {hostAddress.AbsoluteUri} : {ex.Message}");
throw;
}
}

private OAuthRequest? LoginNewDeveloperId()
{
OAuthRequest oauthRequest = new ();
Expand Down Expand Up @@ -208,10 +231,8 @@ public DeveloperId GetDeveloperIdInternal(IDeveloperId devId)
}

// Internal Functions.
private DeveloperId CreateOrUpdateDeveloperId(OAuthRequest oauthRequest)
private void SaveOrOverwriteDeveloperId(DeveloperId newDeveloperId, SecureString accessToken)
{
// Query necessary data and populate Developer Id.
var newDeveloperId = oauthRequest.RetrieveDeveloperId();
var duplicateDeveloperIds = DeveloperIds.Where(d => d.Url.Equals(newDeveloperId.Url, StringComparison.OrdinalIgnoreCase));

if (duplicateDeveloperIds.Any())
Expand All @@ -220,7 +241,7 @@ private DeveloperId CreateOrUpdateDeveloperId(OAuthRequest oauthRequest)
try
{
// Save the credential to Credential Vault.
CredentialVault.SaveAccessTokenToVault(duplicateDeveloperIds.Single().LoginId, oauthRequest.AccessToken);
CredentialVault.SaveAccessTokenToVault(duplicateDeveloperIds.Single().LoginId, accessToken);

try
{
Expand All @@ -244,7 +265,7 @@ private DeveloperId CreateOrUpdateDeveloperId(OAuthRequest oauthRequest)
DeveloperIds.Add(newDeveloperId);
}

CredentialVault.SaveAccessTokenToVault(newDeveloperId.LoginId, oauthRequest.AccessToken);
CredentialVault.SaveAccessTokenToVault(newDeveloperId.LoginId, accessToken);

try
{
Expand All @@ -255,6 +276,22 @@ private DeveloperId CreateOrUpdateDeveloperId(OAuthRequest oauthRequest)
Log.Logger()?.ReportError($"LoggedIn event signaling failed: {error}");
}
}
}

private DeveloperId CreateOrUpdateDeveloperIdFromOauthRequest(OAuthRequest oauthRequest)
{
// Query necessary data and populate Developer Id.
var newDeveloperId = oauthRequest.RetrieveDeveloperId();
var accessToken = oauthRequest.AccessToken;
if (accessToken is null)
{
Log.Logger()?.ReportError($"Invalid AccessToken");
throw new InvalidOperationException();
}

SaveOrOverwriteDeveloperId(newDeveloperId, accessToken);

Log.Logger()?.ReportInfo($"{newDeveloperId.LoginId} logged in with OAuth flow to {newDeveloperId.GetHostAddress()}");

return newDeveloperId;
}
Expand Down
Binary file modified src/GitHubExtension/Widgets/Assets/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 15 additions & 15 deletions src/GitHubExtensionServer/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,22 @@
<Icon Path="Widgets\Assets\GitHubLogo_Light.jpg" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="For accessibility" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
<DarkMode>
<Icons>
<Icon Path="Widgets\Assets\GitHubLogo_Dark.png" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="For accessibility" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
</DarkMode>
<LightMode>
<Icons>
<Icon Path="Widgets\Assets\GitHubLogo_Light.png" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
</LightMode>
</ThemeResources>
Expand All @@ -133,22 +133,22 @@
<Icon Path="Widgets\Assets\GitHubLogo_Light.jpg" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="For accessibility" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
<DarkMode>
<Icons>
<Icon Path="Widgets\Assets\GitHubLogo_Dark.png" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="For accessibility" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
</DarkMode>
<LightMode>
<Icons>
<Icon Path="Widgets\Assets\GitHubLogo_Light.png" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
</LightMode>
</ThemeResources>
Expand All @@ -167,22 +167,22 @@
<Icon Path="Widgets\Assets\GitHubLogo_Light.jpg" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="For accessibility" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
<DarkMode>
<Icons>
<Icon Path="Widgets\Assets\GitHubLogo_Dark.png" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="For accessibility" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
</DarkMode>
<LightMode>
<Icons>
<Icon Path="Widgets\Assets\GitHubLogo_Light.png" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
</LightMode>
</ThemeResources>
Expand All @@ -201,22 +201,22 @@
<Icon Path="Widgets\Assets\GitHubLogo_Light.jpg" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="For accessibility" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
<DarkMode>
<Icons>
<Icon Path="Widgets\Assets\GitHubLogo_Dark.png" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="For accessibility" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
</DarkMode>
<LightMode>
<Icons>
<Icon Path="Widgets\Assets\GitHubLogo_Light.png" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
</LightMode>
</ThemeResources>
Expand All @@ -235,22 +235,22 @@
<Icon Path="Widgets\Assets\GitHubLogo_Light.jpg" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="For accessibility" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
<DarkMode>
<Icons>
<Icon Path="Widgets\Assets\GitHubLogo_Dark.png" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="For accessibility" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
</DarkMode>
<LightMode>
<Icons>
<Icon Path="Widgets\Assets\GitHubLogo_Light.png" />
</Icons>
<Screenshots>
<Screenshot Path="Widgets\Assets\screenshot.png" />
<Screenshot Path="Widgets\Assets\screenshot.png" DisplayAltText="DevHomeGitHub icon" />
</Screenshots>
</LightMode>
</ThemeResources>
Expand Down

0 comments on commit 866b2a3

Please sign in to comment.