blob: bb9e82d30820e9c4af5c603bd147e9bfec69e88e [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001/*
2Copyright 2016 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package v1beta1
18
19import (
20 "fmt"
21
22 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23)
24
25// +genclient
26// +genclient:nonNamespaced
27// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
28
29// Describes a certificate signing request
30type CertificateSigningRequest struct {
31 metav1.TypeMeta `json:",inline"`
32 // +optional
33 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
34
35 // The certificate request itself and any additional information.
36 // +optional
37 Spec CertificateSigningRequestSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
38
39 // Derived information about the request.
40 // +optional
41 Status CertificateSigningRequestStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
42}
43
44// This information is immutable after the request is created. Only the Request
45// and Usages fields can be set on creation, other fields are derived by
46// Kubernetes and cannot be modified by users.
47type CertificateSigningRequestSpec struct {
48 // Base64-encoded PKCS#10 CSR data
49 Request []byte `json:"request" protobuf:"bytes,1,opt,name=request"`
50
51 // allowedUsages specifies a set of usage contexts the key will be
52 // valid for.
53 // See: https://tools.ietf.org/html/rfc5280#section-4.2.1.3
54 // https://tools.ietf.org/html/rfc5280#section-4.2.1.12
55 Usages []KeyUsage `json:"usages,omitempty" protobuf:"bytes,5,opt,name=usages"`
56
57 // Information about the requesting user.
58 // See user.Info interface for details.
59 // +optional
60 Username string `json:"username,omitempty" protobuf:"bytes,2,opt,name=username"`
61 // UID information about the requesting user.
62 // See user.Info interface for details.
63 // +optional
64 UID string `json:"uid,omitempty" protobuf:"bytes,3,opt,name=uid"`
65 // Group information about the requesting user.
66 // See user.Info interface for details.
67 // +optional
68 Groups []string `json:"groups,omitempty" protobuf:"bytes,4,rep,name=groups"`
69 // Extra information about the requesting user.
70 // See user.Info interface for details.
71 // +optional
72 Extra map[string]ExtraValue `json:"extra,omitempty" protobuf:"bytes,6,rep,name=extra"`
73}
74
75// ExtraValue masks the value so protobuf can generate
76// +protobuf.nullable=true
77// +protobuf.options.(gogoproto.goproto_stringer)=false
78type ExtraValue []string
79
80func (t ExtraValue) String() string {
81 return fmt.Sprintf("%v", []string(t))
82}
83
84type CertificateSigningRequestStatus struct {
85 // Conditions applied to the request, such as approval or denial.
86 // +optional
87 Conditions []CertificateSigningRequestCondition `json:"conditions,omitempty" protobuf:"bytes,1,rep,name=conditions"`
88
89 // If request was approved, the controller will place the issued certificate here.
90 // +optional
91 Certificate []byte `json:"certificate,omitempty" protobuf:"bytes,2,opt,name=certificate"`
92}
93
94type RequestConditionType string
95
96// These are the possible conditions for a certificate request.
97const (
98 CertificateApproved RequestConditionType = "Approved"
99 CertificateDenied RequestConditionType = "Denied"
100)
101
102type CertificateSigningRequestCondition struct {
103 // request approval state, currently Approved or Denied.
104 Type RequestConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=RequestConditionType"`
105 // brief reason for the request state
106 // +optional
107 Reason string `json:"reason,omitempty" protobuf:"bytes,2,opt,name=reason"`
108 // human readable message with details about the request state
109 // +optional
110 Message string `json:"message,omitempty" protobuf:"bytes,3,opt,name=message"`
111 // timestamp for the last update to this condition
112 // +optional
113 LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty" protobuf:"bytes,4,opt,name=lastUpdateTime"`
114}
115
116// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
117
118type CertificateSigningRequestList struct {
119 metav1.TypeMeta `json:",inline"`
120 // +optional
121 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
122
123 Items []CertificateSigningRequest `json:"items" protobuf:"bytes,2,rep,name=items"`
124}
125
126// KeyUsages specifies valid usage contexts for keys.
127// See: https://tools.ietf.org/html/rfc5280#section-4.2.1.3
128// https://tools.ietf.org/html/rfc5280#section-4.2.1.12
129type KeyUsage string
130
131const (
132 UsageSigning KeyUsage = "signing"
133 UsageDigitalSignature KeyUsage = "digital signature"
134 UsageContentCommittment KeyUsage = "content commitment"
135 UsageKeyEncipherment KeyUsage = "key encipherment"
136 UsageKeyAgreement KeyUsage = "key agreement"
137 UsageDataEncipherment KeyUsage = "data encipherment"
138 UsageCertSign KeyUsage = "cert sign"
139 UsageCRLSign KeyUsage = "crl sign"
140 UsageEncipherOnly KeyUsage = "encipher only"
141 UsageDecipherOnly KeyUsage = "decipher only"
142 UsageAny KeyUsage = "any"
143 UsageServerAuth KeyUsage = "server auth"
144 UsageClientAuth KeyUsage = "client auth"
145 UsageCodeSigning KeyUsage = "code signing"
146 UsageEmailProtection KeyUsage = "email protection"
147 UsageSMIME KeyUsage = "s/mime"
148 UsageIPsecEndSystem KeyUsage = "ipsec end system"
149 UsageIPsecTunnel KeyUsage = "ipsec tunnel"
150 UsageIPsecUser KeyUsage = "ipsec user"
151 UsageTimestamping KeyUsage = "timestamping"
152 UsageOCSPSigning KeyUsage = "ocsp signing"
153 UsageMicrosoftSGC KeyUsage = "microsoft sgc"
154 UsageNetscapSGC KeyUsage = "netscape sgc"
155)