Skip to content

Commit 3b45837

Browse files
Merge updated sni-mtls-pop foundation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2 parents 60a9f24 + e226f92 commit 3b45837

23 files changed

Lines changed: 1488 additions & 187 deletions

‎.Pipelines/pipeline-publish.yml‎

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pr: none
3636
variables:
3737
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)]
3838
system.debug: ${{ parameters.debug }}
39+
WindowsContainerImage: 'onebranch.azurecr.io/windows/ltsc2022/vse2022:latest' # https://aka.ms/obpipelines/containers
3940

4041
resources:
4142
repositories:
@@ -64,6 +65,7 @@ extends:
6465
tsaEnabled: true
6566
featureFlags:
6667
EnableCDPxPAT: false
68+
WindowsHostVersion: '1ESWindows2022'
6769

6870
stages:
6971

@@ -82,34 +84,26 @@ extends:
8284
condition: eq(dependencies.E2ETests.result, 'Succeeded')
8385
jobs:
8486
- job: BuildDist
85-
displayName: 'Build sdist + wheel (Python 3.12)'
87+
displayName: 'Build sdist + wheel'
8688
pool:
87-
type: linux
88-
isCustom: true
89-
vmImage: 'ubuntu-22.04'
89+
type: windows
9090
variables:
9191
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
9292
steps:
93-
- task: UsePythonVersion@0
94-
inputs:
95-
versionSpec: '3.12'
96-
displayName: 'Use Python 3.12'
93+
- script: python --version
94+
displayName: 'Check Python version'
9795

98-
- script: |
99-
python -m pip install --upgrade pip build twine
100-
displayName: 'Install build toolchain'
101-
102-
- script: |
103-
python -m build
96+
- script: python setup.py sdist bdist_wheel
10497
displayName: 'Build sdist and wheel'
10598

