From fae8b1e3aaac77a49338c1b47ff98bbbfe332908 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Wed, 4 Nov 2026 23:10:12 -0600 Subject: [PATCH 1/3] feat: separate Argo UI exposure and webhook endpoint Implements [[tasks/gitops-private-ui-public-webhook]] --- .github/workflows/on-pr.yaml | 2 + .github/workflows/on-push-main.yaml | 2 + Makefile | 3 + README.md | 49 +++++++- apis/gitopsstacks/definition.yaml | 17 ++- examples/gitopsstacks/private-ui.yaml | 24 ++++ functions/render/000-state-init.yaml.gotmpl | 13 +- .../200-helm-release-argocd.yaml.gotmpl | 3 + tests/test-render/main.k | 115 ++++++++++++++++++ 9 files changed, 218 insertions(+), 10 deletions(-) create mode 100644 examples/gitopsstacks/private-ui.yaml diff --git a/.github/workflows/on-pr.yaml b/.github/workflows/on-pr.yaml index 6e819ac..d11e49f 100644 --- a/.github/workflows/on-pr.yaml +++ b/.github/workflows/on-pr.yaml @@ -35,6 +35,8 @@ jobs: { "example": "examples/gitopsstacks/minimal.yaml" }, { "example": "examples/gitopsstacks/standard.yaml" }, { "example": "examples/gitopsstacks/webhook.yaml" }, + { "example": "examples/gitopsstacks/private-ui.yaml" }, + { "example": "examples/gitopsstacks/nodepool.yaml" }, { "example": "examples/gitopsstacks/standard.yaml", "observed_resources": "examples/test/mocks/observed-resources/standard/steps/1/" }, { "example": "examples/gitopsstacks/standard.yaml", "observed_resources": "examples/test/mocks/observed-resources/standard/steps/2/" }, { "example": "examples/gitopsstacks/eso.yaml" }, diff --git a/.github/workflows/on-push-main.yaml b/.github/workflows/on-push-main.yaml index 5f71054..e3c1594 100644 --- a/.github/workflows/on-push-main.yaml +++ b/.github/workflows/on-push-main.yaml @@ -30,6 +30,8 @@ jobs: { "example": "examples/gitopsstacks/minimal.yaml" }, { "example": "examples/gitopsstacks/standard.yaml" }, { "example": "examples/gitopsstacks/webhook.yaml" }, + { "example": "examples/gitopsstacks/private-ui.yaml" }, + { "example": "examples/gitopsstacks/nodepool.yaml" }, { "example": "examples/gitopsstacks/standard.yaml", "observed_resources": "examples/test/mocks/observed-resources/standard/steps/1/" }, { "example": "examples/gitopsstacks/standard.yaml", "observed_resources": "examples/test/mocks/observed-resources/standard/steps/2/" }, { "example": "examples/gitopsstacks/eso.yaml" }, diff --git a/Makefile b/Makefile index b5afe81..787adda 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ EXAMPLES := \ examples/gitopsstacks/standard.yaml:: \ examples/gitopsstacks/nodepool.yaml:: \ examples/gitopsstacks/webhook.yaml:: \ + examples/gitopsstacks/private-ui.yaml:: \ examples/gitopsstacks/standard.yaml::examples/test/mocks/observed-resources/standard/steps/1/ \ examples/gitopsstacks/standard.yaml::examples/test/mocks/observed-resources/standard/steps/2/ \ examples/gitopsstacks/eso.yaml:: \ @@ -46,6 +47,7 @@ render\:all: observed=$${entry#*::}; \ outfile="$$tmpdir/$$(echo $$entry | tr '/:' '__')"; \ ( \ + set -euo pipefail; \ if [ -n "$$observed" ]; then \ echo "=== Rendering $$example with observed-resources $$observed ==="; \ up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example --observed-resources=$$observed; \ @@ -76,6 +78,7 @@ validate\:all: generate-configuration observed=$${entry#*::}; \ outfile="$$tmpdir/$$(echo $$entry | tr '/:' '__')"; \ ( \ + set -euo pipefail; \ if [ -n "$$observed" ]; then \ echo "=== Validating $$example with observed-resources $$observed ==="; \ up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example \ diff --git a/README.md b/README.md index 7b96b57..6fa9216 100644 --- a/README.md +++ b/README.md @@ -143,9 +143,52 @@ This creates a GitHub `push` webhook for `https://argocd.example.com/api/webhook`. The generated secret uses `updatePolicy: IfNotExists` and is retained when the stack is deleted, making AWS Secrets Manager the durable source of truth. SecretStack, a path under its -`push/*` write boundary, and a public ArgoCD Gateway route are required. Set +`push/*` write boundary, and a publicly reachable webhook endpoint are required. Set `generate: false` to read a pre-existing secret from another path instead. + +#### Private UI with a separate public webhook + +Set `repository.webhook.url` to a public HTTPS endpoint when the UI hostname +resolves to a private Gateway. The URL must end in `/api/webhook` and cannot +contain credentials, a query string or a fragment. Without this override the +existing `https:///api/webhook` behavior is unchanged. + +```yaml +spec: + exposure: + enabled: true + hostname: argocd.example.com + gatewayRef: + name: private + namespace: ingress + sectionName: https-argocd + routeAnnotations: + external-dns.alpha.kubernetes.io/cloudflare-proxied: "false" + repository: + org: hops-ops + webhook: + enabled: true + url: https://argocd-webhook.example.com/api/webhook + secretPath: push/example-cluster/argo/github-webhook +``` + +The webhook override updates the URL exported in the shared Kubernetes Secret; +GitopsEnvironment consumers of that Secret follow it on reconciliation. It does +not rotate the HMAC secret, change the UI URL, alter native OIDC callbacks or +create a public route. Provision a separate public HTTPRoute before changing +webhook URLs. Restrict that route to `POST` and the exact `/api/webhook` path, +backed by `argocd-server:80` in the Argo namespace; keep all UI/API paths private. +Argo validates the existing shared HMAC signature. Verify new GitHub deliveries +before moving the UI's DNS and Gateway parent. A webhook may also use an explicit +URL with `exposure.enabled: false` if routing is managed separately. + +`exposure.routeAnnotations` applies only to the UI HTTPRoute. Typed annotation +keys take precedence over matching `argocd.values.server.httproute.annotations` +keys while retaining unrelated raw annotations. Other Helm values and resources +are unaffected. The public/private network boundary belongs to the chosen +Gateway and DNS target; annotations alone do not make an endpoint private. + ### Stage 3: Crossplane Integration Enable ArgoCD-managed Crossplane resources for full platform automation. @@ -308,7 +351,8 @@ The Usage ensures ArgoCD CRDs stay alive until all ArgoCD Application CRs are cl | `argocd.values` | object | no | `{}` | Helm values merged with defaults | | `argocd.overrideAllValues` | object | no | — | Helm values replacing all defaults | | `exposure.enabled` | boolean | no | `false` | Create an ArgoCD HTTPRoute | -| `exposure.hostname` | string | with exposure | — | Public ArgoCD hostname | +| `exposure.hostname` | string | with exposure | — | ArgoCD UI hostname | +| `exposure.routeAnnotations` | map of strings | no | `{}` | Annotations on only the ArgoCD HTTPRoute | | `exposure.gatewayRef.*` | object | no | `platform` / `istio-ingress` / `https` | Existing Gateway listener | | `auth.oidc.enabled` | boolean | no | `false` | Enable native ArgoCD OIDC with Zitadel | | `auth.oidc.issuerURL` | string | with OIDC | — | Zitadel issuer URL | @@ -325,6 +369,7 @@ The Usage ensures ArgoCD CRDs stay alive until all ArgoCD Application CRs are cl | `repository.topics` | []string | no | `[]` | Repository topics | | `repository.deleteBranchOnMerge` | boolean | no | `true` | Auto-delete head branches on merge | | `repository.webhook.enabled` | boolean | no | `false` | Create a signed GitHub push webhook for immediate ArgoCD refreshes | +| `repository.webhook.url` | string | no | `https:///api/webhook` | Independent public HTTPS webhook endpoint | | `repository.webhook.generate` | boolean | no | `true` | Generate the shared secret once and push it to AWS Secrets Manager | | `repository.webhook.secretStoreName` | string | no | `externalSecrets.secretStoreName` or `default` | ClusterSecretStore used to push and read the shared secret | | `repository.webhook.secretPath` | string | when enabled | — | AWS Secrets Manager path containing the shared secret | diff --git a/apis/gitopsstacks/definition.yaml b/apis/gitopsstacks/definition.yaml index f6dbb4f..93944cd 100644 --- a/apis/gitopsstacks/definition.yaml +++ b/apis/gitopsstacks/definition.yaml @@ -126,7 +126,7 @@ spec: type: object x-kubernetes-preserve-unknown-fields: true exposure: - description: Optional public exposure of the ArgoCD server through an existing Gateway API Gateway. + description: Optional exposure of the ArgoCD server through an existing public or private Gateway API Gateway. type: object properties: enabled: @@ -134,9 +134,14 @@ spec: type: boolean default: false hostname: - description: Public DNS hostname for ArgoCD. + description: DNS hostname for ArgoCD. type: string minLength: 1 + routeAnnotations: + description: Annotations applied to the ArgoCD HTTPRoute, including per-route DNS provider settings. + type: object + additionalProperties: + type: string gatewayRef: description: Existing Gateway listener that accepts the ArgoCD HTTPRoute. type: object @@ -262,13 +267,17 @@ spec: type: boolean default: false webhook: - description: GitHub webhook that immediately refreshes ArgoCD Applications when the repository changes. Requires SecretStack and public ArgoCD exposure. + description: GitHub webhook that immediately refreshes ArgoCD Applications when the repository changes. Requires SecretStack and a publicly reachable webhook endpoint. type: object properties: enabled: - description: Create a push webhook targeting the exposed ArgoCD server. Defaults to false. + description: Create a push webhook targeting ArgoCD. Defaults to false. type: boolean default: false + url: + description: Public HTTPS ArgoCD webhook URL ending in /api/webhook. Defaults to https:///api/webhook. Set this independently when the UI uses private exposure. + type: string + pattern: '^https://[A-Za-z0-9]([A-Za-z0-9.-]*[A-Za-z0-9])?(:[0-9]{1,5})?/api/webhook$' generate: description: Generate the shared secret and push it to AWS Secrets Manager. Defaults to true. Set false to use a pre-existing secret. type: boolean diff --git a/examples/gitopsstacks/private-ui.yaml b/examples/gitopsstacks/private-ui.yaml new file mode 100644 index 0000000..505182f --- /dev/null +++ b/examples/gitopsstacks/private-ui.yaml @@ -0,0 +1,24 @@ +apiVersion: hops.ops.com.ai/v1alpha1 +kind: GitopsStack +metadata: + name: gitops + namespace: example-env +spec: + clusterName: example-cluster + exposure: + enabled: true + hostname: argocd.example.com + gatewayRef: + name: private + namespace: ingress + sectionName: https-argocd + routeAnnotations: + external-dns.alpha.kubernetes.io/cloudflare-proxied: "false" + repository: + org: hops-ops + name: example-cluster-gitops + webhook: + enabled: true + url: https://argocd-webhook.example.com/api/webhook + secretStoreName: default + secretPath: push/example-cluster/argo/github-webhook diff --git a/functions/render/000-state-init.yaml.gotmpl b/functions/render/000-state-init.yaml.gotmpl index 9291984..d19bd63 100644 --- a/functions/render/000-state-init.yaml.gotmpl +++ b/functions/render/000-state-init.yaml.gotmpl @@ -99,7 +99,7 @@ {{- $argocdSpec := $spec.argocd | default dict }} # ============================================================================== -# Public exposure +# Gateway exposure # ============================================================================== {{- $exposureSpec := $spec.exposure | default dict }} {{- $exposureEnabled := false }} @@ -168,8 +168,12 @@ {{- if and $webhookEnabled $webhookGenerate (not (hasPrefix "push/" ($webhookSpec.secretPath | default ""))) }} {{- fail "spec.repository.webhook.secretPath must start with push/ when secret generation is enabled" }} {{- end }} -{{- if and $webhookEnabled (not $exposureEnabled) }} - {{- fail "spec.exposure.enabled must be true when the GitHub webhook is enabled" }} +{{- $webhookURLOverride := $webhookSpec.url | default "" }} +{{- if and (hasKey $webhookSpec "url") (not (regexMatch `^https://[A-Za-z0-9]([A-Za-z0-9.-]*[A-Za-z0-9])?(:[0-9]{1,5})?/api/webhook$` $webhookURLOverride)) }} + {{- fail "spec.repository.webhook.url must be an HTTPS endpoint ending in /api/webhook without credentials, query or fragment" }} +{{- end }} +{{- if and $webhookEnabled (not $exposureEnabled) (eq $webhookURLOverride "") }} + {{- fail "spec.exposure.enabled must be true when the GitHub webhook is enabled unless spec.repository.webhook.url is provided" }} {{- end }} # Template config (optional) @@ -229,6 +233,7 @@ "exposure" (dict "enabled" $exposureEnabled "hostname" $exposureHostname + "routeAnnotations" ($exposureSpec.routeAnnotations | default dict) "gatewayRef" (dict "name" ($gatewayRefSpec.name | default "platform") "namespace" ($gatewayRefSpec.namespace | default "istio-ingress") @@ -280,7 +285,7 @@ "generatorName" (printf "%s-github-webhook" $name) "providerSecretName" (printf "%s-github-webhook" $name) "argocdSecretName" (printf "%s-argocd-github-webhook" $name) - "url" (printf "https://%s/api/webhook" $exposureHostname) + "url" ($webhookURLOverride | default (printf "https://%s/api/webhook" $exposureHostname)) "maxPayloadSizeMB" ($webhookSpec.maxPayloadSizeMB | default 10) ) ) diff --git a/functions/render/200-helm-release-argocd.yaml.gotmpl b/functions/render/200-helm-release-argocd.yaml.gotmpl index 91337a5..9208f3f 100644 --- a/functions/render/200-helm-release-argocd.yaml.gotmpl +++ b/functions/render/200-helm-release-argocd.yaml.gotmpl @@ -105,6 +105,9 @@ spec: ) ) }} + {{- with $state.exposure.routeAnnotations }} + {{- $_ := set $exposureValues.server.httproute "annotations" . }} + {{- end }} {{- $effectiveValues = mergeOverwrite $effectiveValues $exposureValues }} {{- end }} diff --git a/tests/test-render/main.k b/tests/test-render/main.k index 66d2c6d..55aeb44 100644 --- a/tests/test-render/main.k +++ b/tests/test-render/main.k @@ -1152,6 +1152,121 @@ _items = [ ] } } + # A private UI keeps its callback/domain while the exported webhook URL moves. + metav1alpha1.CompositionTest { + metadata.name = "private-ui-public-webhook" + spec = { + compositionPath = "apis/gitopsstacks/composition.yaml" + xrdPath = "apis/gitopsstacks/definition.yaml" + timeoutSeconds = 60 + validate = False + xr = { + apiVersion = "hops.ops.com.ai/v1alpha1" + kind = "GitopsStack" + metadata = {name = "private-ui", namespace = "platform"} + spec = { + clusterName = "test-cluster" + argocd.values.server.httproute.annotations = { + "example.com/retained" = "yes" + "external-dns.alpha.kubernetes.io/cloudflare-proxied" = "true" + } + exposure = { + enabled = True + hostname = "argocd.example.com" + gatewayRef = {name = "private", namespace = "ingress", sectionName = "https-argocd"} + routeAnnotations = {"external-dns.alpha.kubernetes.io/cloudflare-proxied" = "false"} + } + repository = { + org = "hops-ops" + webhook = { + enabled = True + generate = False + secretPath = "existing/github-webhook" + url = "https://argocd-webhook.example.com/api/webhook" + } + } + } + } + assertResources = [ + { + apiVersion = "helm.m.crossplane.io/v1beta1" + kind = "Release" + metadata.name = "argocd" + spec.forProvider.values = { + global.domain = "argocd.example.com" + configs.cm.url = "https://argocd.example.com" + configs.secret.githubSecret = "$private-ui-argocd-github-webhook:secret" + server.httproute = { + enabled = True + hostnames = ["argocd.example.com"] + parentRefs = [{name = "private", namespace = "ingress", sectionName = "https-argocd"}] + annotations = { + "example.com/retained" = "yes" + "external-dns.alpha.kubernetes.io/cloudflare-proxied" = "false" + } + } + } + } + { + apiVersion = "kubernetes.m.crossplane.io/v1alpha1" + kind = "Object" + metadata.name = "private-ui-github-webhook-secret" + spec.forProvider.manifest.spec = { + target.template.data.url = "https://argocd-webhook.example.com/api/webhook" + data = [{secretKey = "webhookSecret", remoteRef = {key = "existing/github-webhook", property = "webhookSecret"}}] + } + } + { + apiVersion = "repo.github.m.upbound.io/v1alpha1" + kind = "RepositoryWebhook" + metadata.name = "test-cluster-gitops" + spec.forProvider.configuration = [{ + contentType = "json" + insecureSsl = False + urlSecretRef = {name = "private-ui-github-webhook", key = "url"} + secretSecretRef = {name = "private-ui-github-webhook", key = "secret"} + }] + } + ] + } + } + # A public webhook can reach a server whose UI route is managed elsewhere. + metav1alpha1.CompositionTest { + metadata.name = "webhook-without-ui-exposure" + spec = { + compositionPath = "apis/gitopsstacks/composition.yaml" + xrdPath = "apis/gitopsstacks/definition.yaml" + timeoutSeconds = 60 + validate = False + xr = { + apiVersion = "hops.ops.com.ai/v1alpha1" + kind = "GitopsStack" + metadata = {name = "webhook-only", namespace = "platform"} + spec = { + clusterName = "test-cluster" + exposure.enabled = False + repository = { + org = "hops-ops" + webhook = { + enabled = True + generate = False + secretPath = "existing/github-webhook" + url = "https://argocd-webhook.example.com/api/webhook" + } + } + } + } + assertResources = [ + { + apiVersion = "kubernetes.m.crossplane.io/v1alpha1" + kind = "Object" + metadata.name = "webhook-only-github-webhook-secret" + spec.forProvider.manifest.spec.target.template.data.url = "https://argocd-webhook.example.com/api/webhook" + } + ] + } + } + ] items = _items From e171e38f8e75a4cbd723b3ba97abe968adfbf5f4 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Wed, 4 Nov 2026 23:13:45 -0600 Subject: [PATCH 2/3] test: validate independent webhook URL admission Implements [[tasks/gitops-private-ui-public-webhook]] --- .github/workflows/on-pr.yaml | 1 + .github/workflows/on-push-main.yaml | 1 + Makefile | 1 + apis/gitopsstacks/definition.yaml | 4 ++-- examples/gitopsstacks/webhook-only.yaml | 17 +++++++++++++++++ 5 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 examples/gitopsstacks/webhook-only.yaml diff --git a/.github/workflows/on-pr.yaml b/.github/workflows/on-pr.yaml index d11e49f..7f2c3b4 100644 --- a/.github/workflows/on-pr.yaml +++ b/.github/workflows/on-pr.yaml @@ -36,6 +36,7 @@ jobs: { "example": "examples/gitopsstacks/standard.yaml" }, { "example": "examples/gitopsstacks/webhook.yaml" }, { "example": "examples/gitopsstacks/private-ui.yaml" }, + { "example": "examples/gitopsstacks/webhook-only.yaml" }, { "example": "examples/gitopsstacks/nodepool.yaml" }, { "example": "examples/gitopsstacks/standard.yaml", "observed_resources": "examples/test/mocks/observed-resources/standard/steps/1/" }, { "example": "examples/gitopsstacks/standard.yaml", "observed_resources": "examples/test/mocks/observed-resources/standard/steps/2/" }, diff --git a/.github/workflows/on-push-main.yaml b/.github/workflows/on-push-main.yaml index e3c1594..7d5e289 100644 --- a/.github/workflows/on-push-main.yaml +++ b/.github/workflows/on-push-main.yaml @@ -31,6 +31,7 @@ jobs: { "example": "examples/gitopsstacks/standard.yaml" }, { "example": "examples/gitopsstacks/webhook.yaml" }, { "example": "examples/gitopsstacks/private-ui.yaml" }, + { "example": "examples/gitopsstacks/webhook-only.yaml" }, { "example": "examples/gitopsstacks/nodepool.yaml" }, { "example": "examples/gitopsstacks/standard.yaml", "observed_resources": "examples/test/mocks/observed-resources/standard/steps/1/" }, { "example": "examples/gitopsstacks/standard.yaml", "observed_resources": "examples/test/mocks/observed-resources/standard/steps/2/" }, diff --git a/Makefile b/Makefile index 787adda..5109f7d 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,7 @@ EXAMPLES := \ examples/gitopsstacks/nodepool.yaml:: \ examples/gitopsstacks/webhook.yaml:: \ examples/gitopsstacks/private-ui.yaml:: \ + examples/gitopsstacks/webhook-only.yaml:: \ examples/gitopsstacks/standard.yaml::examples/test/mocks/observed-resources/standard/steps/1/ \ examples/gitopsstacks/standard.yaml::examples/test/mocks/observed-resources/standard/steps/2/ \ examples/gitopsstacks/eso.yaml:: \ diff --git a/apis/gitopsstacks/definition.yaml b/apis/gitopsstacks/definition.yaml index 93944cd..95d8dce 100644 --- a/apis/gitopsstacks/definition.yaml +++ b/apis/gitopsstacks/definition.yaml @@ -375,8 +375,8 @@ spec: x-kubernetes-validations: - rule: "!has(self.auth) || !has(self.auth.oidc) || !self.auth.oidc.enabled || (has(self.exposure) && self.exposure.enabled)" message: spec.exposure.enabled must be true when native OIDC is enabled - - rule: "!has(self.repository) || !has(self.repository.webhook) || !self.repository.webhook.enabled || (has(self.exposure) && self.exposure.enabled)" - message: spec.exposure.enabled must be true when the GitHub webhook is enabled + - rule: "!has(self.repository) || !has(self.repository.webhook) || !self.repository.webhook.enabled || has(self.repository.webhook.url) || (has(self.exposure) && self.exposure.enabled)" + message: spec.exposure.enabled must be true when the GitHub webhook is enabled unless spec.repository.webhook.url is provided status: description: GitopsStackStatus defines the observed state. type: object diff --git a/examples/gitopsstacks/webhook-only.yaml b/examples/gitopsstacks/webhook-only.yaml new file mode 100644 index 0000000..620fceb --- /dev/null +++ b/examples/gitopsstacks/webhook-only.yaml @@ -0,0 +1,17 @@ +apiVersion: hops.ops.com.ai/v1alpha1 +kind: GitopsStack +metadata: + name: gitops + namespace: example-env +spec: + clusterName: example-cluster + exposure: + enabled: false + repository: + org: hops-ops + name: example-cluster-gitops + webhook: + enabled: true + url: https://argocd-webhook.example.com/api/webhook + secretStoreName: default + secretPath: push/example-cluster/argo/github-webhook From d2530d32e89ec19de49c5f6d4c7c920b45657cab Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Wed, 4 Nov 2026 23:34:03 -0600 Subject: [PATCH 3/3] fix: validate webhook ports and clarify backend TLS Implements [[tasks/gitops-private-ui-public-webhook]] --- README.md | 27 ++++++++++++++++++--- apis/gitopsstacks/definition.yaml | 2 +- examples/gitopsstacks/webhook-only.yaml | 5 ++++ functions/render/000-state-init.yaml.gotmpl | 2 +- tests/test-render/main.k | 11 +++++++-- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6fa9216..46999ef 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,8 @@ AWS Secrets Manager the durable source of truth. SecretStack, a path under its Set `repository.webhook.url` to a public HTTPS endpoint when the UI hostname resolves to a private Gateway. The URL must end in `/api/webhook` and cannot -contain credentials, a query string or a fragment. Without this override the +contain credentials, a query string or a fragment. An explicit port must be +between 1 and 65535. Without this override the existing `https:///api/webhook` behavior is unchanged. ```yaml @@ -179,9 +180,29 @@ not rotate the HMAC secret, change the UI URL, alter native OIDC callbacks or create a public route. Provision a separate public HTTPRoute before changing webhook URLs. Restrict that route to `POST` and the exact `/api/webhook` path, backed by `argocd-server:80` in the Argo namespace; keep all UI/API paths private. -Argo validates the existing shared HMAC signature. Verify new GitHub deliveries +Require `X-GitHub-Event` to be `push` or `ping`, and remove competing provider +headers (`X-Vss-Activityid`, `X-Gogs-Event`, `X-Gitlab-Event`, `X-Hook-UUID`, +`X-Event-Key`) before forwarding. Argo shares this endpoint across providers; +these restrictions ensure requests use the GitHub handler and its existing +shared HMAC verification. Verify new GitHub deliveries before moving the UI's DNS and Gateway parent. A webhook may also use an explicit -URL with `exposure.enabled: false` if routing is managed separately. +URL with `exposure.enabled: false` if routing is managed separately. In that +case the XR does not select backend TLS for the externally managed route. For +TLS termination at the Gateway with an HTTP `argocd-server:80` backend, set: + +```yaml +spec: + argocd: + values: + configs: + params: + server.insecure: "true" +``` + +Alternatively, keep Argo's server TLS enabled and configure the externally +managed Gateway's backend TLS appropriately. Match the backend scheme to this +setting: GitHub webhook POSTs must reach the handler without an HTTP-to-HTTPS +redirect. The public webhook URL itself remains HTTPS in either case. `exposure.routeAnnotations` applies only to the UI HTTPRoute. Typed annotation keys take precedence over matching `argocd.values.server.httproute.annotations` diff --git a/apis/gitopsstacks/definition.yaml b/apis/gitopsstacks/definition.yaml index 95d8dce..8d69ad6 100644 --- a/apis/gitopsstacks/definition.yaml +++ b/apis/gitopsstacks/definition.yaml @@ -277,7 +277,7 @@ spec: url: description: Public HTTPS ArgoCD webhook URL ending in /api/webhook. Defaults to https:///api/webhook. Set this independently when the UI uses private exposure. type: string - pattern: '^https://[A-Za-z0-9]([A-Za-z0-9.-]*[A-Za-z0-9])?(:[0-9]{1,5})?/api/webhook$' + pattern: '^https://[A-Za-z0-9]([A-Za-z0-9.-]*[A-Za-z0-9])?(:(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{0,3}))?/api/webhook$' generate: description: Generate the shared secret and push it to AWS Secrets Manager. Defaults to true. Set false to use a pre-existing secret. type: boolean diff --git a/examples/gitopsstacks/webhook-only.yaml b/examples/gitopsstacks/webhook-only.yaml index 620fceb..44abfcf 100644 --- a/examples/gitopsstacks/webhook-only.yaml +++ b/examples/gitopsstacks/webhook-only.yaml @@ -5,6 +5,11 @@ metadata: namespace: example-env spec: clusterName: example-cluster + argocd: + values: + configs: + params: + server.insecure: "true" exposure: enabled: false repository: diff --git a/functions/render/000-state-init.yaml.gotmpl b/functions/render/000-state-init.yaml.gotmpl index d19bd63..ff0d8e7 100644 --- a/functions/render/000-state-init.yaml.gotmpl +++ b/functions/render/000-state-init.yaml.gotmpl @@ -169,7 +169,7 @@ {{- fail "spec.repository.webhook.secretPath must start with push/ when secret generation is enabled" }} {{- end }} {{- $webhookURLOverride := $webhookSpec.url | default "" }} -{{- if and (hasKey $webhookSpec "url") (not (regexMatch `^https://[A-Za-z0-9]([A-Za-z0-9.-]*[A-Za-z0-9])?(:[0-9]{1,5})?/api/webhook$` $webhookURLOverride)) }} +{{- if and (hasKey $webhookSpec "url") (not (regexMatch `^https://[A-Za-z0-9]([A-Za-z0-9.-]*[A-Za-z0-9])?(:(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{0,3}))?/api/webhook$` $webhookURLOverride)) }} {{- fail "spec.repository.webhook.url must be an HTTPS endpoint ending in /api/webhook without credentials, query or fragment" }} {{- end }} {{- if and $webhookEnabled (not $exposureEnabled) (eq $webhookURLOverride "") }} diff --git a/tests/test-render/main.k b/tests/test-render/main.k index 55aeb44..2394f32 100644 --- a/tests/test-render/main.k +++ b/tests/test-render/main.k @@ -1244,6 +1244,7 @@ _items = [ metadata = {name = "webhook-only", namespace = "platform"} spec = { clusterName = "test-cluster" + argocd.values.configs.params = {"server.insecure" = "true"} exposure.enabled = False repository = { org = "hops-ops" @@ -1251,17 +1252,23 @@ _items = [ enabled = True generate = False secretPath = "existing/github-webhook" - url = "https://argocd-webhook.example.com/api/webhook" + url = "https://argocd-webhook.example.com:8443/api/webhook" } } } } assertResources = [ + { + apiVersion = "helm.m.crossplane.io/v1beta1" + kind = "Release" + metadata.name = "argocd" + spec.forProvider.values.configs.params = {"server.insecure" = "true"} + } { apiVersion = "kubernetes.m.crossplane.io/v1alpha1" kind = "Object" metadata.name = "webhook-only-github-webhook-secret" - spec.forProvider.manifest.spec.target.template.data.url = "https://argocd-webhook.example.com/api/webhook" + spec.forProvider.manifest.spec.target.template.data.url = "https://argocd-webhook.example.com:8443/api/webhook" } ] }