Skip to content

Commit e69ef8a

Browse files
authored
Merge pull request #154 from willvelida/013-apim-managed-identity
feat: Add JWT validation to APIM for managed identity authentication
2 parents 6f27fcb + 125df35 commit e69ef8a

38 files changed

+4475
-37
lines changed

.github/workflows/deploy-activity-api.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
run-unit-tests:
3333
name: Run Unit Tests with Coverage
3434
needs: env-setup
35-
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-unit-tests.yml@main
35+
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-unit-tests.yml@013-apim-managed-identity
3636
with:
3737
dotnet-version: ${{ needs.env-setup.outputs.dotnet-version }}
3838
working-directory: ./src/Biotrackr.Activity.Api/Biotrackr.Activity.Api.UnitTests
@@ -42,7 +42,7 @@ jobs:
4242
run-contract-tests:
4343
name: Run API Contract Tests
4444
needs: env-setup
45-
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-contract-tests.yml@main
45+
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-contract-tests.yml@013-apim-managed-identity
4646
with:
4747
dotnet-version: ${{ needs.env-setup.outputs.dotnet-version }}
4848
working-directory: ./src/Biotrackr.Activity.Api/Biotrackr.Activity.Api.IntegrationTests
@@ -51,7 +51,7 @@ jobs:
5151
build-container-image-dev:
5252
name: Build and Push Container Image
5353
needs: [run-unit-tests, run-contract-tests]
54-
uses: willvelida/biotrackr/.github/workflows/template-acr-push-image.yml@main
54+
uses: willvelida/biotrackr/.github/workflows/template-acr-push-image.yml@013-apim-managed-identity
5555
with:
5656
working-directory: ./src/Biotrackr.Activity.Api
5757
app-name: biotrackr-activity-api
@@ -84,17 +84,17 @@ jobs:
8484
lint:
8585
name: Run Bicep Linter
8686
needs: retrieve-container-image-dev
87-
uses: willvelida/biotrackr/.github/workflows/template-bicep-linter.yml@main
87+
uses: willvelida/biotrackr/.github/workflows/template-bicep-linter.yml@013-apim-managed-identity
8888
with:
8989
template-file: './infra/apps/activity-api/main.bicep'
9090

9191
validate:
9292
name: Validate Template
9393
needs: [lint, retrieve-container-image-dev]
94-
uses: willvelida/biotrackr/.github/workflows/template-bicep-validate.yml@main
94+
uses: willvelida/biotrackr/.github/workflows/template-bicep-validate.yml@013-apim-managed-identity
9595
with:
9696
template-file: './infra/apps/activity-api/main.bicep'
97-
parameters-file: ./infra/apps/activity-api/main.dev.bicepparam
97+
parameters-file: ./infra/apps/activity-api/main.dev.bicepparam
9898
parameters: '{"imageName": "${{ needs.retrieve-container-image-dev.outputs.loginServer }}/biotrackr-activity-api:${{ github.sha }}"}'
9999
scope: resourceGroup
100100
secrets:
@@ -106,7 +106,7 @@ jobs:
106106
preview:
107107
name: Preview Changes
108108
needs: [validate, retrieve-container-image-dev]
109-
uses: willvelida/biotrackr/.github/workflows/template-bicep-whatif.yml@main
109+
uses: willvelida/biotrackr/.github/workflows/template-bicep-whatif.yml@013-apim-managed-identity
110110
with:
111111
scope: resourceGroup
112112
template-file: './infra/apps/activity-api/main.bicep'
@@ -121,7 +121,7 @@ jobs:
121121
deploy-dev:
122122
name: Deploy Template to Dev
123123
needs: [preview, retrieve-container-image-dev]
124-
uses: willvelida/biotrackr/.github/workflows/template-bicep-deploy.yml@main
124+
uses: willvelida/biotrackr/.github/workflows/template-bicep-deploy.yml@013-apim-managed-identity
125125
with:
126126
template-file: './infra/apps/activity-api/main.bicep'
127127
parameters-file: ./infra/apps/activity-api/main.dev.bicepparam
@@ -137,7 +137,7 @@ jobs:
137137
run-e2e-tests:
138138
name: Run E2E Tests Against Dev
139139
needs: [deploy-dev, env-setup]
140-
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-e2e-tests.yml@main
140+
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-e2e-tests.yml@013-apim-managed-identity
141141
with:
142142
dotnet-version: ${{ needs.env-setup.outputs.dotnet-version }}
143143
working-directory: ./src/Biotrackr.Activity.Api/Biotrackr.Activity.Api.IntegrationTests

