Skip to content

Commit c78a28a

Browse files
authored
Security updates (#21)
* remove zone assignment in PostgreSQL Terraform * Managed identity PostgreSQL * front door rate limiting * jumpbox SSH Microsoft Entra ID * add ssh files to gitignore
1 parent 4cd6870 commit c78a28a

File tree

23 files changed

+206
-96
lines changed

23 files changed

+206
-96
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"VARIANT": "jammy"
77
}
88
},
9+
"postStartCommand": "./.devcontainer/scripts/onCreateCommand.sh",
910
"remoteUser": "vscode",
1011
"containerEnv": {
1112
"M2": "/home/vscode" // required because the java feature is not setting this correctly
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set -x
2+
3+
az extension add --name serviceconnector-passwordless --upgrade

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,8 @@ application-dev.properties
4949
*.terraform.lock.hcl
5050
.terraform/
5151
*.tfplan
52-
.DS_Store
52+
.DS_Store
53+
54+
# Azure CLI configuration
55+
az_ssh_config/
56+
ssh-config

apps/contoso-fiber/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
<groupId>org.springframework.boot</groupId>
5353
<artifactId>spring-boot-starter-data-jpa</artifactId>
5454
</dependency>
55+
<dependency>
56+
<groupId>com.azure.spring</groupId>
57+
<artifactId>spring-cloud-azure-starter-jdbc-postgresql</artifactId>
58+
</dependency>
5559
<dependency>
5660
<groupId>org.postgresql</groupId>
5761
<artifactId>postgresql</artifactId>
@@ -142,6 +146,11 @@
142146
<artifactId>spring-cloud-azure-starter-storage-blob</artifactId>
143147
</dependency>
144148

149+
<dependency>
150+
<groupId>org.apache.commons</groupId>
151+
<artifactId>commons-lang3</artifactId>
152+
</dependency>
153+
145154
</dependencies>
146155

147156
<build>
File renamed without changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
source_id=$1
4+
target_id=$2
5+
6+
random_string=$RANDOM
7+
connection_name=postgresql_${RANDOM}
8+
9+
az webapp connection create postgres-flexible --connection ${connection_name} --source-id ${source_id} --target-id ${target_id} --client-type springBoot --system-identity

infra/shared/terraform/modules/app-service/main.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ resource "azurerm_linux_web_app" "application" {
104104
APPINSIGHTS_INSTRUMENTATIONKEY = var.app_insights_instrumentation_key
105105
ApplicationInsightsAgent_EXTENSION_VERSION = "~3"
106106

107-
DATABASE_URL = var.contoso_webapp_options.postgresql_database_url
108-
DATABASE_USERNAME = var.contoso_webapp_options.postgresql_database_user
109-
DATABASE_PASSWORD = var.contoso_webapp_options.postgresql_database_password
110-
111107
AZURE_ACTIVE_DIRECTORY_CREDENTIAL_CLIENT_ID = var.contoso_webapp_options.contoso_active_directory_client_id
112108
AZURE_ACTIVE_DIRECTORY_CREDENTIAL_CLIENT_SECRET = var.contoso_webapp_options.contoso_active_directory_client_secret
113109
AZURE_ACTIVE_DIRECTORY_TENANT_ID = var.contoso_webapp_options.contoso_active_directory_tenant_id

infra/shared/terraform/modules/app-service/variables.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ variable "contoso_webapp_options" {
7070
contoso_active_directory_client_id = string
7171
contoso_active_directory_client_secret = string
7272

73-
postgresql_database_url = string
74-
postgresql_database_user = string
75-
postgresql_database_password = string
76-
7773
redis_host_name = string
7874
redis_port = number
7975
redis_password = string

infra/shared/terraform/modules/cache/main.tf

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,14 @@ resource "azurerm_monitor_diagnostic_setting" "redis_diagnostic" {
7575

7676
enabled_log {
7777
category_group = "audit"
78-
79-
retention_policy {
80-
days = 0
81-
enabled = false
82-
}
8378
}
8479

8580
enabled_log {
8681
category_group = "allLogs"
87-
88-
retention_policy {
89-
days = 0
90-
enabled = false
91-
}
9282
}
9383

9484
metric {
9585
category = "AllMetrics"
9686
enabled = true
97-
retention_policy {
98-
enabled = false
99-
days = 0
100-
}
10187
}
10288
}

infra/shared/terraform/modules/frontdoor/main.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,24 @@ resource "azurerm_cdn_frontdoor_firewall_policy" "firewall_policy" {
118118
sku_name = azurerm_cdn_frontdoor_profile.front_door.sku_name
119119
enabled = true
120120
mode = "Prevention"
121+
122+
custom_rule {
123+
name = "RateLimitingRule"
124+
priority = 100
125+
type = "RateLimitRule"
126+
127+
match_condition {
128+
match_variable = "RemoteAddr"
129+
operator = "IPMatch"
130+
match_values = ["0.0.0.0/0"]
131+
negation_condition = false
132+
}
133+
134+
rate_limit_duration_in_minutes = 1
135+
rate_limit_threshold = 200
136+
137+
action = "Block"
138+
}
121139
}
122140

123141
resource "azurecaf_name" "front_door_security_policy_name" {

0 commit comments

Comments
 (0)