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

Upgrade lasso and use incognito mode. #187

Merged
merged 18 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 15 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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Added On-premises Security Identifier in Telemetry as `sid`.
- Added Subcommand `info` and its subcommand `reset-device-id` to show or reset the device ID.

### Changed
- Upgrade MSAL to 4.47.2 and opt-in native WAM mode.
Expand Down
92 changes: 42 additions & 50 deletions src/AzureAuth.Test/AzureAuth.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,52 +1,44 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
goagain marked this conversation as resolved.
Show resolved Hide resolved
<DefineConstants>PlatformWindows</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))">
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Linux'))">
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<IsPackable>false</IsPackable>

<!-- Stylecop warnings as errors flag for build to fail -->
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<!-- Stylecop required items -->
<AdditionalFiles Include="..\stylecop\stylecop.json" Link="stylecop.json" />
<Compile Include="..\stylecop\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
<Compile Include="..\stylecop\GlobalSuppressions.Test.cs" Link="GlobalSuppressions.Test.cs" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="coverlet.collector" Version="3.0.2" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="7.0.7" />
<PackageReference Include="Moq" Version="4.17.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AzureAuth\AzureAuth.csproj" />
</ItemGroup>

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<DefineConstants>PlatformWindows</DefineConstants>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>

<!-- Stylecop warnings as errors flag for build to fail -->
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<!-- Stylecop required items -->
<AdditionalFiles Include="..\stylecop\stylecop.json" Link="stylecop.json" />
<Compile Include="..\stylecop\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
<Compile Include="..\stylecop\GlobalSuppressions.Test.cs" Link="GlobalSuppressions.Test.cs" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="coverlet.collector" Version="3.0.2" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="7.0.7" />
<PackageReference Include="Moq" Version="4.17.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AzureAuth\AzureAuth.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Commands\" />
</ItemGroup>

</Project>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/AzureAuth/AzureAuth.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Office.Lasso" Version="2022.1.6.1" />
<PackageReference Include="Microsoft.Office.Lasso" Version="2023.2.6.2" />
<PackageReference Include="Tomlyn" Version="0.11.0" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions src/AzureAuth/Commands/CommandAzureAuth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Microsoft.Authentication.AzureAuth.Commands
[Command(Name = "azureauth", Description = "A CLI interface to MSAL (Microsoft Authentication Library)")]
[Subcommand(typeof(CommandAad))]
[Subcommand(typeof(CommandAdo))]
[Subcommand(typeof(CommandInfo))]
public class CommandAzureAuth
{
/// <summary>
Expand Down
40 changes: 40 additions & 0 deletions src/AzureAuth/Commands/CommandInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.Authentication.AzureAuth.Commands
{
using System.IO.Abstractions;
using System.Reflection;
using McMaster.Extensions.CommandLineUtils;
using Microsoft.Authentication.AzureAuth.Commands.Info;
using Microsoft.Extensions.Logging;
using Microsoft.Office.Lasso.Telemetry;

/// <summary>
/// The command <see cref="CommandInfo"/> shows debug information and system runtime.
/// </summary>
[Command(Name = "info", Description = "Shows AzureAuth debug information. Please provide when asking for help.")]
[Subcommand(typeof(CommandResetDeviceID))]
public class CommandInfo
{
/// <summary>
/// This method executes the info process.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="fileSystem">The file system.</param>
/// <returns>The error code: 0 is normal execution, and the rest means errors during execution.</returns>
public int OnExecute(ILogger<CommandInfo> logger, IFileSystem fileSystem)
{
Assembly assembly = Assembly.GetExecutingAssembly();
string azureauthVersion = assembly.GetName().Version.ToString();
string deviceID = TelemetryDeviceID.GetAsync(fileSystem).Result;

logger.LogInformation(
$"AzureAuth Version: {azureauthVersion} \n" +
$"Device ID: {deviceID} \n" +
$"To reset your device identifier, Run `azureauth info reset-device-id`");

goagain marked this conversation as resolved.
Show resolved Hide resolved
return 0;
}
}
}
31 changes: 31 additions & 0 deletions src/AzureAuth/Commands/Info/CommandInfoResetDeviceID.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.Authentication.AzureAuth.Commands.Info
{
using System.IO.Abstractions;
using McMaster.Extensions.CommandLineUtils;
using Microsoft.Extensions.Logging;
using Microsoft.Office.Lasso.Telemetry;

/// <summary>
/// The command <see cref="CommandResetDeviceID"/> reset the device ID in local storage.
/// </summary>
[Command(Name = "reset-device-id", Description = "Reset your device identifier.")]
goagain marked this conversation as resolved.
Show resolved Hide resolved
public class CommandResetDeviceID
{
/// <summary>
/// This method executes the reset device ID process.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="fileSystem">The file system.</param>
/// <returns>The error code: 0 is normal execution, and the rest means errors during execution.</returns>
public int OnExecute(ILogger<CommandResetDeviceID> logger, IFileSystem fileSystem)
{
TelemetryDeviceID.Delete(fileSystem);
logger.LogInformation($"Device ID was reset.");
goagain marked this conversation as resolved.
Show resolved Hide resolved

return 0;
}
}
}
3 changes: 1 addition & 2 deletions src/AzureAuth/ExceptionListToStringConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace Microsoft.Authentication.AzureAuth
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Microsoft.Identity.Client;

Expand Down Expand Up @@ -100,7 +99,7 @@ public string Message
/// <summary>
/// Sets the error code.
/// </summary>
/// <param name="exception">exception from which error code is extracted.</param>
/// <param name="exception">Exception from which error code is extracted.</param>
private void SetAADErrorCode(Exception exception)
{
var exceptionType = exception.GetType();
Expand Down
4 changes: 3 additions & 1 deletion src/AzureAuth/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ private static void Main(string[] args)
backend: backend,
ingestionToken: ingestionToken,
useAsync: true,
envVarsToCollect: new[] { "SYSTEM_DEFINITIONID", "QBUILD_DISTRIBUTED" });
envVarsToCollect: new[] { "SYSTEM_DEFINITIONID", "QBUILD_DISTRIBUTED" },
hideAlias: true,
hideMachineName: true);

// We want redirect stdout to get just token output
// while warnings and errors still go to stderr to be seen by a user.
Expand Down