Skip to content

Commit

Permalink
chore: use key vault for client secret
Browse files Browse the repository at this point in the history
  • Loading branch information
nlykkei committed Jul 12, 2024
1 parent 490f0c9 commit 8a3a3f3
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 12 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ on:
resourceGroupName:
required: true
type: string
reviewApiUrl:
required: true
type: string
secrets:
AZURE_CLIENT_ID:
required: true
AZURE_TENANT_ID:
required: true
AZURE_SUBSCRIPTION_ID:
required: true
reviewApiKey:
required: true

jobs:
validate:
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ jobs:
with:
environment: test
resourceGroupName: TodoAppTest
reviewApiUrl: https://sandbox.contoso.com/reviews
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
reviewApiKey: ${{ secrets.REVIEW_API_KEY_TEST }}
needs: [build, lint]

deploy-production:
Expand All @@ -46,10 +44,8 @@ jobs:
with:
environment: production
resourceGroupName: TodoAppProd
reviewApiUrl: https://api.contoso.com/reviews
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
reviewApiKey: ${{ secrets.REVIEW_API_KEY_PRODUCTION }}
needs: [deploy-test]
4 changes: 4 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ resource appServiceApp 'Microsoft.Web/sites@2022-03-01' = {
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: applicationInsights.properties.ConnectionString
}
{
name: 'AzureAd__ClientSecret'
value: '@Microsoft.KeyVault(SecretUri=https://todo-app-rbqkyp2g5zxmq.vault.azure.net/secrets/ClientSecret/)'
}
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/TodoApp/Controllers/WeatherForecastController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public WeatherForecastController(ILogger<WeatherForecastController> logger,
[HttpGet(Name = "GetWeatherForecast")]
public async Task<IEnumerable<WeatherForecast>> Get()
{
// var user = await _graphServiceClient.Me.GetAsync();
var user = await _graphServiceClient.Me.GetAsync();

_logger.LogInformation("Getting weather forecast");

Expand Down
2 changes: 1 addition & 1 deletion src/TodoApp/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/TodoApp/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"Microsoft.AspNetCore": "Warning"
}
}
}
}
1 change: 1 addition & 0 deletions src/TodoApp/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"Domain": "qualified.domain.name",
"TenantId": "1d063515-6cad-4195-9486-ea65df456faa",
"ClientId": "cf2b7db1-87aa-4fe1-90c8-219abd6f1609",
"ClientSecret": "secret-from-app-registration",
"Scopes": "user_impersonation",
"CallbackPath": "/signin-oidc"
},
Expand Down

0 comments on commit 8a3a3f3

Please sign in to comment.