.github/workflows/deploy-food-api.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
run-unit-tests:
3333
name: Run Unit Tests with Coverage
3434
needs: env-setup
35-
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-unit-tests.yml@main
35+
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-unit-tests.yml@013-apim-managed-identity
3636
with:
3737
dotnet-version: ${{ needs.env-setup.outputs.dotnet-version }}
3838
working-directory: ./src/Biotrackr.Food.Api/Biotrackr.Food.Api.UnitTests
@@ -42,7 +42,7 @@ jobs:
4242
run-contract-tests:
4343
name: Run API Contract Tests
4444
needs: env-setup
45-
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-contract-tests.yml@main
45+
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-contract-tests.yml@013-apim-managed-identity
4646
with:
4747
dotnet-version: ${{ needs.env-setup.outputs.dotnet-version }}
4848
working-directory: ./src/Biotrackr.Food.Api/Biotrackr.Food.Api.IntegrationTests
@@ -51,7 +51,7 @@ jobs:
5151
build-container-image-dev:
5252
name: Build and Push Container Image
5353
needs: [run-unit-tests, run-contract-tests]
54-
uses: willvelida/biotrackr/.github/workflows/template-acr-push-image.yml@main
54+
uses: willvelida/biotrackr/.github/workflows/template-acr-push-image.yml@013-apim-managed-identity
5555
with:
5656
working-directory: ./src/Biotrackr.Food.Api
5757
app-name: biotrackr-food-api
@@ -84,17 +84,17 @@ jobs:
8484
lint:
8585
name: Run Bicep Linter
8686
needs: retrieve-container-image-dev
87-
uses: willvelida/biotrackr/.github/workflows/template-bicep-linter.yml@main
87+
uses: willvelida/biotrackr/.github/workflows/template-bicep-linter.yml@013-apim-managed-identity
8888
with:
8989
template-file: './infra/apps/food-api/main.bicep'
9090

9191
validate:
9292
name: Validate Template
9393
needs: [lint, retrieve-container-image-dev]
94-
uses: willvelida/biotrackr/.github/workflows/template-bicep-validate.yml@main
94+
uses: willvelida/biotrackr/.github/workflows/template-bicep-validate.yml@013-apim-managed-identity
9595
with:
9696
template-file: './infra/apps/food-api/main.bicep'
97-
parameters-file: ./infra/apps/food-api/main.dev.bicepparam
97+
parameters-file: ./infra/apps/food-api/main.dev.bicepparam
9898
parameters: '{"imageName": "${{ needs.retrieve-container-image-dev.outputs.loginServer }}/biotrackr-food-api:${{ github.sha }}"}'
9999
scope: resourceGroup
100100
secrets:
@@ -106,7 +106,7 @@ jobs:
106106
preview:
107107
name: Preview Changes
108108
needs: [validate, retrieve-container-image-dev]
109-
uses: willvelida/biotrackr/.github/workflows/template-bicep-whatif.yml@main
109+
uses: willvelida/biotrackr/.github/workflows/template-bicep-whatif.yml@013-apim-managed-identity
110110
with:
111111
scope: resourceGroup
112112
template-file: './infra/apps/food-api/main.bicep'
@@ -121,7 +121,7 @@ jobs:
121121
deploy-dev:
122122
name: Deploy Template to Dev
123123
needs: [preview, retrieve-container-image-dev]
124-
uses: willvelida/biotrackr/.github/workflows/template-bicep-deploy.yml@main
124+
uses: willvelida/biotrackr/.github/workflows/template-bicep-deploy.yml@013-apim-managed-identity
125125
with:
126126
template-file: './infra/apps/food-api/main.bicep'
127127
parameters-file: ./infra/apps/food-api/main.dev.bicepparam
@@ -137,7 +137,7 @@ jobs:
137137
run-e2e-tests:
138138
name: Run E2E Tests Against Dev
139139
needs: [deploy-dev, env-setup]
140-
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-e2e-tests.yml@main
140+
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-e2e-tests.yml@013-apim-managed-identity
141141
with:
142142
dotnet-version: ${{ needs.env-setup.outputs.dotnet-version }}
143143
working-directory: ./src/Biotrackr.Food.Api/Biotrackr.Food.Api.IntegrationTests

