Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,36 @@ services:
ports:
- "${IDENTITY_PORT:-8082}:8082"

# ── Fake IdP (dev/e2e ONLY — never shipped to production) ──────────────
#
# A tiny in-repo OIDC provider so the authenticator's real login / refresh /
# logout code path runs locally and in CI with no external IdP. It signs with
# a keypair checked into the repo and exposes /_control/* test hooks. Builds
# entirely from its own Dockerfile (no host-built-binary bind mount), so it is
# self-contained. See src/backend/services/fakeidp/README.md and
# cf/NGINX_BFF.md §10 G6. On the default profile — comes up with the stack.
fakeidp:
<<: *backend-common
image: ${FAKEIDP_IMAGE:-insight-fakeidp:dev}
container_name: insight-fakeidp
build:
context: src/backend
dockerfile: services/fakeidp/Dockerfile
environment:
# Issuer defaults to the host-visible URL so the README curl flow works
# from your laptop. When the authenticator (step 04) consumes this from
# inside the compose network, override to http://fakeidp:8084 so the
# discovery issuer matches the URL used to fetch it.
FAKEIDP_ISSUER: "${FAKEIDP_ISSUER:-http://localhost:8084}"
FAKEIDP_BIND: "0.0.0.0:8084"
FAKEIDP_TOKEN_TTL: "${FAKEIDP_TOKEN_TTL:-300}"
# Set once the authenticator exists to enable POST /_control/backchannel/{email},
# e.g. http://authenticator:8083/auth/oidc/back-channel-logout
FAKEIDP_BACKCHANNEL_URL: "${FAKEIDP_BACKCHANNEL_URL:-}"
RUST_LOG: ${RUST_LOG:-info}
ports:
- "${FAKEIDP_PORT:-8084}:8084"

# ── Frontend (one variant active per FRONTEND_MODE) ────────────────────
#
# The dev-compose.sh up script translates FRONTEND_MODE=dev|built|ghcr
Expand Down
8 changes: 8 additions & 0 deletions scripts/ci/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
# zero-hit dependency files would gate THOSE components at 0%.
"cover_ignore_regex": "src/backend/(libs|plugins)/",
"paths": ["src/backend/services/api-gateway"]},
# cover=False: fakeidp is a dev/e2e test double (see cf/NGINX_BFF.md §10 G6),
# not shipped code — its integration test still runs via plain `cargo test`
# (a failure fails the job), but coverage is neither collected nor gated.
# fmt + clippy still run. Mirrors the api-gateway decision above.
{"name": "fakeidp", "lang": "rust", "root": "src/backend",
"package": "fakeidp",
"cover": False,
"paths": ["src/backend/services/fakeidp"]},
# jira-enrich is a standalone workspace; its `io` feature needs a live
# ClickHouse, so cover with default features only (core tests are io-free).
# clippy: False — jira-enrich's strict [lints.clippy] (pedantic/unwrap_used/…)
Expand Down
39 changes: 38 additions & 1 deletion src/backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ members = [
"plugins/oidc-authn-plugin",
"services/api-gateway",
"services/analytics",
# Dev/e2e-only fake OIDC provider (never shipped in a prod image). See
# services/fakeidp/README.md and cf/NGINX_BFF.md §10 G6.
"services/fakeidp",
]
resolver = "3"

Expand Down
6 changes: 5 additions & 1 deletion src/backend/services/analytics/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ COPY libs/insight-clickhouse/Cargo.toml ./libs/insight-clickhouse/Cargo.toml
COPY plugins/oidc-authn-plugin/Cargo.toml ./plugins/oidc-authn-plugin/Cargo.toml
COPY services/api-gateway/Cargo.toml ./services/api-gateway/Cargo.toml
COPY services/analytics/Cargo.toml ./services/analytics/Cargo.toml
# fakeidp is a dev/e2e workspace member; cargo must load its manifest to
# resolve the workspace even though this image never builds or ships it.
COPY services/fakeidp/Cargo.toml ./services/fakeidp/Cargo.toml

RUN mkdir -p libs/insight-clickhouse/src && echo "" > libs/insight-clickhouse/src/lib.rs && \
mkdir -p plugins/oidc-authn-plugin/src && echo "" > plugins/oidc-authn-plugin/src/lib.rs && \
mkdir -p services/api-gateway/src && echo "fn main() {}" > services/api-gateway/src/main.rs && \
mkdir -p services/analytics/src && echo "fn main() {}" > services/analytics/src/main.rs
mkdir -p services/analytics/src && echo "fn main() {}" > services/analytics/src/main.rs && \
mkdir -p services/fakeidp/src && echo "fn main() {}" > services/fakeidp/src/main.rs

RUN cargo build --release --bin analytics 2>/dev/null || true

Expand Down
6 changes: 5 additions & 1 deletion src/backend/services/api-gateway/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ COPY libs/insight-clickhouse/Cargo.toml ./libs/insight-clickhouse/Cargo.toml
COPY plugins/oidc-authn-plugin/Cargo.toml ./plugins/oidc-authn-plugin/Cargo.toml
COPY services/api-gateway/Cargo.toml ./services/api-gateway/Cargo.toml
COPY services/analytics/Cargo.toml ./services/analytics/Cargo.toml
# fakeidp is a dev/e2e workspace member; cargo must load its manifest to
# resolve the workspace even though this image never builds or ships it.
COPY services/fakeidp/Cargo.toml ./services/fakeidp/Cargo.toml

