Wires the signing-service's production path for ProofedMesh Phase 1: the service now performs a double identity check (Pocket-ID OIDC JWT + K8s ServiceAccount TokenReview), reconciles both against the trust-api `agents` registry, and asks an OPA/Rego policy whether the caller may sign with the requested key_ref. Code - internal/token/pocket_id.go: OIDC-Discovery-backed JWKS validator with automatic kid rotation (coreos/go-oidc). - internal/token/k8s_tokenreview.go: hand-rolled TokenReview client; reads X-Workload-Token, posts to authentication.k8s.io/v1 via the pod's in-cluster SA token + CA. - internal/registry: Postgres resolver for the agents table + in-memory Static resolver for tests. - internal/policy/opa.go: OPA/rego StructuredDecider; input carries both lookups so the policy can enforce identity consistency AND the key_ref ↔ role mapping. - internal/httpapi/sign.go: new structured flow when Validator+TokenReviewer+Registry+StructuredPolicy are all wired; dev path (static bearers + AllowAll) remains intact. - cmd/signing-service/main.go: -pocket-id-issuer, -pocket-id-audience, -k8s-tokenreview, -registry-dsn, -policy-bundle flags. Policy - policies/sinks/signing_service.rego: identities_agree + key_ref_matches_role rules; agent → key_ref prefix map covers approval-service, testagent-transform, dummy-sink. Deploy - deploy/signing-service/01-rbac.yaml: ClusterRole with tokenreviews.create + binding to the signing-service SA. - deploy/signing-service/20-deployment.yaml: adds POCKET_ID_ISSUER, POCKET_ID_AUDIENCE, TRUST_PG_DSN env, projected SA token volume, OPA policy ConfigMap mount, structured flags. - deploy/signing-service/00-serviceaccount.yaml: disables default auto-mount; a projected volume is used. - deploy/signing-service/README.md: documents prod flags + ConfigMap generation. Tests - httptest-mock Pocket-ID (OIDC discovery + JWKS, kid rotation), StaticTokenReviewer fake, Static registry, real Rego policy. - Happy paths: Approval-Service → trust-api/approval-signer-2026-q4; testagent-transform → trust-api/agent-testagent-transform-2026-q4. - Denies: registry mismatch, wrong key_ref for role, missing / bad workload token, bad Pocket-ID token, kid rotation. Co-Authored-By: Paperclip <noreply@paperclip.ing>
163 lines
5.8 KiB
YAML
163 lines
5.8 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: signing-service
|
|
namespace: agent-trust
|
|
labels:
|
|
app.kubernetes.io/name: signing-service
|
|
app.kubernetes.io/part-of: proofedmesh
|
|
app.kubernetes.io/component: trust-core
|
|
spec:
|
|
replicas: 2
|
|
revisionHistoryLimit: 5
|
|
strategy:
|
|
type: RollingUpdate
|
|
rollingUpdate:
|
|
maxSurge: 1
|
|
maxUnavailable: 0
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: signing-service
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: signing-service
|
|
app.kubernetes.io/part-of: proofedmesh
|
|
app.kubernetes.io/component: trust-core
|
|
spec:
|
|
serviceAccountName: signing-service
|
|
# The signing-service MUST NOT get the default auto-mounted token
|
|
# because we need a projected token with an explicit `trust-api`
|
|
# audience so the pod SA token can be used to call the API server
|
|
# for TokenReview (the audience on the pod's own SA token is what
|
|
# the K8s API server will accept as Bearer credential).
|
|
automountServiceAccountToken: false
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
runAsUser: 65532
|
|
runAsGroup: 65532
|
|
fsGroup: 65532
|
|
seccompProfile:
|
|
type: RuntimeDefault
|
|
containers:
|
|
- name: signing-service
|
|
image: harbor.basicstack.de/basicstack/signing-service:dev
|
|
imagePullPolicy: IfNotPresent
|
|
args:
|
|
- "-listen=:8081"
|
|
- "-backend=memory"
|
|
- "-keys=trust-api/approval-signer-2026-q4,trust-api/agent-testagent-transform-2026-q4"
|
|
- "-keys-from-env"
|
|
- "-pocket-id-issuer=$(POCKET_ID_ISSUER)"
|
|
- "-pocket-id-audience=$(POCKET_ID_AUDIENCE)"
|
|
- "-k8s-tokenreview=on"
|
|
- "-registry-dsn=$(TRUST_PG_DSN)"
|
|
- "-policy-bundle=/etc/signing-service/policies/signing_service.rego"
|
|
env:
|
|
# ---- Pocket-ID OIDC discovery (DEV-609) ----
|
|
- name: POCKET_ID_ISSUER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: signing-service-prod
|
|
key: POCKET_ID_ISSUER
|
|
- name: POCKET_ID_AUDIENCE
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: signing-service-prod
|
|
key: POCKET_ID_AUDIENCE
|
|
# ---- trust-api agent registry DSN (DEV-609) ----
|
|
- name: TRUST_PG_DSN
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: signing-service-prod
|
|
key: TRUST_PG_DSN
|
|
# ---- Signing keys (same shape as dev; swapped to prod Secret) ----
|
|
- name: KEY_TRUST_API_APPROVAL_SIGNER_2026_Q4
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: signing-service-prod
|
|
key: KEY_TRUST_API_APPROVAL_SIGNER_2026_Q4
|
|
- name: KEY_TRUST_API_AGENT_TESTAGENT_TRANSFORM_2026_Q4
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: signing-service-prod
|
|
key: KEY_TRUST_API_AGENT_TESTAGENT_TRANSFORM_2026_Q4
|
|
ports:
|
|
- name: http
|
|
containerPort: 8081
|
|
protocol: TCP
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /healthz
|
|
port: http
|
|
initialDelaySeconds: 2
|
|
periodSeconds: 10
|
|
failureThreshold: 3
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /healthz
|
|
port: http
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 20
|
|
failureThreshold: 3
|
|
resources:
|
|
requests:
|
|
cpu: "100m"
|
|
memory: "128Mi"
|
|
limits:
|
|
cpu: "1000m"
|
|
memory: "512Mi"
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
readOnlyRootFilesystem: true
|
|
capabilities:
|
|
drop:
|
|
- ALL
|
|
volumeMounts:
|
|
- name: kube-api-token
|
|
mountPath: /var/run/secrets/kubernetes.io/serviceaccount
|
|
readOnly: true
|
|
- name: opa-policy
|
|
mountPath: /etc/signing-service/policies
|
|
readOnly: true
|
|
volumes:
|
|
# Projected SA token the signing-service presents to the
|
|
# Kubernetes API server to authorize TokenReview calls. The
|
|
# projected volume also carries the API server CA, which the
|
|
# in-cluster TokenReviewer loads from
|
|
# /var/run/secrets/kubernetes.io/serviceaccount/ca.crt.
|
|
- name: kube-api-token
|
|
projected:
|
|
sources:
|
|
- serviceAccountToken:
|
|
path: token
|
|
# The API server audience — pod-SA tokens addressed to
|
|
# the api server are what RBAC checks against.
|
|
audience: "https://kubernetes.default.svc"
|
|
expirationSeconds: 3600
|
|
- configMap:
|
|
name: kube-root-ca.crt
|
|
items:
|
|
- key: ca.crt
|
|
path: ca.crt
|
|
- downwardAPI:
|
|
items:
|
|
- path: namespace
|
|
fieldRef:
|
|
fieldPath: metadata.namespace
|
|
# OPA Rego policy source, mounted read-only. The ConfigMap is
|
|
# created from policies/sinks/signing_service.rego by GitOps
|
|
# (see deploy/signing-service/README.md).
|
|
- name: opa-policy
|
|
configMap:
|
|
name: signing-service-policy
|
|
items:
|
|
- key: signing_service.rego
|
|
path: signing_service.rego
|
|
topologySpreadConstraints:
|
|
- maxSkew: 1
|
|
topologyKey: kubernetes.io/hostname
|
|
whenUnsatisfiable: ScheduleAnyway
|
|
labelSelector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: signing-service
|