From 9ca7ac46c20b6be15ef7a6167e23600ae9b28d9c Mon Sep 17 00:00:00 2001 From: Rami Mohamed Date: Sat, 12 Sep 2026 17:34:45 +0400 Subject: [PATCH] fix: fail closed when gateway security is unspecified --- README.md | 6 +++--- helm/values.yaml | 2 +- .../security/GatewaySecurityDisabledConfiguration.java | 2 +- src/main/resources/application.yml | 3 ++- src/test/resources/application.properties | 2 ++ 5 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 src/test/resources/application.properties diff --git a/README.md b/README.md index d9729b2..30a8bcd 100644 --- a/README.md +++ b/README.md @@ -122,16 +122,16 @@ The gateway emits one ECS-formatted JSON completion event per exchange. It conta ## Gateway Authorization And Environment Promotion -The gateway is an internal Kubernetes `ClusterIP` Service in SIT. When `gateway.security.enabled` is true, it validates JWTs and enforces these scopes: +The gateway is an internal Kubernetes `ClusterIP` Service in SIT. Authentication is enabled by default and validates JWTs before enforcing these scopes. A local test must explicitly set `GATEWAY_SECURITY_ENABLED=false` to use the bypass configuration; do not use that bypass in a deployed environment. - `admin.internal` for `/admin/**` and centralized API documentation. - `mfa.internal` for `/api/v1/mfa/**`. -- `transaction.internal` for `/internal/v1/transfer-workflows/**`. +- `transfer.internal` for `/internal/v1/transfer-workflows/**`. - `payment.internal` for `/internal/v1/payment-instructions/**`. Customer and account APIs require an authenticated token. Health endpoints and Auth login remain public. Requests that do not authenticate receive `401` Problem Details; authenticated requests without the required scope receive `403` Problem Details. -SIT uses a base64-encoded HMAC secret supplied through the Kubernetes `auth-service-secrets` Secret. UAT and PROD should use the same application contract with an AWS-managed secret or an OIDC/JWK issuer; no token secret belongs in Git. The chart keeps security disabled by default outside an explicitly enabled environment. +SIT uses a base64-encoded HMAC secret supplied through the Kubernetes `auth-service-secrets` Secret. UAT and PROD should use the same application contract with an AWS-managed secret or an OIDC/JWK issuer; no token secret belongs in Git. The chart fails closed by default when an environment does not provide an explicit security override. Circuit breaking and safe-read retries are independent availability controls. They do not replace service authorization, idempotency keys, transactional guarantees, or audit controls. diff --git a/helm/values.yaml b/helm/values.yaml index 5ede1b2..febeda7 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -13,7 +13,7 @@ runtime: configServerUrl: http://config-server:8888 security: - enabled: false + enabled: true secretName: auth-service-secrets secretKey: jwt-secret diff --git a/src/main/java/com/digitalbank/apigateway/security/GatewaySecurityDisabledConfiguration.java b/src/main/java/com/digitalbank/apigateway/security/GatewaySecurityDisabledConfiguration.java index e3fe399..cfdba92 100644 --- a/src/main/java/com/digitalbank/apigateway/security/GatewaySecurityDisabledConfiguration.java +++ b/src/main/java/com/digitalbank/apigateway/security/GatewaySecurityDisabledConfiguration.java @@ -7,7 +7,7 @@ import org.springframework.security.web.server.SecurityWebFilterChain; @Configuration(proxyBeanMethods = false) -@ConditionalOnProperty(name = "gateway.security.enabled", havingValue = "false", matchIfMissing = true) +@ConditionalOnProperty(name = "gateway.security.enabled", havingValue = "false") class GatewaySecurityDisabledConfiguration { @Bean diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 4a2367c..3f36cb3 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -26,7 +26,8 @@ spring: gateway: security: - enabled: ${GATEWAY_SECURITY_ENABLED:false} + # Authentication is fail-closed. Tests that need the bypass must opt in. + enabled: ${GATEWAY_SECURITY_ENABLED:true} rate-limit: trusted-proxies: [] resilience: diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties new file mode 100644 index 0000000..864fc05 --- /dev/null +++ b/src/test/resources/application.properties @@ -0,0 +1,2 @@ +# Test contexts must opt into the unauthenticated harness explicitly. +gateway.security.enabled=false