Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ jobs:
healthcheck: ${{ env.HEALTHCHECK_CMD }}
db-seed: false
smoke-test: false
gcp-wip: ${{ vars.GCP_WIP }}
gcp-project-id: ${{ vars.GCP_PROJECT_ID }}

# ---------------------------
# REVIEW APP DATABASE DEPLOYMENT (PR)
Expand Down Expand Up @@ -472,6 +474,8 @@ jobs:
teams-webhook-url: ${{ secrets.TEAMS_WEBHOOK_URL }}
service: ${{ vars.TEAMS_MSG_SERVICE_NAME }}
smoke-test: false
gcp-wip: ${{ vars.GCP_WIP }}
gcp-project-id: ${{ vars.GCP_PROJECT_ID }}

manual_deploy:
name: Manual deploy
Expand Down Expand Up @@ -506,6 +510,8 @@ jobs:
teams-webhook-url: ${{ secrets.TEAMS_WEBHOOK_URL }}
service: ${{ vars.TEAMS_MSG_SERVICE_NAME }}
smoke-test: false
gcp-wip: ${{ vars.GCP_WIP }}
gcp-project-id: ${{ vars.GCP_PROJECT_ID }}

- name: Checkout (needed for workspace consistency)
if: ${{ inputs.environment == 'review' && inputs.refresh-review-db }}
Expand Down
23 changes: 20 additions & 3 deletions SAPSec.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using GovUk.Frontend.AspNetCore;
using Dfe.Analytics;
using Dfe.Analytics.AspNetCore;
using GovUk.Frontend.AspNetCore;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Localization;
Expand Down Expand Up @@ -114,7 +116,20 @@ public static void Main(string[] args)
options.RequestCultureProviders.Clear();
});

builder.Services.AddHealthChecks();
builder.Services.AddHealthChecks();

//builder.Services.AddDfeAnalytics(options =>
//{
// // options.ProjectId = builder.Configuration["DfeAnalytics:ProjectId"];
// // options.DatasetId = builder.Configuration["DfeAnalytics:DatasetId"];
// // options.Environment = builder.Environment.EnvironmentName;
//}).AddAspNetCoreIntegration(options =>
//{
// options.UserIdClaimType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier";
// options.TableId = "events";
//});

builder.Services.AddDfeAnalytics().AddAspNetCoreIntegration();

var establishmentsCsvPath = builder.Configuration["Establishments:CsvPath"];

Expand Down Expand Up @@ -201,7 +216,9 @@ public static void Main(string[] args)

app.UseAuthorization();

app.MapHealthChecks("/healthcheck");
app.MapHealthChecks("/healthcheck");

app.UseDfeAnalytics();

