Skip to content

Going secretless for Azure DevOps access#376

Draft
BillWagner wants to merge 12 commits into
mainfrom
going-secretless
Draft

Going secretless for Azure DevOps access#376
BillWagner wants to merge 12 commits into
mainfrom
going-secretless

Conversation

@BillWagner

Copy link
Copy Markdown
Member

First draft at using secretless authentication for Azure Dev Ops access.

@IEvangelist IEvangelist left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Comment thread actions/sequester/ImportIssues/Program.cs Outdated
Comment thread actions/sequester/ImportIssues/Program.cs Outdated
@BillWagner BillWagner force-pushed the going-secretless branch 2 times, most recently from cc35898 to 7411f20 Compare July 19, 2024 19:23
@BillWagner BillWagner force-pushed the going-secretless branch 2 times, most recently from ce72ac9 to 23773dd Compare July 29, 2024 15:37
@BillWagner BillWagner force-pushed the going-secretless branch 3 times, most recently from 09b5bf0 to 2641047 Compare August 15, 2024 21:16
@BillWagner BillWagner force-pushed the going-secretless branch 2 times, most recently from e486e67 to bfc561e Compare September 13, 2024 14:22
Copilot AI review requested due to automatic review settings June 25, 2026 18:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 QuestAccessToken option sourced from environment variables and workflow OIDC output.
  • Thread a useBearerToken flag through service construction and update QuestClient to support Bearer vs Basic auth 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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants