sslobodr | d046be8 | 2019-01-16 10:02:22 -0500 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2018 The Kubernetes Authors. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package clientauthentication |
| 18 | |
| 19 | import ( |
| 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 | ) |
| 22 | |
| 23 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 24 | |
| 25 | // ExecCredentials is used by exec-based plugins to communicate credentials to |
| 26 | // HTTP transports. |
| 27 | type ExecCredential struct { |
| 28 | metav1.TypeMeta |
| 29 | |
| 30 | // Spec holds information passed to the plugin by the transport. This contains |
| 31 | // request and runtime specific information, such as if the session is interactive. |
| 32 | Spec ExecCredentialSpec |
| 33 | |
| 34 | // Status is filled in by the plugin and holds the credentials that the transport |
| 35 | // should use to contact the API. |
| 36 | // +optional |
| 37 | Status *ExecCredentialStatus |
| 38 | } |
| 39 | |
| 40 | // ExecCredenitalSpec holds request and runtime specific information provided by |
| 41 | // the transport. |
| 42 | type ExecCredentialSpec struct { |
| 43 | // Response is populated when the transport encounters HTTP status codes, such as 401, |
| 44 | // suggesting previous credentials were invalid. |
| 45 | // +optional |
| 46 | Response *Response |
| 47 | |
| 48 | // Interactive is true when the transport detects the command is being called from an |
| 49 | // interactive prompt. |
| 50 | // +optional |
| 51 | Interactive bool |
| 52 | } |
| 53 | |
| 54 | // ExecCredentialStatus holds credentials for the transport to use. |
| 55 | type ExecCredentialStatus struct { |
| 56 | // ExpirationTimestamp indicates a time when the provided credentials expire. |
| 57 | // +optional |
| 58 | ExpirationTimestamp *metav1.Time |
| 59 | // Token is a bearer token used by the client for request authentication. |
| 60 | // +optional |
| 61 | Token string |
| 62 | // PEM-encoded client TLS certificate. |
| 63 | // +optional |
| 64 | ClientCertificateData string |
| 65 | // PEM-encoded client TLS private key. |
| 66 | // +optional |
| 67 | ClientKeyData string |
| 68 | } |
| 69 | |
| 70 | // Response defines metadata about a failed request, including HTTP status code and |
| 71 | // response headers. |
| 72 | type Response struct { |
| 73 | // Headers holds HTTP headers returned by the server. |
| 74 | Header map[string][]string |
| 75 | // Code is the HTTP status code returned by the server. |
| 76 | Code int32 |
| 77 | } |