Repository navigation
feat(enrollment): record each enrollment as a CertificateSigningRequest #360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hexfusion
merged 4 commits into
praxis-proxy:main
from
hexfusion:docs/enrollment-architecture
Oct 12, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
32c7fdb
fix(certs): a request body is exactly one PEM block, and a request
hexfusion 93ef38e
feat(enrollment): record each enrollment as a CertificateSigningRequest
hexfusion 2ba9791
docs: enrollment architecture
hexfusion ec75418
Merge branch 'main' into docs/enrollment-architecture
hexfusion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
charts/grid-enrollment/templates/enrollment/csr-record-policy.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| {{- include "grid-enrollment.normalize" . }} | ||
| {{- if and (eq .Values.enrollment.authz "kube") .Values.enrollment.csrRecord.enabled }} | ||
| {{- if not .Values.enrollment.csrRecord.policy.enabled }} | ||
| {{- fail "enrollment.csrRecord needs enrollment.csrRecord.policy: without it the record roles grant cluster-wide create on CertificateSigningRequests. On a cluster without admissionregistration.k8s.io/v1 set enrollment.csrRecord.enabled=false" }} | ||
| {{- end }} | ||
| {{- $signer := .Values.enrollment.csrRecord.signerName }} | ||
| {{- $sa := printf "system:serviceaccount:%s:%s" .Release.Namespace (include "grid-enrollment.serviceAccountName" .) }} | ||
| {{- $name := printf "%s-%s-csr-record" (include "grid-enrollment.fullname" .) .Release.Namespace }} | ||
| {{/* | ||
| Two policies, cluster-scoped so their names carry the namespace. | ||
|
|
||
| The first lets only this release's service file a request under its signer | ||
| name. Without it any principal with create on CertificateSigningRequests could | ||
| put a request in the record under the grid's name. It stops ordinary CSR | ||
| creators and accidents; a principal that can act as the service account, by | ||
| impersonation, a minted token or exec into the pod, is the service. | ||
|
|
||
| The second confines the service account to its own signer name on every write | ||
| it can make, so a compromised service cannot file, approve or complete | ||
| requests under any other signer. spec is immutable, so on an update | ||
| object.spec is the stored value. | ||
| */}} | ||
| apiVersion: admissionregistration.k8s.io/v1 | ||
| kind: ValidatingAdmissionPolicy | ||
| metadata: | ||
| name: {{ $name }} | ||
| labels: | ||
| {{- include "grid-enrollment.labels" . | nindent 4 }} | ||
| spec: | ||
| failurePolicy: Fail | ||
| matchConstraints: | ||
| resourceRules: | ||
| - apiGroups: ["certificates.k8s.io"] | ||
| apiVersions: ["v1"] | ||
| operations: ["CREATE"] | ||
| resources: ["certificatesigningrequests"] | ||
| matchConditions: | ||
| - name: grid-signer | ||
| expression: {{ printf "object.spec.signerName == %q" $signer | quote }} | ||
| validations: | ||
| - expression: {{ printf "request.userInfo.username == %q" $sa | quote }} | ||
| message: "only the grid enrollment service may file a request under a grid signer name" | ||
| reason: Forbidden | ||
| --- | ||
| apiVersion: admissionregistration.k8s.io/v1 | ||
| kind: ValidatingAdmissionPolicyBinding | ||
| metadata: | ||
| name: {{ $name }} | ||
| labels: | ||
| {{- include "grid-enrollment.labels" . | nindent 4 }} | ||
| spec: | ||
| policyName: {{ $name }} | ||
| validationActions: [Deny] | ||
| --- | ||
| apiVersion: admissionregistration.k8s.io/v1 | ||
| kind: ValidatingAdmissionPolicy | ||
| metadata: | ||
| name: {{ $name }}-confine | ||
| labels: | ||
| {{- include "grid-enrollment.labels" . | nindent 4 }} | ||
| spec: | ||
| failurePolicy: Fail | ||
| matchConstraints: | ||
| resourceRules: | ||
| - apiGroups: ["certificates.k8s.io"] | ||
| apiVersions: ["v1"] | ||
| operations: ["CREATE", "UPDATE"] | ||
| resources: ["certificatesigningrequests", "certificatesigningrequests/approval", "certificatesigningrequests/status"] | ||
| matchConditions: | ||
| - name: grid-enrollment-service | ||
| expression: {{ printf "request.userInfo.username == %q" $sa | quote }} | ||
| validations: | ||
| - expression: {{ printf "object.spec.signerName == %q" $signer | quote }} | ||
| message: "the grid enrollment service may only touch requests under its own signer name" | ||
| reason: Forbidden | ||
| --- | ||
| apiVersion: admissionregistration.k8s.io/v1 | ||
| kind: ValidatingAdmissionPolicyBinding | ||
| metadata: | ||
| name: {{ $name }}-confine | ||
| labels: | ||
| {{- include "grid-enrollment.labels" . | nindent 4 }} | ||
| spec: | ||
| policyName: {{ $name }}-confine | ||
| validationActions: [Deny] | ||
| {{- end }} |
75 changes: 75 additions & 0 deletions
75
charts/grid-enrollment/templates/enrollment/csr-record-rbac.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| {{- include "grid-enrollment.normalize" . }} | ||
| {{- if and (eq .Values.enrollment.authz "kube") .Values.enrollment.csrRecord.enabled }} | ||
| {{- $signer := .Values.enrollment.csrRecord.signerName }} | ||
| {{/* | ||
| The service records each enrollment as a CertificateSigningRequest. Two roles: | ||
| filing needs create plus the status subresource and the sign verb on the | ||
| signer; approving needs the approval subresource and the approve verb. They are | ||
| separate so a later release can move approval to people without rewriting the | ||
| filing role. Cluster-scoped, so the names carry the namespace. The installing | ||
| principal must itself hold approve and sign on the signer, or RBAC escalation | ||
| prevention refuses these roles. | ||
| */}} | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: {{ include "grid-enrollment.fullname" . }}-{{ .Release.Namespace }}-csr-file | ||
| labels: | ||
| {{- include "grid-enrollment.labels" . | nindent 4 }} | ||
| rules: | ||
| - apiGroups: ["certificates.k8s.io"] | ||
| resources: ["certificatesigningrequests"] | ||
| verbs: ["create"] | ||
| - apiGroups: ["certificates.k8s.io"] | ||
| resources: ["certificatesigningrequests/status"] | ||
| verbs: ["patch"] | ||
| - apiGroups: ["certificates.k8s.io"] | ||
| resources: ["signers"] | ||
| resourceNames: [{{ $signer | quote }}] | ||
| verbs: ["sign"] | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: {{ include "grid-enrollment.fullname" . }}-{{ .Release.Namespace }}-csr-approve | ||
| labels: | ||
| {{- include "grid-enrollment.labels" . | nindent 4 }} | ||
| rules: | ||
| - apiGroups: ["certificates.k8s.io"] | ||
| resources: ["certificatesigningrequests/approval"] | ||
| verbs: ["patch"] | ||
| - apiGroups: ["certificates.k8s.io"] | ||
| resources: ["signers"] | ||
| resourceNames: [{{ $signer | quote }}] | ||
| verbs: ["approve"] | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: {{ include "grid-enrollment.fullname" . }}-{{ .Release.Namespace }}-csr-file | ||
| labels: | ||
| {{- include "grid-enrollment.labels" . | nindent 4 }} | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: {{ include "grid-enrollment.fullname" . }}-{{ .Release.Namespace }}-csr-file | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: {{ include "grid-enrollment.serviceAccountName" . }} | ||
| namespace: {{ .Release.Namespace }} | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: {{ include "grid-enrollment.fullname" . }}-{{ .Release.Namespace }}-csr-approve | ||
| labels: | ||
| {{- include "grid-enrollment.labels" . | nindent 4 }} | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: {{ include "grid-enrollment.fullname" . }}-{{ .Release.Namespace }}-csr-approve | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: {{ include "grid-enrollment.serviceAccountName" . }} | ||
| namespace: {{ .Release.Namespace }} | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| suite: enrollment record as CertificateSigningRequest | ||
| templates: | ||
| - templates/enrollment/csr-record-rbac.yaml | ||
| - templates/enrollment/csr-record-policy.yaml | ||
| - templates/enrollment/deployment.yaml | ||
| tests: | ||
| - it: splits filing from approving, each scoped to the signer name | ||
| template: templates/enrollment/csr-record-rbac.yaml | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 4 | ||
| - documentIndex: 0 | ||
| equal: | ||
| path: metadata.name | ||
| value: RELEASE-NAME-grid-enrollment-NAMESPACE-csr-file | ||
| - documentIndex: 0 | ||
| equal: | ||
| path: rules | ||
| value: | ||
| - apiGroups: ["certificates.k8s.io"] | ||
| resources: ["certificatesigningrequests"] | ||
| verbs: ["create"] | ||
| - apiGroups: ["certificates.k8s.io"] | ||
| resources: ["certificatesigningrequests/status"] | ||
| verbs: ["patch"] | ||
| - apiGroups: ["certificates.k8s.io"] | ||
| resources: ["signers"] | ||
| resourceNames: ["grid.praxis.fast/site"] | ||
| verbs: ["sign"] | ||
| - documentIndex: 1 | ||
| equal: | ||
| path: metadata.name | ||
| value: RELEASE-NAME-grid-enrollment-NAMESPACE-csr-approve | ||
| - documentIndex: 1 | ||
| equal: | ||
| path: rules | ||
| value: | ||
| - apiGroups: ["certificates.k8s.io"] | ||
| resources: ["certificatesigningrequests/approval"] | ||
| verbs: ["patch"] | ||
| - apiGroups: ["certificates.k8s.io"] | ||
| resources: ["signers"] | ||
| resourceNames: ["grid.praxis.fast/site"] | ||
| verbs: ["approve"] | ||
|
|
||
| - it: binds both roles to the service account | ||
| template: templates/enrollment/csr-record-rbac.yaml | ||
| documentSelector: | ||
| path: kind | ||
| value: ClusterRoleBinding | ||
| matchMany: true | ||
| asserts: | ||
| - equal: | ||
| path: subjects[0].name | ||
| value: RELEASE-NAME-grid-enrollment | ||
| - equal: | ||
| path: subjects[0].namespace | ||
| value: NAMESPACE | ||
|
|
||
| - it: scopes the signer verbs to a configured signer name | ||
| set: | ||
| enrollment.csrRecord.signerName: example.com/west | ||
| template: templates/enrollment/csr-record-rbac.yaml | ||
| documentSelector: | ||
| path: kind | ||
| value: ClusterRole | ||
| matchMany: true | ||
| asserts: | ||
| - equal: | ||
| path: rules[-1].resourceNames | ||
| value: ["example.com/west"] | ||
|
|
||
| - it: lets only the service file under the signer name, and confines the service to it | ||
| template: templates/enrollment/csr-record-policy.yaml | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 4 | ||
| - documentIndex: 0 | ||
| equal: | ||
| path: spec.matchConditions[0].expression | ||
| value: "object.spec.signerName == \"grid.praxis.fast/site\"" | ||
| - documentIndex: 0 | ||
| equal: | ||
| path: spec.validations[0].expression | ||
| value: "request.userInfo.username == \"system:serviceaccount:NAMESPACE:RELEASE-NAME-grid-enrollment\"" | ||
| - documentIndex: 0 | ||
| equal: | ||
| path: spec.failurePolicy | ||
| value: Fail | ||
| - documentIndex: 2 | ||
| equal: | ||
| path: spec.matchConditions[0].expression | ||
| value: "request.userInfo.username == \"system:serviceaccount:NAMESPACE:RELEASE-NAME-grid-enrollment\"" | ||
| - documentIndex: 2 | ||
| equal: | ||
| path: spec.validations[0].expression | ||
| value: "object.spec.signerName == \"grid.praxis.fast/site\"" | ||
| - documentIndex: 2 | ||
| equal: | ||
| path: spec.matchConstraints.resourceRules[0].operations | ||
| value: ["CREATE", "UPDATE"] | ||
|
|
||
| - it: turns the record on in the service with its signer name | ||
| template: templates/enrollment/deployment.yaml | ||
| asserts: | ||
| - equal: | ||
| path: spec.template.spec.containers[0].env[?(@.name=="ENROLLMENT_CSR_RECORD")].value | ||
| value: "true" | ||
| - equal: | ||
| path: spec.template.spec.containers[0].env[?(@.name=="ENROLLMENT_CSR_SIGNER_NAME")].value | ||
| value: grid.praxis.fast/site | ||
|
|
||
| - it: renders nothing under local authz | ||
| set: | ||
| enrollment.authz: local | ||
| template: templates/enrollment/csr-record-rbac.yaml | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 0 | ||
|
|
||
| - it: renders nothing when the record is off | ||
| set: | ||
| enrollment.csrRecord.enabled: false | ||
| template: templates/enrollment/csr-record-rbac.yaml | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 0 | ||
|
|
||
| - it: refuses the record without the policy | ||
| set: | ||
| enrollment.csrRecord.policy.enabled: false | ||
| template: templates/enrollment/csr-record-policy.yaml | ||
| asserts: | ||
| - failedTemplate: | ||
| errorPattern: needs enrollment.csrRecord.policy |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.