Skip to content

Commit cd4680e

Browse files
authored
chore(aws): codify iCaptcha enforce in the EC2 node Terraform (#139)
The AWS EC2 node (manila) was upgraded to v0.4.0 and enabled iCaptcha enforce by hand-editing its running /opt/gitlawb/compose.yaml — which would be lost on instance replacement or a user-data re-run. Codify it so rebuilds stay enforced: - variables.tf: add icaptcha_mode (default "enforce"), icaptcha_pubkey (default the pinned live icaptcha.gitlawb.com Ed25519 key), and icaptcha_required_level (default 3). - main.tf: pass the three vars into the compose templatefile render. - compose.yaml.tftpl: set ICAPTCHA_MODE / ICAPTCHA_PUBKEY / ICAPTCHA_REQUIRED_LEVEL on the node service environment. Operators can override per-deployment via terraform.tfvars.
1 parent 8d96cab commit cd4680e

3 files changed

Lines changed: 39 additions & 10 deletions

File tree

infra/aws/compose.yaml.tftpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ services:
5858
GITLAWB_P2P_PORT: "${p2p_port}"
5959
GITLAWB_REPOS_DIR: /data/repos
6060
GITLAWB_KEY: /data/keys/identity.pem
61+
# iCaptcha proof-of-intelligence gate (spam protection on create/fork/register)
62+
ICAPTCHA_MODE: ${icaptcha_mode}
63+
ICAPTCHA_PUBKEY: ${icaptcha_pubkey}
64+
ICAPTCHA_REQUIRED_LEVEL: "${icaptcha_required_level}"
6165
GITLAWB_PUBLIC_URL: $${GITLAWB_PUBLIC_URL}
6266
GITLAWB_BOOTSTRAP_PEERS: $${GITLAWB_BOOTSTRAP_PEERS}
6367
GITLAWB_AUTO_SYNC: $${GITLAWB_AUTO_SYNC}

infra/aws/main.tf

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,19 @@ locals {
290290
)
291291

292292
compose_yaml = templatefile("${path.module}/compose.yaml.tftpl", {
293-
image_repo = local.image_repo
294-
image_tag = var.image_tag
295-
domain_name = var.domain_name
296-
db_host = var.use_rds ? aws_db_instance.node[0].address : ""
297-
gitlawb_port = var.gitlawb_port
298-
p2p_port = var.gitlawb_p2p_port
299-
metrics_port = var.metrics_port
300-
expose_metrics = local.expose_metrics
301-
pg_user = var.postgres_user
302-
pg_db = var.postgres_db
293+
image_repo = local.image_repo
294+
image_tag = var.image_tag
295+
domain_name = var.domain_name
296+
db_host = var.use_rds ? aws_db_instance.node[0].address : ""
297+
gitlawb_port = var.gitlawb_port
298+
p2p_port = var.gitlawb_p2p_port
299+
metrics_port = var.metrics_port
300+
expose_metrics = local.expose_metrics
301+
pg_user = var.postgres_user
302+
pg_db = var.postgres_db
303+
icaptcha_mode = var.icaptcha_mode
304+
icaptcha_pubkey = var.icaptcha_pubkey
305+
icaptcha_required_level = var.icaptcha_required_level
303306
})
304307

305308
user_data = templatefile("${path.module}/user-data.sh.tftpl", {

infra/aws/variables.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,28 @@ variable "image_tag" {
8181
default = "latest"
8282
}
8383

84+
# ---------------------------------------------------------------------------
85+
# iCaptcha proof-of-intelligence gate (spam protection on writes)
86+
# ---------------------------------------------------------------------------
87+
88+
variable "icaptcha_mode" {
89+
description = "iCaptcha gate mode: off | shadow | enforce. The live gitlawb network enforces."
90+
type = string
91+
default = "enforce"
92+
}
93+
94+
variable "icaptcha_pubkey" {
95+
description = "base64url Ed25519 public key of the iCaptcha service, pinned so startup doesn't depend on fetching it. This is the live icaptcha.gitlawb.com key."
96+
type = string
97+
default = "xjyPNqIbvc9U-kwXW6u9mDqRJ7E2UUMOaJdUWhpEXq8"
98+
}
99+
100+
variable "icaptcha_required_level" {
101+
description = "Minimum iCaptcha proof level required to pass the gate."
102+
type = number
103+
default = 3
104+
}
105+
84106
# ---------------------------------------------------------------------------
85107
# Networking / ingress
86108
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)