Going secretless for Azure DevOps access#376
Draft
BillWagner wants to merge 12 commits into
Draft
Conversation
IEvangelist
reviewed
Jul 11, 2024
cc35898 to
7411f20
Compare
ce72ac9 to
23773dd
Compare
09b5bf0 to
2641047
Compare
e486e67 to
bfc561e
Compare
bfc561e to
5ea6109
Compare
5ea6109 to
8d0d632
Compare
8d0d632 to
3631080
Compare
3631080 to
2edd53d
Compare
2edd53d to
c3a3496
Compare
Update the SeQuester C# application to support secretless authentication.
Co-authored-by: David Pine <david.pine@microsoft.com>
c3a3496 to
086857d
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR is a first pass at enabling “secretless” Azure DevOps authentication for the sequester tooling by introducing an Azure DevOps bearer access token path (OIDC/OAuth) alongside the existing PAT-based flow.
Changes:
- Add a new
QuestAccessTokenoption sourced from environment variables and workflow OIDC output. - Thread a
useBearerTokenflag through service construction and updateQuestClientto supportBearervsBasicauth headers. - Update the bulk workflow to acquire an Azure DevOps OIDC token and pass it to the action.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| actions/sequester/Quest2GitHub/QuestGitHubService.cs | Adds useBearerToken, but currently still constructs the AzDO client with QuestKey regardless (blocks secretless auth). |
| actions/sequester/Quest2GitHub/Options/EnvironmentVariableReader.cs | Reads new QuestAccessToken and makes PAT optional, creating a mismatch with ApiKeys.QuestKey being required. |
| actions/sequester/Quest2GitHub/Options/ApiKeys.cs | Introduces QuestAccessToken, but its XML docs are currently incorrect/misleading. |
| actions/sequester/Quest2GitHub/AzDoClientServices/QuestClient.cs | Supports Bearer auth, but adds response-body logging and double-reads the content (security/robustness issue). |
| actions/sequester/ImportIssues/Program.cs | Wires through useBearerToken and validates token presence; also adds an unused using. |
| .github/workflows/quest-bulk.yml | Adds Azure DevOps OIDC auth step and passes QuestAccessToken; pins sequester action to a feature branch ref. |
Comments suppressed due to low confidence (1)
actions/sequester/Quest2GitHub/Options/EnvironmentVariableReader.cs:31
- QuestKey is now read as optional, but ApiKeys.QuestKey is still declared as a required non-nullable string. That combination can produce null values at runtime (the reader returns value!) and makes it unclear which token is actually required. Consider making QuestKey nullable (and validating based on auth mode) or requiring it only when bearer auth isn’t used.
var azureAccessToken = CoalesceEnvVar(("ImportOptions__ApiKeys__AzureAccessToken", "AZURE_ACCESS_TOKEN"), false);
// This key is the PAT for Quest access. It's now a legacy key. Secretless should be better.
var questKey = CoalesceEnvVar(("ImportOptions__ApiKeys__QuestKey", "QuestKey"), false);
if (!int.TryParse(appIDString, out int appID)) appID = 0;
return new ApiKeys()
{
GitHubToken = githubToken,
QuestAccessToken = questToken,
AzureAccessToken = azureAccessToken,
QuestKey = questKey,
SequesterPrivateKey = oauthPrivateKey,
SequesterAppID = appID
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| private const string LinkedWorkItemComment = "Associated WorkItem - "; | ||
| private readonly QuestClient _azdoClient = new(importOptions.ApiKeys.QuestKey, importOptions.AzureDevOps.Org, importOptions.AzureDevOps.Project); | ||
| private readonly QuestClient _azdoClient = new(importOptions.ApiKeys.QuestKey, importOptions.AzureDevOps.Org, importOptions.AzureDevOps.Project, useBearerToken); |
Comment on lines
+159
to
164
| // Temporary debugging code: | ||
|
|
||
| string packet = await response.Content.ReadAsStringAsync(); | ||
| Console.WriteLine($"Response: {packet}"); | ||
| JsonDocument jsonDocument = await JsonDocument.ParseAsync(await response.Content.ReadAsStreamAsync()); | ||
| return jsonDocument.RootElement; |
Comment on lines
+39
to
+48
| /// <summary> | ||
| /// The client ID for identifying this app with AzureDevOps. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Assign this from an environment variable with the following key, <c>ImportOptions__ApiKeys__AzureAccessToken</c>: | ||
| /// <code> | ||
| /// env: | ||
| /// ImportOptions__ApiKeys__QuestAccessToken: ${{ secrets.QUEST_ACCESS_TOKEN }} | ||
| /// </code> | ||
| /// </remarks> |
Comment on lines
33
to
+40
| /// <summary> | ||
| /// Create the quest client services object | ||
| /// </summary> | ||
| /// <param name="token">The personal access token</param> | ||
| /// <param name="org">The Azure DevOps organization</param> | ||
| /// <param name="project">The Azure DevOps project</param> | ||
| public QuestClient(string token, string org, string project) | ||
| /// <param name="useBearerToken">True to use a just in time bearer token, false assumes PAT</param> | ||
| public QuestClient(string token, string org, string project, bool useBearerToken) |
Comment on lines
1
to
+5
| using System.CommandLine; | ||
| using System.CommandLine.Parsing; | ||
| using DotNetDocs.Tools.GitHubCommunications; | ||
| using Microsoft.DotnetOrg.Ospo; | ||
| using Microsoft.Extensions.Options; |
Comment on lines
51
to
54
| - name: bulk-sequester | ||
| id: bulk-sequester | ||
| uses: dotnet/docs-tools/actions/sequester@main | ||
| uses: dotnet/docs-tools/actions/sequester@going-secretless | ||
| env: |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First draft at using secretless authentication for Azure Dev Ops access.