Skip to content

[POC][US 20499] Control Tower auth probe in PR package-build check (internal)#17855

Draft
PawelWMS wants to merge 2 commits into
4.0from
pawelwi/sources-upload-prcheck
Draft

[POC][US 20499] Control Tower auth probe in PR package-build check (internal)#17855
PawelWMS wants to merge 2 commits into
4.0from
pawelwi/sources-upload-prcheck

Conversation

@PawelWMS

Copy link
Copy Markdown
Contributor

POC for US 20499 (sources-upload prcheck)

Verifies the passed service connection can authenticate to Control Tower from an internal PR before wiring the real source-scan/upload flow.

What this changes

.github/workflows/ado/templates/pr-package-build-stages.yml:

  • Adds a new probeOnly parameter (default true).
  • Adds an early AzureCLI@2 probe step that acquires a token via the WIF service connection and does a read-only GET /api/Workflow/plans (no build submitted), failing the check on any non-200.
  • Gates the real change-detection + scratch-build steps behind probeOnly == false, so the POC run stops right after the probe.

How to test

Trigger the [PR-check] scratch package build validation (def 5465). Expect the probe to authenticate and return the plans list, then stop.

Draft — POC only, not for merge.

POC for US 20499 (sources-upload prcheck). Verify the passed service
connection authenticates to Control Tower from BOTH internal and fork
PRs before wiring the real source-scan/upload flow.

Adds an early AzureCLI@2 step that acquires a token via the WIF service
connection and does a read-only GET /api/Workflow/plans (no build is
submitted), failing the check on any non-200. A new probeOnly parameter
(default true) gates the change-detection + scratch-build steps so the
POC run stops right after the probe.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 29, 2026 23:52
@github-actions

Copy link
Copy Markdown

Hello, and thank you for opening this pull request! 👋🏼 We appreciate the contribution.

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Commits in this repo will typically be prefixed with fix:, feat:, docs:, chore:, refactor:, test:, or ci: to indicate the type of change being proposed. The linked specification has more details.

Details:

No release type found in pull request title "[POC][US 20499] Control Tower auth probe in PR package-build check (internal)". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

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 an explicitly-draft proof-of-concept for US 20499. It adds a Control Tower authentication probe to the raw stages template for the [PR-check] scratch package build ADO pipeline, to verify that the WIF service connection can authenticate against Control Tower from a PR before the real source-scan/upload flow is wired in. The probe acquires a token via the service connection and issues a read-only GET /api/Workflow/plans, failing the check on any non-200. A new probeOnly parameter (default true) gates the existing change-detection + scratch-build steps so the POC run stops right after the probe.

Changes:

  • Adds a probeOnly boolean parameter (default true) to pr-package-build-stages.yml.
  • Adds an unconditional AzureCLI@2 probe step doing inline az account get-access-token + curl against /api/Workflow/plans.
  • Wraps the existing real build steps in ${{ if eq(parameters.probeOnly, false) }} so they are skipped by default.

Comment on lines +110 to +129
inlineScript: |
set -euo pipefail
base_url="${API_BASE_URL%/}"
url="$base_url/api/Workflow/plans"
echo "Acquiring Control Tower token for audience: $API_AUDIENCE"
token="$(az account get-access-token --resource "$API_AUDIENCE" --query accessToken -o tsv)"
echo "GET $url"
http_code="$(curl -sS -o /tmp/ct_plans.json -w '%{http_code}' \
-H "Authorization: Bearer $token" \
-H "Accept: application/json" \
"$url")"
echo "HTTP status: $http_code"
echo "Response (first 1000 bytes):"
head -c 1000 /tmp/ct_plans.json || true
echo
if [ "$http_code" != "200" ]; then
echo "##[error]Control Tower auth probe failed (HTTP $http_code)."
exit 1
fi
echo "Control Tower auth probe succeeded (HTTP 200)."
Point the POC auth probe at the Azure Front Door endpoint (ApiBaseAFDUrl)
instead of the direct APIM URL. The real scratch-build step keeps using
ApiBaseDirectUrl.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

2 participants