.github/workflows/deploy-sleep-api.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
run-unit-tests:
3636
name: Run Unit Tests with Coverage
3737
needs: env-setup
38-
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-unit-tests.yml@main
38+
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-unit-tests.yml@013-apim-managed-identity
3939
with:
4040
dotnet-version: ${{ needs.env-setup.outputs.dotnet-version }}
4141
working-directory: ./src/Biotrackr.Sleep.Api/Biotrackr.Sleep.Api.UnitTests
@@ -45,7 +45,7 @@ jobs:
4545
run-contract-tests:
4646
name: Run API Contract Tests
4747
needs: env-setup
48-
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-contract-tests.yml@main
48+
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-contract-tests.yml@013-apim-managed-identity
4949
with:
5050
dotnet-version: ${{ needs.env-setup.outputs.dotnet-version }}
5151
working-directory: ./src/Biotrackr.Sleep.Api/Biotrackr.Sleep.Api.IntegrationTests
@@ -100,17 +100,17 @@ jobs:
100100
lint:
101101
name: Run Bicep Linter
102102
needs: retrieve-container-image-dev
103-
uses: willvelida/biotrackr/.github/workflows/template-bicep-linter.yml@main
103+
uses: willvelida/biotrackr/.github/workflows/template-bicep-linter.yml@013-apim-managed-identity
104104
with:
105105
template-file: './infra/apps/sleep-api/main.bicep'
106106

107107
validate:
108108
name: Validate Template
109109
needs: [lint, retrieve-container-image-dev]
110-
uses: willvelida/biotrackr/.github/workflows/template-bicep-validate.yml@main
110+
uses: willvelida/biotrackr/.github/workflows/template-bicep-validate.yml@013-apim-managed-identity
111111
with:
112112
template-file: './infra/apps/sleep-api/main.bicep'
113-
parameters-file: ./infra/apps/sleep-api/main.dev.bicepparam
113+
parameters-file: ./infra/apps/sleep-api/main.dev.bicepparam
114114
parameters: '{"imageName": "${{ needs.retrieve-container-image-dev.outputs.loginServer }}/biotrackr-sleep-api:${{ github.sha }}"}'
115115
scope: resourceGroup
116116
secrets:
@@ -122,7 +122,7 @@ jobs:
122122
preview:
123123
name: Preview Changes
124124
needs: [validate, retrieve-container-image-dev]
125-
uses: willvelida/biotrackr/.github/workflows/template-bicep-whatif.yml@main
125+
uses: willvelida/biotrackr/.github/workflows/template-bicep-whatif.yml@013-apim-managed-identity
126126
with:
127127
template-file: './infra/apps/sleep-api/main.bicep'
128128
parameters-file: ./infra/apps/sleep-api/main.dev.bicepparam
@@ -137,7 +137,7 @@ jobs:
137137
deploy-dev:
138138
name: Deploy Template to Dev
139139
needs: [preview, retrieve-container-image-dev]
140-
uses: willvelida/biotrackr/.github/workflows/template-bicep-deploy.yml@main
140+
uses: willvelida/biotrackr/.github/workflows/template-bicep-deploy.yml@013-apim-managed-identity
141141
with:
142142
template-file: './infra/apps/sleep-api/main.bicep'
143143
parameters-file: ./infra/apps/sleep-api/main.dev.bicepparam