106-
- script: |
107-
python -m twine check dist/*
108-
displayName: 'Verify distribution (twine check)'
109-
110-
- script: |
111-
cp -r dist/* $(ob_outputDirectory)/
99+
- task: CopyFiles@2
112100
displayName: 'Copy dist to output directory'
101+
inputs:
102+
SourceFolder: '$(Build.SourcesDirectory)\dist'
103+
Contents: |
104+
*.whl
105+
*.tar.gz
106+
TargetFolder: '$(ob_outputDirectory)'
113107

114108
# ========================================================================
115109
# Stage 5a - Publish to test.pypi.org (Preview / RC)
@@ -135,8 +129,9 @@ extends:
135129
- task: DownloadPipelineArtifact@2
136130
displayName: 'Download build artifact'
137131
inputs:
138-
artifactName: drop_Build_BuildDist
139-
targetPath: $(Pipeline.Workspace)/python-dist
132+
buildType: 'current'
133+
artifactName: 'drop_Build_BuildDist'
134+
targetPath: $(Pipeline.Workspace)\python-dist
140135

141136
- task: UsePythonVersion@0
142137
inputs:
@@ -211,8 +206,9 @@ extends:
211206
- task: DownloadPipelineArtifact@2
212207
displayName: 'Download python-dist artifact'
213208
inputs:
214-
artifactName: drop_Build_BuildDist
215-
targetPath: $(Pipeline.Workspace)/python-dist
209+
buildType: 'current'
210+
artifactName: 'drop_Build_BuildDist'
211+
targetPath: $(Pipeline.Workspace)\python-dist
216212

217213
- task: EsrpRelease@12
218214
displayName: 'Publish to PyPI via ESRP'
@@ -225,9 +221,9 @@ extends:
225221
intent: 'PackageDistribution'
226222
contenttype: 'PyPi'
227223
contentsource: 'Folder'
228-
folderlocation: '$(Pipeline.Workspace)/python-dist'
224+
folderlocation: '$(Pipeline.Workspace)\python-dist'
229225
waitforreleasecompletion: true
230-
owners: 'ryauld@microsoft.com,avdunn@microsoft.com'
226+
owners: 'avdunn@microsoft.com,bogavril@microsoft.com'
231227
approvers: 'avdunn@microsoft.com,bogavril@microsoft.com'
232228
serviceendpointurl: 'https://api.esrp.microsoft.com'
233229
mainpublisher: 'ESRPRELPACMAN'

‎.Pipelines/template-pipeline-stages.yml‎

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ stages:
125125
--ignore=tests/test_e2e.py \
126126
--ignore=tests/test_e2e_manual.py \
127127
--ignore=tests/test_fmi_e2e.py \
128+
--ignore=tests/test_mi_e2e.py \
128129
--deselect tests/test_cryptography.py::CryptographyTestCase::test_ceiling_should_be_latest_cryptography_version_plus_three \
129130
--deselect tests/test_cryptography.py::CryptographyTestCase::test_should_be_run_with_latest_version_of_cryptography
130131
displayName: 'Run pytest (unit)'
@@ -275,3 +276,123 @@ stages:
275276
- bash: rm -f "$(Agent.TempDirectory)/lab-auth.pfx"
276277
displayName: 'Remove lab certificate from agent'
277278
condition: always()
279+
280+
# ══════════════════════════════════════════════════════════════════════════════
281+
# Stage 4 - MI E2E (IMDS) - REAL managed identity token acquisition on an Azure VM.
282+
# Runs on the self-hosted "MISEManagedIdentity" pool, a Windows Azure VM
283+
# that has the lab system-assigned + user-assigned identities assigned.
284+
# Mirrors the MSAL Go "MI E2E - IMDS" stage. Only the IMDS cases in
285+
# tests/test_mi_e2e.py run here (gated on MSAL_TEST_MI_IMDS); the Arc case
286+
# self-skips. No lab certificate is needed - the VM's own managed identity
287+
# is used.
288+
#
289+
# Pool assumptions (self-hosted): Python 3.x on PATH and outbound access to
290+
# PyPI for "pip install". Adjust if the pool differs.
291+
# ══════════════════════════════════════════════════════════════════════════════
292+
- stage: MIE2EImds
293+
displayName: 'MI E2E - IMDS'
294+
dependsOn: UnitTests
295+
# Fork guard: never run untrusted forked-PR code on the self-hosted pool.
296+
condition: and(eq(dependencies.UnitTests.result, 'Succeeded'), ne(variables['System.PullRequest.IsFork'], 'True'))
297+
jobs:
298+
- job: Pytest
299+
displayName: 'Managed Identity E2E - VM / IMDS'
300+
pool:
301+
type: windows
302+
isCustom: true
303+
name: MISEManagedIdentity
304+
timeoutInMinutes: 30
305+
variables:
306+
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
307+
steps:
308+
# msal + its dependencies (requests, cryptography, PyJWT) and pytest are PRE-PROVISIONED on the
309+
# self-hosted pool (like the Go/.NET toolchains already are), so there is no runtime pip install.
310+
# This also avoids the Arc pool's egress TLS inspection blocking files.pythonhosted.org.
311+
- task: PowerShell@2
312+
displayName: 'Run pytest (MI E2E - IMDS)'
313+
inputs:
314+
targetType: 'inline'
315+
workingDirectory: '$(System.DefaultWorkingDirectory)'
316+
script: |
317+
$ErrorActionPreference = 'Stop'
318+
$py = (Get-Command python.exe -ErrorAction SilentlyContinue).Source
319+
if (-not $py) {
320+
$py = Get-ChildItem 'C:\Program Files\Python3*\python.exe','C:\Program Files (x86)\Python3*\python.exe','C:\Python3*\python.exe' -ErrorAction SilentlyContinue |
321+
Select-Object -First 1 -ExpandProperty FullName
322+
}
323+
if (-not $py) { throw 'Python not found on this agent. Install Python 3.x on the pool machine.' }
324+
Write-Host "Using Python: $py"
325+
& $py --version
326+
New-Item -ItemType Directory -Force -Path test-results | Out-Null
327+
& $py -m pytest -vv --junitxml=test-results/junit-mi-e2e-imds.xml tests/test_mi_e2e.py
328+
env:
329+
PYTHONUNBUFFERED: '1'
330+
MSAL_TEST_MI_IMDS: '1'
331+
332+
- task: PublishTestResults@2
333+
displayName: 'Publish MI E2E (IMDS) test results'
334+
condition: succeededOrFailed()
335+
inputs:
336+
testResultsFormat: 'JUnit'
337+
testResultsFiles: 'test-results/junit-mi-e2e-imds.xml'
338+
failTaskOnFailedTests: true
339+
testRunTitle: 'MI E2E - IMDS'
340+
341+
# ══════════════════════════════════════════════════════════════════════════════
342+
# Stage 5 - MI E2E (Azure Arc) - REAL managed identity token acquisition on an
343+
# Azure Arc-enabled machine. Runs on the self-hosted "MISEAZUREARC" pool.
344+
# Azure Arc supports the system-assigned identity only. Mirrors the MSAL Go
345+
# "MI E2E - Azure Arc" stage. tests/test_mi_e2e.py's Arc case runs here; the
346+
# IMDS cases self-skip (MSAL_TEST_MI_IMDS unset).
347+
#
348+
# Pool note: as observed for MSAL Go, the Arc machine's egress inspection can
349+
# reset TLS for package downloads. If "pip install" cannot reach PyPI, pre-provision
350+
# the dependencies on the pool (or use an offline wheel cache) and drop the install step.
351+
# ══════════════════════════════════════════════════════════════════════════════
352+
- stage: MIE2EAzureArc
353+
displayName: 'MI E2E - Azure Arc'
354+
dependsOn: UnitTests
355+
# Fork guard: never run untrusted forked-PR code on the self-hosted pool.
356+
condition: and(eq(dependencies.UnitTests.result, 'Succeeded'), ne(variables['System.PullRequest.IsFork'], 'True'))
357+
jobs:
358+
- job: Pytest
359+
displayName: 'Managed Identity E2E - Azure Arc'
360+
pool:
361+
type: windows
362+
isCustom: true
363+
name: MISEAZUREARC
364+
timeoutInMinutes: 30
365+
variables:
366+
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
367+
steps:
368+
# msal + its dependencies (requests, cryptography, PyJWT) and pytest are PRE-PROVISIONED on the
369+
# self-hosted pool (like the Go/.NET toolchains already are), so there is no runtime pip install.
370+
# This is required here because the Arc machine's egress TLS inspection blocks files.pythonhosted.org.
371+
- task: PowerShell@2
372+
displayName: 'Run pytest (MI E2E - Azure Arc)'
373+
inputs:
374+
targetType: 'inline'
375+
workingDirectory: '$(System.DefaultWorkingDirectory)'
376+
script: |
377+
$ErrorActionPreference = 'Stop'
378+
$py = (Get-Command python.exe -ErrorAction SilentlyContinue).Source
379+
if (-not $py) {
380+
$py = Get-ChildItem 'C:\Program Files\Python3*\python.exe','C:\Program Files (x86)\Python3*\python.exe','C:\Python3*\python.exe' -ErrorAction SilentlyContinue |
381+
Select-Object -First 1 -ExpandProperty FullName
382+
}
383+
if (-not $py) { throw 'Python not found on this agent. Install Python 3.x on the pool machine.' }
384+
Write-Host "Using Python: $py"
385+
& $py --version
386+
New-Item -ItemType Directory -Force -Path test-results | Out-Null
387+
& $py -m pytest -vv --junitxml=test-results/junit-mi-e2e-arc.xml tests/test_mi_e2e.py
388+
env:
389+
PYTHONUNBUFFERED: '1'
390+
391+
- task: PublishTestResults@2
392+
displayName: 'Publish MI E2E (Azure Arc) test results'
393+
condition: succeededOrFailed()
394+
inputs:
395+
testResultsFormat: 'JUnit'
396+
testResultsFiles: 'test-results/junit-mi-e2e-arc.xml'
397+
failTaskOnFailedTests: true
398+
testRunTitle: 'MI E2E - Azure Arc'

‎.github/dependabot.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
groups:
6+
github-actions:
7+
patterns: ["*"]
8+
schedule:
9+
interval: "weekly"
10+
cooldown:
11+
default-days: 7

‎.github/workflows/RunIssueSentinel.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Run Issue Sentinel
13-
uses: Azure/issue-sentinel@v1
13+
uses: Azure/issue-sentinel@d1e433f192aa9442d44292b9b6d5d31419639aba # v1.6.1
1414
with:
1515
password: ${{secrets.ISSUE_SENTINEL_PASSWORD}}
1616
enable-similar-issues-scanning: true # Scan for similar issues

‎.github/workflows/python-package.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ jobs:
2222
contents: read
2323
runs-on: ubuntu-22.04
2424
steps:
25-
- uses: actions/checkout@v4
25+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
2626
- name: Set up Python
27-
uses: actions/setup-python@v5
27+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2828
with:
2929
python-version: '3.12'
3030
cache: 'pip'
@@ -38,7 +38,7 @@ jobs:
3838
# `twine check` catches broken long_description / metadata that would fail PyPI upload.
3939
run: twine check dist/*
4040
- name: Upload built artifacts
41-
uses: actions/upload-artifact@v4
41+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
4242
with:
4343
name: dist
4444
path: dist/

‎msal/__main__.py‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,7 @@ def _remove_tokens_for_client(app):
216216

217217
def _exit(app):
218218
"""Exit"""
219-
bug_link = (
220-
"https://identitydivision.visualstudio.com/Engineering/_queries/query/79b3a352-a775-406f-87cd-a487c382a8ed/"
221-
if app._enable_broker else
222-
"https://github.com/AzureAD/microsoft-authentication-library-for-python/issues/new/choose"
223-
)
219+
bug_link = "https://github.com/AzureAD/microsoft-authentication-library-for-python/issues/new/choose"
224220
print("Bye. If you found a bug, please report it here: {}".format(bug_link))
225221
sys.exit()
226222

@@ -334,4 +330,3 @@ def _main():
334330

335331
if __name__ == "__main__":
336332
_main()
337-

0 commit comments

Comments
 (0)