Skip to content

Commit 7323a45

Browse files
committed
Add signature verification to Git spec
1 parent 51f82e7 commit 7323a45

File tree

2 files changed

+78
-4
lines changed

2 files changed

+78
-4
lines changed

docs/spec/v1alpha1/common.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ const (
134134
// AuthenticationFailedReason represents the fact that a given secret does not
135135
// have the required fields or the provided credentials do not match.
136136
AuthenticationFailedReason string = "AuthenticationFailed"
137+
138+
// VerificationFailedReason represents the fact that the cryptographic provenance
139+
// verification for the source failed.
140+
VerificationFailedReason string = "VerificationFailed"
137141
)
138142
```
139143

docs/spec/v1alpha1/gitrepositories.md

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@ type GitRepositorySpec struct {
2222
// known_hosts fields.
2323
// +optional
2424
SecretRef *v1.LocalObjectReference `json:"secretRef,omitempty"`
25-
25+
26+
// The interval at which to check for repository updates.
27+
Interval metav1.Duration `json:"interval"`
28+
2629
// The git reference to checkout and monitor for changes, defaults to
2730
// master branch.
2831
// +optional
2932
Reference *GitRepositoryRef `json:"ref,omitempty"`
3033

31-
// The interval at which to check for repository updates.
32-
Interval metav1.Duration `json:"interval"`
34+
// Verify OpenPGP signature for the commit that HEAD points to.
35+
// +optional
36+
Verification *GitRepositoryVerification `json:"verify,omitempty"`
3337
}
3438
```
3539

@@ -57,6 +61,20 @@ type GitRepositoryRef struct {
5761
}
5862
```
5963

64+
Git repository cryptographic provenance verification:
65+
66+
```go
67+
// GitRepositoryVerification defines the OpenPGP signature verification process.
68+
type GitRepositoryVerification struct {
69+
// Mode describes what git object should be verified, currently ('head').
70+
// +kubebuilder:validation:Enum=head
71+
Mode string `json:"mode"`
72+
73+
// The secret name containing the public keys of all trusted git authors.
74+
SecretRef corev1.LocalObjectReference `json:"secretRef"`
75+
}
76+
```
77+
6078
### Status
6179

6280
```go
@@ -230,6 +248,46 @@ kubectl create secret generic ssh-credentials \
230248
--from-file=./known_hosts
231249
```
232250

251+
Verify the OpenPGP signature for the commit that master branch HEAD points to:
252+
253+
```yaml
254+
apiVersion: source.fluxcd.io/v1alpha1
255+
kind: GitRepository
256+
metadata:
257+
name: podinfo
258+
namespace: default
259+
spec:
260+
interval: 1m
261+
url: https://github.com/stefanprodan/podinfo
262+
ref:
263+
branch: master
264+
verify:
265+
mode: head
266+
secretRef:
267+
name: pgp-public-keys
268+
---
269+
apiVersion: v1
270+
kind: Secret
271+
metadata:
272+
name: pgp-public-keys
273+
namespace: default
274+
type: Opaque
275+
data:
276+
author1.asc: <BASE64>
277+
author2.asc: <BASE64>
278+
```
279+
280+
Example of generating the PGP public keys secret:
281+
282+
```bash
283+
gpg --export --armor 3CB12BA185C47B67 > author1.asc
284+
gpg --export --armor 6A7436E8790F8689 > author2.asc
285+
286+
kubectl create secret generic pgp-public-keys \
287+
--from-file=author1.asc \
288+
--from-file=author2.asc
289+
```
290+
233291
## Status examples
234292

235293
Successful sync:
@@ -251,7 +309,7 @@ status:
251309
url: http://<host>/gitrepository/podinfo-default/latest.tar.gz
252310
```
253311

254-
Failed sync:
312+
Failed authentication:
255313

256314
```yaml
257315
status:
@@ -264,6 +322,18 @@ status:
264322
type: Ready
265323
```
266324

325+
Failed PGP signature verification:
326+
327+
```yaml
328+
status:
329+
conditions:
330+
- lastTransitionTime: "2020-04-06T06:48:59Z"
331+
message: 'PGP signature of {Stefan Prodan 2020-04-04 13:36:58 +0300 +0300} can not be verified'
332+
reason: VerificationFailed
333+
status: "False"
334+
type: Ready
335+
```
336+
267337
Wait for condition:
268338

269339
```bash

0 commit comments

Comments
 (0)