.github/workflows/deploy-weight-api.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
run-unit-tests:
3333
name: Run Unit Tests with Coverage
3434
needs: env-setup
35-
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-unit-tests.yml@main
35+
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-unit-tests.yml@013-apim-managed-identity
3636
with:
3737
dotnet-version: ${{ needs.env-setup.outputs.dotnet-version }}
3838
working-directory: ./src/Biotrackr.Weight.Api/Biotrackr.Weight.Api.UnitTests
@@ -42,7 +42,7 @@ jobs:
4242
run-contract-tests:
4343
name: Run API Contract Tests
4444
needs: env-setup
45-
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-contract-tests.yml@main
45+
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-contract-tests.yml@013-apim-managed-identity
4646
with:
4747
dotnet-version: ${{ needs.env-setup.outputs.dotnet-version }}
4848
working-directory: ./src/Biotrackr.Weight.Api/Biotrackr.Weight.Api.IntegrationTests
@@ -51,7 +51,7 @@ jobs:
5151
build-container-image-dev:
5252
name: Build and Push Container Image
5353
needs: [run-unit-tests, run-contract-tests]
54-
uses: willvelida/biotrackr/.github/workflows/template-acr-push-image.yml@main
54+
uses: willvelida/biotrackr/.github/workflows/template-acr-push-image.yml@013-apim-managed-identity
5555
with:
5656
working-directory: ./src/Biotrackr.Weight.Api
5757
app-name: biotrackr-weight-api
@@ -84,14 +84,14 @@ jobs:
8484
lint:
8585
name: Run Bicep Linter
8686
needs: retrieve-container-image-dev
87-
uses: willvelida/biotrackr/.github/workflows/template-bicep-linter.yml@main
87+
uses: willvelida/biotrackr/.github/workflows/template-bicep-linter.yml@013-apim-managed-identity
8888
with:
8989
template-file: './infra/apps/weight-api/main.bicep'
9090

9191
validate:
9292
name: Validate Template
9393
needs: [lint, retrieve-container-image-dev]
94-
uses: willvelida/biotrackr/.github/workflows/template-bicep-validate.yml@main
94+
uses: willvelida/biotrackr/.github/workflows/template-bicep-validate.yml@013-apim-managed-identity
9595
with:
9696
template-file: './infra/apps/weight-api/main.bicep'
9797
parameters-file: ./infra/apps/weight-api/main.dev.bicepparam
@@ -106,7 +106,7 @@ jobs:
106106
preview:
107107
name: Preview Changes
108108
needs: [validate, retrieve-container-image-dev]
109-
uses: willvelida/biotrackr/.github/workflows/template-bicep-whatif.yml@main
109+
uses: willvelida/biotrackr/.github/workflows/template-bicep-whatif.yml@013-apim-managed-identity
110110
with:
111111
template-file: './infra/apps/weight-api/main.bicep'
112112
parameters-file: ./infra/apps/weight-api/main.dev.bicepparam
@@ -121,7 +121,7 @@ jobs:
121121
deploy-dev:
122122
name: Deploy Template to Dev
123123
needs: [preview, retrieve-container-image-dev]
124-
uses: willvelida/biotrackr/.github/workflows/template-bicep-deploy.yml@main
124+
uses: willvelida/biotrackr/.github/workflows/template-bicep-deploy.yml@013-apim-managed-identity
125125
with:
126126
template-file: './infra/apps/weight-api/main.bicep'
127127
parameters-file: ./infra/apps/weight-api/main.dev.bicepparam
@@ -137,7 +137,7 @@ jobs:
137137
run-e2e-tests:
138138
name: Run E2E Tests Against Dev
139139
needs: [deploy-dev, env-setup]
140-
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-e2e-tests.yml@main
140+
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-e2e-tests.yml@013-apim-managed-identity
141141
with:
142142
dotnet-version: ${{ needs.env-setup.outputs.dotnet-version }}
143143
working-directory: ./src/Biotrackr.Weight.Api/Biotrackr.Weight.Api.IntegrationTests