RUN mkdir -p libs/insight-clickhouse/src && echo "" > libs/insight-clickhouse/src/lib.rs && \
mkdir -p plugins/oidc-authn-plugin/src && echo "" > plugins/oidc-authn-plugin/src/lib.rs && \
mkdir -p services/api-gateway/src && echo "fn main() {}" > services/api-gateway/src/main.rs && \
mkdir -p services/analytics/src && echo "fn main() {}" > services/analytics/src/main.rs
mkdir -p services/analytics/src && echo "fn main() {}" > services/analytics/src/main.rs && \
mkdir -p services/fakeidp/src && echo "fn main() {}" > services/fakeidp/src/main.rs

# Cache dependencies
RUN cargo build --release --bin insight-api-gateway 2>/dev/null || true
Expand Down
48 changes: 48 additions & 0 deletions src/backend/services/fakeidp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# fakeidp — a deliberately silly fake OIDC provider for dev/e2e.
#
# NOT a toolkit gear, NOT production code, NEVER shipped in a production
# image or referenced by a production chart. It exists so the authenticator's
# *real* OIDC code path (code + PKCE, refresh-token rotation, back-channel
# logout, IdP-refusal handling) can be exercised end-to-end locally and in CI.
#
# See cf/NGINX_BFF.md §10 G6 for the decision and the control-hook rationale.
#
# Workspace lints are intentionally NOT inherited (`[lints] workspace = true`
# is absent): this is a throwaway test double, so the pedantic/`unwrap_used`
# denials the real services carry would be noise here.
[package]
name = "fakeidp"
version = "0.1.0"
edition.workspace = true
license.workspace = true
authors.workspace = true
repository.workspace = true
rust-version.workspace = true
publish = false

[[bin]]
name = "fakeidp"
path = "src/main.rs"

[dependencies]
axum.workspace = true
tokio.workspace = true
serde.workspace = true
serde_json.workspace = true
uuid.workspace = true
reqwest.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true

# Test-double-only deps (kept out of the shared [workspace.dependencies]
# table on purpose — nothing in production links these).
jsonwebtoken = "9"
rsa = { version = "0.9", features = ["pem"] }
sha2 = "0.10"
base64 = "0.22"
serde_yaml = "0.9"
rand = "0.8"

[dev-dependencies]
reqwest = { workspace = true, features = ["json"] }
tokio = { workspace = true }
71 changes: 71 additions & 0 deletions src/backend/services/fakeidp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Multi-stage build for the fake IdP (dev/e2e ONLY).
#
# This image must NEVER be published to a production registry or referenced by
# a production chart — fakeidp signs tokens with a keypair checked into the
# repo and exposes `/_control/*` test hooks. It exists so `docker compose up`
# and CI can drive the authenticator's real OIDC code path. See
# services/fakeidp/README.md and cf/NGINX_BFF.md §10 G6.
#
# Build context: src/backend/
# Usage: cd src/backend && docker build -f services/fakeidp/Dockerfile -t insight-fakeidp:dev .

# Stage 1: Builder
FROM rust:1.95-bookworm AS builder

WORKDIR /build

# --- Dependency caching layer ---
# fakeidp lives in the src/backend workspace, so cargo must be able to load
# every member's manifest. We copy just the manifests + stub sources so the
# dependency graph resolves and fakeidp's deps get cached without dragging in
# the other services' real code.
COPY Cargo.toml Cargo.lock ./
COPY libs/insight-clickhouse/Cargo.toml ./libs/insight-clickhouse/Cargo.toml
COPY plugins/oidc-authn-plugin/Cargo.toml ./plugins/oidc-authn-plugin/Cargo.toml
COPY services/api-gateway/Cargo.toml ./services/api-gateway/Cargo.toml
COPY services/analytics/Cargo.toml ./services/analytics/Cargo.toml
COPY services/fakeidp/Cargo.toml ./services/fakeidp/Cargo.toml

RUN mkdir -p libs/insight-clickhouse/src && echo "" > libs/insight-clickhouse/src/lib.rs && \
mkdir -p plugins/oidc-authn-plugin/src && echo "" > plugins/oidc-authn-plugin/src/lib.rs && \
mkdir -p services/api-gateway/src && echo "fn main() {}" > services/api-gateway/src/main.rs && \
mkdir -p services/analytics/src && echo "fn main() {}" > services/analytics/src/main.rs && \
mkdir -p services/fakeidp/src && echo "fn main() {}" > services/fakeidp/src/main.rs && \
echo "" > services/fakeidp/src/lib.rs

RUN cargo build --release --bin fakeidp 2>/dev/null || true

# --- Source layer ---
RUN rm -rf services/fakeidp/src \
target/release/fakeidp target/release/deps/fakeidp* target/release/deps/libfakeidp*

# The signing keypair and users.yaml are baked into the binary via include_str!,
# so the source tree must carry them at compile time.
COPY services/fakeidp/src/ ./services/fakeidp/src/
COPY services/fakeidp/keys/ ./services/fakeidp/keys/
COPY services/fakeidp/users.yaml ./services/fakeidp/users.yaml

RUN cargo build --release --bin fakeidp

# Stage 2: Runtime
FROM debian:bookworm-slim

# ca-certificates so the back-channel control hook can POST over TLS if the RP
# endpoint is https.
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates && \
rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY --from=builder /build/target/release/fakeidp /app/fakeidp
# Also drop users.yaml alongside the binary for reference / optional override
# via FAKEIDP_USERS (the binary bakes a copy, so this is not required to run).
COPY --from=builder /build/services/fakeidp/users.yaml /app/users.yaml

RUN useradd -U -u 1000 -m appuser && chown -R 1000:1000 /app
USER 1000

EXPOSE 8084

ENTRYPOINT ["/app/fakeidp"]
Loading
Loading