Skip to content

Commit 2d23299

Browse files
Merge pull request #556 from microsoft/psl-inputvalidation-oidc
ci: Added Input Validation and Migrated GitHub Actions authentication from client secrets to OIDC
2 parents a5e8780 + db3b477 commit 2d23299

12 files changed

Lines changed: 704 additions & 197 deletions

.github/workflows/CI.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616
schedule:
1717
- cron: "0 10,22 * * *" # Runs at 10:00 AM and 10:00 PM GMT
1818
permissions:
19+
id-token: write
1920
contents: read
2021
actions: read
2122
env:
@@ -25,6 +26,7 @@ env:
2526
jobs:
2627
deploy:
2728
runs-on: ubuntu-latest
29+
environment: production
2830
outputs:
2931
RESOURCE_GROUP_NAME: ${{ steps.get_webapp_url.outputs.RESOURCE_GROUP_NAME }}
3032
KUBERNETES_RESOURCE_GROUP_NAME: ${{ steps.get_webapp_url.outputs.KUBERNETES_RESOURCE_GROUP_NAME }}
@@ -78,6 +80,14 @@ jobs:
7880
with:
7981
driver: docker
8082

83+
- name: Login to Azure
84+
uses: azure/login@v2
85+
with:
86+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
87+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
88+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
89+
enable-AzPSSession: true
90+
8191
- name: Run Quota Check
8292
id: quota-check
8393
shell: pwsh
@@ -105,9 +115,6 @@ jobs:
105115
}
106116
env:
107117
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
108-
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
109-
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
110-
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
111118
GPT_MIN_CAPACITY: ${{ env.GPT_CAPACITY }}
112119
TEXT_EMBEDDING_MIN_CAPACITY: ${{ env.TEXT_EMBEDDING_CAPACITY }}
113120
AZURE_REGIONS: "${{ vars.AZURE_REGIONS }}"
@@ -158,11 +165,6 @@ jobs:
158165
echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
159166
echo "Generated RESOURCE_GROUP_NAME: ${UNIQUE_RG_NAME}"
160167
161-
- name: Login to Azure
162-
run: |
163-
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
164-
az account set --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }}
165-
166168
- name: Check and Create Resource Group
167169
id: check_create_rg
168170
run: |
@@ -252,11 +254,8 @@ jobs:
252254
Write-Host "Resource Group Name is ${{ env.RESOURCE_GROUP_NAME }}"
253255
Write-Host "Kubernetes resource group is ${{ env.AZURE_AKS_NAME }}"
254256
env:
255-
# From GitHub secrets (for login)
257+
# From GitHub secrets
256258
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
257-
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
258-
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
259-
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
260259

261260
# From deployment outputs step (these come from $GITHUB_ENV)
262261
RESOURCE_GROUP_NAME: ${{ env.RESOURCE_GROUP_NAME }}
@@ -292,10 +291,9 @@ jobs:
292291
if az account show &> /dev/null; then
293292
echo "Azure CLI is authenticated."
294293
else
295-
echo "Azure CLI is not authenticated. Logging in..."
296-
az login --service-principal --username ${{ secrets.AZURE_CLIENT_ID }} --password ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
294+
echo "Azure CLI is not authenticated. Please check the OIDC login step."
295+
exit 1
297296
fi
298-
az account set --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }}
299297
300298
# Get the Web App URL and save it to GITHUB_OUTPUT
301299
echo "Retrieving Web App URL..."
@@ -393,6 +391,7 @@ jobs:
393391
if: always()
394392
needs: [deploy, e2e-test]
395393
runs-on: ubuntu-latest
394+
environment: production
396395
env:
397396
RESOURCE_GROUP_NAME: ${{ needs.deploy.outputs.RESOURCE_GROUP_NAME }}
398397
KUBERNETES_RESOURCE_GROUP_NAME: ${{ needs.deploy.outputs.KUBERNETES_RESOURCE_GROUP_NAME }}
@@ -402,10 +401,11 @@ jobs:
402401

403402
steps:
404403
- name: Login to Azure
405-
shell: bash
406-
run: |
407-
az login --service-principal --username ${{ secrets.AZURE_CLIENT_ID }} --password ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
408-
az account set --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}"
404+
uses: azure/login@v2
405+
with:
406+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
407+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
408+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
409409

410410
- name: Delete Resource Groups
411411
if: env.RESOURCE_GROUP_NAME != ''

.github/workflows/codeql.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,13 @@ on:
88
- 'App/frontend-app/**'
99
- 'App/kernel-memory/**'
1010
- '.github/workflows/codeql.yml'
11-
paths-ignore:
12-
- '**/.gitignore'
13-
- '**/Dockerfile'
14-
- '**/.dockerignore'
1511
pull_request:
1612
branches: [ "main", "dev", "demo" ]
1713
paths:
1814
- 'App/backend-api/**'
1915
- 'App/frontend-app/**'
2016
- 'App/kernel-memory/**'
2117
- '.github/workflows/codeql.yml'
22-
paths-ignore:
23-
- '**/.gitignore'
24-
- '**/Dockerfile'
25-
- '**/.dockerignore'
2618
schedule:
2719
- cron: '37 2 * * 5'
2820

.github/workflows/deploy-linux.yml

Lines changed: 0 additions & 84 deletions
This file was deleted.

.github/workflows/deploy-orchestrator.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ jobs:
7777
secrets: inherit
7878

7979
send-notification:
80-
if: "!cancelled()"
80+
# if: "!cancelled()"
81+
if: false # Temporarily disable notification job
8182
needs: [deploy, e2e-test]
8283
uses: ./.github/workflows/job-send-notification.yml
8384
with:
@@ -96,7 +97,7 @@ jobs:
9697
secrets: inherit
9798

9899
cleanup-deployment:
99-
if: "!cancelled() && needs.deploy.result == 'success' && needs.deploy.outputs.RESOURCE_GROUP_NAME != '' && inputs.existing_webapp_url == '' && (inputs.trigger_type != 'workflow_dispatch' || inputs.cleanup_resources)"
100+
if: "!cancelled() && needs.deploy.outputs.RESOURCE_GROUP_NAME != '' && inputs.existing_webapp_url == '' && (inputs.trigger_type != 'workflow_dispatch' || inputs.cleanup_resources)"
100101
needs: [deploy, e2e-test]
101102
uses: ./.github/workflows/job-cleanup-deployment.yml
102103
with:

0 commit comments

Comments
 (0)