.github/workflows/template-bicep-deploy.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ jobs:
4444
tenant-id: ${{ secrets.tenant-id }}
4545
subscription-id: ${{ secrets.subscription-id }}
4646

47+
- name: Prepare Parameters with Tenant ID
48+
id: prepare-params
49+
shell: bash
50+
run: |
51+
if [ -n "${{ inputs.parameters }}" ]; then
52+
# Merge user parameters with tenantId
53+
PARAMS=$(echo '${{ inputs.parameters }}' | jq -c '. + {"tenantId": "${{ secrets.tenant-id }}"}')
54+
else
55+
# Only tenantId
56+
PARAMS='{"tenantId": "${{ secrets.tenant-id }}"}'
57+
fi
58+
echo "params=$PARAMS" >> "$GITHUB_OUTPUT"
59+
4760
- uses: azure/bicep-deploy@v2
4861
name: Deploy Bicep Template
4962
with:
@@ -54,5 +67,5 @@ jobs:
5467
resource-group-name: ${{ secrets.resource-group-name }}
5568
template-file: ${{ inputs.template-file }}
5669
parameters-file: ${{ inputs.parameters-file }}
57-
parameters: ${{ inputs.parameters }}
70+
parameters: ${{ steps.prepare-params.outputs.params }}
5871
name: ${{ github.run_number }}

.github/workflows/template-bicep-validate.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ jobs:
4040
tenant-id: ${{ secrets.tenant-id }}
4141
subscription-id: ${{ secrets.subscription-id }}
4242

43+
- name: Prepare Parameters with Tenant ID
44+
id: prepare-params
45+
shell: bash
46+
run: |
47+
if [ -n "${{ inputs.parameters }}" ]; then
48+
# Merge user parameters with tenantId
49+
PARAMS=$(echo '${{ inputs.parameters }}' | jq -c '. + {"tenantId": "${{ secrets.tenant-id }}"}')
50+
else
51+
# Only tenantId
52+
PARAMS='{"tenantId": "${{ secrets.tenant-id }}"}'
53+
fi
54+
echo "params=$PARAMS" >> "$GITHUB_OUTPUT"
55+
4356
- uses: azure/bicep-deploy@v2
4457
name: Run preflight validation
4558
with:
@@ -50,5 +63,5 @@ jobs:
5063
name: ${{ github.run_number }}
5164
template-file: ${{ inputs.template-file }}
5265
parameters-file: ${{ inputs.parameters-file }}
53-
parameters: ${{ inputs.parameters }}
66+
parameters: ${{ steps.prepare-params.outputs.params }}
5467
operation: validate

.github/workflows/template-bicep-whatif.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ jobs:
4040
tenant-id: ${{ secrets.tenant-id }}
4141
subscription-id: ${{ secrets.subscription-id }}
4242

43+
- name: Prepare Parameters with Tenant ID
44+
id: prepare-params
45+
shell: bash
46+
run: |
47+
if [ -n "${{ inputs.parameters }}" ]; then
48+
# Merge user parameters with tenantId
49+
PARAMS=$(echo '${{ inputs.parameters }}' | jq -c '. + {"tenantId": "${{ secrets.tenant-id }}"}')
50+
else
51+
# Only tenantId
52+
PARAMS='{"tenantId": "${{ secrets.tenant-id }}"}'
53+
fi
54+
echo "params=$PARAMS" >> "$GITHUB_OUTPUT"
55+
4356
- uses: azure/bicep-deploy@v2
4457
name: Perform What-If
4558
with:
@@ -52,4 +65,4 @@ jobs:
5265
name: ${{ github.run_number }}
5366
template-file: ${{ inputs.template-file }}
5467
parameters-file: ${{ inputs.parameters-file }}
55-
parameters: ${{ inputs.parameters }}
68+
parameters: ${{ steps.prepare-params.outputs.params }}

0 commit comments

Comments
 (0)