app.MapControllers();
app.MapRazorPages();
Expand Down
1 change: 1 addition & 0 deletions SAPSec.Web/SAPSec.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ItemGroup>
<PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Blobs" Version="1.5.1" />
<PackageReference Include="Azure.Identity" Version="1.17.1" />
<PackageReference Include="DfeAnalytics.AspNetCore" Version="0.4.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.11" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.1" />
Expand Down
5 changes: 5 additions & 0 deletions SAPSec.Web/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"Establishments": {
"CsvPath": "..\\SAPSec.Infrastructure\\Data\\Establishments.csv"
},
//"DfeAnalytics": {
// "ProjectId": "school-standards",
// "DatasetId": "gsii_events_test",
// "Environment": "development"
//},
"DsiConfiguration": {
"ApiUri": "https://test-api.signin.education.gov.uk",
"Authority": "https://test-oidc.signin.education.gov.uk",
Expand Down
4 changes: 4 additions & 0 deletions SAPSec.Web/appsettings.Test.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"GoogleTagManagerPreview": "env-14",
"ClarityId": "vmzvlwvw68"
},
//"DfeAnalytics": {
// "ProjectId": "school-standards",
// "DatasetId": "gsii_events_test"
//},
"DsiConfiguration": {
"ApiUri": "https://test-api.signin.education.gov.uk",
"Authority": "https://test-oidc.signin.education.gov.uk",
Expand Down
4 changes: 4 additions & 0 deletions SAPSec.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
"Establishments": {
"CsvPath": "Data/Establishments.csv"
},
//"DfeAnalytics": {
// "ProjectId": "school-standards",
// "DatasetId": "gsii_events_production"
//},
"DsiConfiguration": {
"ApiUri": "https://pp-api.signin.education.gov.uk",
"Authority": "https://pp-oidc.signin.education.gov.uk",
Expand Down
25 changes: 24 additions & 1 deletion terraform/application/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 13 additions & 12 deletions terraform/application/application.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module "application_configuration" {
# Delete for non rails apps
is_rails_application = true

config_variables = {
config_variables = merge({
ENVIRONMENT_NAME = var.environment
PGSSLMODE = local.postgres_ssl_mode

Expand All @@ -65,18 +65,18 @@ module "application_configuration" {
DsiConfiguration__ValidateAudience = "true"
DsiConfiguration__ValidateLifetime = "true"
DsiConfiguration__TokenExpiryMinutes = "60"
}
secret_variables = {
DATABASE_URL = module.postgres.url
}, local.federated_auth_configmap)
secret_variables = merge({
DATABASE_URL = module.postgres.url
ConnectionStrings__PostgresConnectionString = module.postgres.dotnet_connection_string
DsiConfiguration__ClientId = data.azurerm_key_vault_secret.dsi_client_id.value
DsiConfiguration__ClientSecret = data.azurerm_key_vault_secret.dsi_client_secret.value
DsiConfiguration__ApiSecret = data.azurerm_key_vault_secret.dsi_api_secret.value
DsiConfiguration__ServiceId = data.azurerm_key_vault_secret.dsi_service_id.value
DFESignInSettings__SignInUri = data.azurerm_key_vault_secret.sign_in_url.value
DFESignInSettings__HelpUri = data.azurerm_key_vault_secret.help_uri.value
StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=${module.storage.name};AccountKey=${module.storage.primary_access_key}"
}
DsiConfiguration__ClientId = data.azurerm_key_vault_secret.dsi_client_id.value
DsiConfiguration__ClientSecret = data.azurerm_key_vault_secret.dsi_client_secret.value
DsiConfiguration__ApiSecret = data.azurerm_key_vault_secret.dsi_api_secret.value
DsiConfiguration__ServiceId = data.azurerm_key_vault_secret.dsi_service_id.value
DFESignInSettings__SignInUri = data.azurerm_key_vault_secret.sign_in_url.value
DFESignInSettings__HelpUri = data.azurerm_key_vault_secret.help_uri.value
StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=${module.storage.name};AccountKey=${module.storage.primary_access_key}"
}, local.federated_auth_secrets)
}

module "web_application" {
Expand All @@ -97,4 +97,5 @@ module "web_application" {
replicas = var.replicas

send_traffic_to_maintenance_page = var.send_traffic_to_maintenance_page
enable_gcp_wif = var.enable_dfe_analytics_federated_auth
}
3 changes: 2 additions & 1 deletion terraform/application/config/review.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"cluster": "test",
"namespace": "sip-development",
"deploy_azure_backing_services": false,
"enable_postgres_ssl" : false
"enable_postgres_ssl" : false,
"enable_dfe_analytics_federated_auth": true
}
3 changes: 2 additions & 1 deletion terraform/application/config/test.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"enable_postgres_backup_storage": true,
"replicas": 2,
"enable_logit": true,
"storage_container_delete_retention_days": 7
"storage_container_delete_retention_days": 7,
"enable_dfe_analytics_federated_auth": true
}
19 changes: 19 additions & 0 deletions terraform/application/dfe_analytics.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
provider "google" {
project = "school-standards"
}

module "dfe_analytics" {
count = local.dfe_analytics_enabled ? 1 : 0
source = "./vendor/modules/aks//aks/dfe_analytics"

azure_resource_prefix = var.azure_resource_prefix
cluster = var.cluster
namespace = var.namespace
service_short = var.service_short
environment = local.environment

gcp_keyring = "school-standards-key-ring"
gcp_key = "school-standards-key"
gcp_taxonomy_id = "9218536955874377223"
gcp_policy_tag_id = "1991951892101805780"
}
15 changes: 14 additions & 1 deletion terraform/application/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ locals {
dsi_urls = local.dsi_config[local.dsi_environment]

key_vault_name = "${var.azure_resource_prefix}-${var.service_short}-${var.config_short}-app-kv"

resource_group_name = "${var.azure_resource_prefix}-${var.service_short}-${var.config_short}-rg"

dfe_analytics_enabled = var.enable_dfe_analytics_federated_auth

federated_auth_configmap = local.dfe_analytics_enabled ? {
DfeAnalytics__Environment = local.environment
DfeAnalytics__ProjectId = module.dfe_analytics[0].bigquery_project_id
DfeAnalytics__DatasetId = module.dfe_analytics[0].bigquery_dataset
DfeAnalytics__TableId = module.dfe_analytics[0].bigquery_table_name
} : {}

federated_auth_secrets = local.dfe_analytics_enabled ? {
DfeAnalytics__CredentialsJson = module.dfe_analytics[0].google_cloud_credentials
} : {}
}
6 changes: 5 additions & 1 deletion terraform/application/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ variable "azure_maintenance_window" {
start_hour = number
start_minute = number
})
default = null
default = null
description = "Maintenance window for PostgreSQL. Day 0 = Sunday, 1 = Monday, etc."
}
variable "docker_image" {
Expand Down Expand Up @@ -112,4 +112,8 @@ locals {
variable "enable_logit" { default = true }


variable "enable_dfe_analytics_federated_auth" {
description = "Create the resources in Google cloud for federated authentication and enable in application"
default = false
}

Loading