Skip to content

Commit 0397c29

Browse files
siddharthpaudwalSiddharth Paudwal
andauthored
Linux plain text cache for headless linux (#439)
* added msal cache logic for headless linux * added xdg open module functionality * removed xdg ipen functionality for headless linux * made changes in build and test yaml file to publish artifacts * added plain text caching for PAT tokens * added logdebug functionality * printing the command line in a separate line after the tokens are written on the terminal * removed pat caching and corrected unit test * written console.writeline for pat * corrected unit test * added osx arm64 in build file --------- Co-authored-by: Siddharth Paudwal <spaudwal@microsoft.com>
1 parent 8de5747 commit 0397c29

File tree

7 files changed

+905
-10
lines changed

7 files changed

+905
-10
lines changed

.azuredevops/BuildAndTest.yml

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,72 @@ parameters:
66
name: Azure-Pipelines-1ESPT-ExDShared
77
image: windows-latest
88
os: windows
9+
runtime: win-x64
910
- pool:
1011
name: Azure-Pipelines-1ESPT-ExDShared
1112
image: ubuntu-latest
1213
os: linux
14+
runtime: linux-x64
1315
- pool:
1416
name: Azure Pipelines
1517
image: macOS-latest
1618
os: macOS
19+
runtime: osx-x64
20+
- pool:
21+
name: Azure-Pipelines-1ESPT-ExDShared
22+
image: windows-latest
23+
os: windows
24+
runtime: win-arm64
25+
archiveExt: zip
26+
- pool:
27+
name: Azure-Pipelines-1ESPT-ExDShared
28+
image: ubuntu-latest
29+
os: linux
30+
runtime: linux-arm64
31+
archiveExt: tar.gz
32+
- pool:
33+
name: Azure Pipelines
34+
image: macOS-latest
35+
os: macOS
36+
runtime: osx-arm64
37+
archiveExt: tar.gz
1738

1839
stages:
1940
- stage: build
2041
displayName: Build And Test
2142
jobs:
2243
- ${{ each config in parameters.buildConfigs }}:
23-
- job: build_${{ config.pool.os }}
24-
displayName: Building and Testing on ${{ config.pool.os }}
44+
- job: build_${{ replace(config.runtime, '-', '_') }}
45+
displayName: Building and Testing on ${{ config.runtime }}
2546
pool:
2647
name: ${{ config.pool.name }}
2748
image: ${{ config.pool.image }}
2849
os: ${{ config.pool.os }}
50+
templateContext:
51+
outputs:
52+
- output: pipelineArtifact
53+
targetPath: dist/${{ config.runtime }}
54+
artifactName: azureauth-${{ config.runtime }}
2955
steps:
3056
- checkout: self
3157
- task: UseDotNet@2
3258
displayName: Use .NET Core sdk 8.x
3359
inputs:
3460
version: 8.x
61+
- task: NuGetToolInstaller@0
62+
displayName: Use NuGet 6.x
63+
inputs:
64+
versionSpec: 6.x
65+
- task: NuGetAuthenticate@1
66+
displayName: Authenticate to Azure Artifacts
3567
- task: DotNetCoreCLI@2
3668
displayName: Install dependencies
3769
inputs:
3870
command: restore
3971
feedsToUse: select
4072
vstsFeed: Office
4173
includeNuGetOrg: false
74+
arguments: --runtime ${{ config.runtime }}
4275
# 1ES PT requires explicit build task for Roslyn analysis. Auto-injected Roslyn task will use build logs from this build.
4376
- task: DotNetCoreCLI@2
4477
displayName: Build projects
@@ -50,4 +83,13 @@ stages:
5083
displayName: Test
5184
inputs:
5285
command: test
53-
arguments: --no-restore --no-build --verbosity normal
86+
arguments: --no-restore --no-build --verbosity normal
87+
- task: DotNetCoreCLI@2
88+
displayName: Publish artifacts
89+
inputs:
90+
command: publish
91+
projects: src/AzureAuth/AzureAuth.csproj
92+
arguments: --configuration release --self-contained true --runtime ${{ config.runtime }} --output dist/${{ config.runtime }}
93+
publishWebProjects: false
94+
zipAfterPublish: false
95+
modifyOutputPath: true

src/AzureAuth/Commands/Ado/CommandPat.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public int OnExecute(ILogger<CommandPat> logger, IPublicClientAuth publicClientA
155155
var pat = manager.GetPatAsync(this.PatOptions()).Result;
156156

157157
// Do not use logger to avoid printing PATs into log files.
158-
Console.Write(FormatPat(pat, this.Output));
158+
Console.WriteLine(FormatPat(pat, this.Output));
159159
}
160160

161161
return 0;
@@ -275,4 +275,4 @@ private IPatCache Cache()
275275
return new PatCache(storageWrapper);
276276
}
277277
}
278-
}
278+
}

src/AzureAuth/Commands/Ado/CommandToken.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public int OnExecute(ILogger<CommandToken> logger, IEnv env, ITelemetryService t
122122
}
123123

124124
// Do not use logger to avoid printing tokens into log files.
125-
Console.Write(FormatToken(token.Token, this.Output, Authorization.Bearer));
125+
Console.WriteLine(FormatToken(token.Token, this.Output, Authorization.Bearer));
126126
return 0;
127127
}
128128
}

src/AzureAuth/Commands/CommandAad.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ private int GetToken(IPublicClientAuth publicClientAuth)
405405
this.logger.LogSuccess(tokenResult.ToString());
406406
break;
407407
case OutputMode.Token:
408-
Console.Write(tokenResult.Token);
408+
Console.WriteLine(tokenResult.Token);
409409
break;
410410
case OutputMode.Json:
411411
Console.Write(tokenResult.ToJson());

0 commit comments

Comments
 (0)