mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-16 02:35:12 +00:00
feat(crypto): FIPS 140-3 compliant build and runtime checks (#12233)
# Which Problems Are Solved Enable FIPS 140-3 compliant build. # How the Problems Are Solved - Add runtime config validation, if the FIPS flag is enabled fail the application when a non-compliant hasher is used, or throw a warning when a legacy verifier is used - Add a build matrix for FIPS certified build: - Go binary is built with `GOFIPS140=certified` - Login container uses a separate base: [ubi9](https://catalog.redhat.com/en/software/containers/ubi9/ubi/615bcf606feffc5384e8452e) from redhat which provides a FIPS certified OpenSSL (used by NodeJS TLS stack) - Non-FIPS images where already pushed to both Github Container Registry and Google Artifact Repository (GAR). Fips images are only pushed to the GAR. - Tag versions are suffixed `-fips`. So on release the following images will be additionally available: ``` europe-docker.pkg.dev/zitadel-common/zitadel-repo/zitadel-login:vX.Y.Z-fips europe-docker.pkg.dev/zitadel-common/zitadel-repo/zitadel:vX.Y.Z-fips-debug europe-docker.pkg.dev/zitadel-common/zitadel-repo/zitadel:vX.Y.Z-fips ``` # Other changes - Bumb Go toolchain. At least v1.25.10 is required for a GOFIPS140=certified setting. # Additional Context - Closes https://github.com/zitadel/zitadel/issues/4335 - Build [test run](https://github.com/zitadel/zitadel/actions/runs/27253916052) pushing FIPS and non-FIPS images
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
"projectType": "application",
|
||||
"namedInputs": {
|
||||
"sources": [
|
||||
"{workspaceRoot}/cmd/defaults.yaml",
|
||||
"{workspaceRoot}/cmd/defaults_fips.yaml",
|
||||
"{workspaceRoot}/cmd/**/*.go",
|
||||
"{workspaceRoot}/internal/**/*.go",
|
||||
"{workspaceRoot}/proto/**/*.go",
|
||||
@@ -23,6 +25,9 @@
|
||||
{
|
||||
"env": "VERSION"
|
||||
},
|
||||
{
|
||||
"env": "ZITADEL_GOFIPS140"
|
||||
},
|
||||
"runtime"
|
||||
]
|
||||
},
|
||||
@@ -416,7 +421,7 @@
|
||||
"parallel": false,
|
||||
"commands": [
|
||||
"mkdir -p .artifacts/pack .artifacts/bin/$GOOS/$GOARCH",
|
||||
"bash -c 'EXT=\"\"; if [ \"$GOOS\" = \"windows\" ]; then EXT=\".exe\"; fi; echo \"Building for $GOOS-$GOARCH...\"; CGO_ENABLED=0 go build -o .artifacts/bin/$GOOS/$GOARCH/zitadel$EXT -ldflags=\"-s -w -X github.com/zitadel/zitadel/cmd/build.commit=$(git rev-parse --short HEAD) -X github.com/zitadel/zitadel/cmd/build.date=$(date \"+%Y-%m-%dT%T%z\" | sed -E \"s/.([0-9]{2})([0-9]{2})$/-\\1:\\2/\") -X github.com/zitadel/zitadel/cmd/build.version=${ZITADEL_VERSION}\"'",
|
||||
"bash -c 'EXT=\"\"; if [ \"$GOOS\" = \"windows\" ]; then EXT=\".exe\"; fi; echo \"Building for $GOOS-$GOARCH (GOFIPS140=${ZITADEL_GOFIPS140:-off})...\"; CGO_ENABLED=0 GOFIPS140=${ZITADEL_GOFIPS140:-off} go build -o .artifacts/bin/$GOOS/$GOARCH/zitadel$EXT -ldflags=\"-s -w -X github.com/zitadel/zitadel/cmd/build.commit=$(git rev-parse --short HEAD) -X github.com/zitadel/zitadel/cmd/build.date=$(date \"+%Y-%m-%dT%T%z\" | sed -E \"s/.([0-9]{2})([0-9]{2})$/-\\1:\\2/\") -X github.com/zitadel/zitadel/cmd/build.version=${ZITADEL_VERSION}\"'",
|
||||
"bash -c 'EXT=\"\"; if [ \"$GOOS\" = \"windows\" ]; then EXT=\".exe\"; fi; FOLDER=\"zitadel-$GOOS-$GOARCH\"; mkdir -p \".artifacts/pack/$FOLDER\"; cp README.md LICENSE \".artifacts/bin/$GOOS/$GOARCH/zitadel$EXT\" \".artifacts/pack/$FOLDER/\"; tar -czvf \".artifacts/pack/$FOLDER.tar.gz\" -C .artifacts/pack \"$FOLDER\"; rm -rf \".artifacts/pack/$FOLDER\"'"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
FROM registry.access.redhat.com/ubi9/nodejs-24
|
||||
USER root
|
||||
RUN update-crypto-policies --set FIPS
|
||||
WORKDIR /app
|
||||
# If /.env-file/.env is mounted into the container, its variables are made available to the server before it starts up.
|
||||
RUN mkdir -p /.env-file && touch /.env-file/.env && chown -R 1001:0 /.env-file
|
||||
|
||||
COPY --chown=1001:0 .next/standalone ./
|
||||
|
||||
USER 1001
|
||||
ENV HOSTNAME="::" \
|
||||
PORT="3000" \
|
||||
NODE_ENV="production" \
|
||||
NODE_OPTIONS="--use-openssl-ca --openssl-shared-config --enable-fips --require /app/load-ssl-cert-dir.cjs" \
|
||||
SSL_CERT_FILE="/etc/pki/tls/certs/ca-bundle.crt" \
|
||||
ZITADEL_TLS_ENABLED="false" \
|
||||
ZITADEL_FIPS_REQUIRED="true" \
|
||||
OTEL_SERVICE_NAME="zitadel-login" \
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD ["node", "/app/healthcheck.mjs", "/ui/v2/login/ready"]
|
||||
ENTRYPOINT ["/app/entrypoint.sh", "node", "apps/login/server.js"]
|
||||
@@ -42,6 +42,19 @@
|
||||
"!{projectRoot}/acceptance/**/*"
|
||||
]
|
||||
},
|
||||
"pack-fips": {
|
||||
"description": "Builds a local FIPS-hardened Docker image for the ZITADEL Login UI (zitadel/zitadel-login:local-fips). Requires Docker daemon.",
|
||||
"dependsOn": ["build"],
|
||||
"command": "docker build -f apps/login/Dockerfile.fips -t zitadel/zitadel-login:local-fips apps/login",
|
||||
"cache": false,
|
||||
"inputs": [
|
||||
"default",
|
||||
"{workspaceRoot}/pnpm-lock.yaml",
|
||||
"{projectRoot}/Dockerfile.fips",
|
||||
"!{projectRoot}/.env.*",
|
||||
"!{projectRoot}/acceptance/**/*"
|
||||
]
|
||||
},
|
||||
"build-vercel": {
|
||||
"description": "Builds the Next.js Login application for Vercel deployment",
|
||||
"cache": false,
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { getFips } from "node:crypto";
|
||||
import * as http from "node:http";
|
||||
import * as https from "node:https";
|
||||
|
||||
if (process.env.ZITADEL_FIPS_REQUIRED === "true" && getFips() !== 1) {
|
||||
console.error("Healthcheck failed: FIPS mode required but not enabled");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const scheme = process.env.ZITADEL_TLS_ENABLED === "true" ? "https" : "http";
|
||||
const port = process.env.PORT || "3000";
|
||||
const url = new URL(process.argv[2] || `/ui/v2/login/healthy`, `${scheme}://localhost:${port}`);
|
||||
|
||||
Reference in New Issue
Block a user