|
1 | 1 | import { KubernetesObject } from 'kpt-functions'; |
2 | 2 | import * as apisMetaV1 from './io.k8s.apimachinery.pkg.apis.meta.v1'; |
3 | 3 |
|
| 4 | +// BoundObjectReference is a reference to an object that a token is bound to. |
| 5 | +export class BoundObjectReference { |
| 6 | + // API version of the referent. |
| 7 | + public apiVersion?: string; |
| 8 | + |
| 9 | + // Kind of the referent. Valid kinds are 'Pod' and 'Secret'. |
| 10 | + public kind?: string; |
| 11 | + |
| 12 | + // Name of the referent. |
| 13 | + public name?: string; |
| 14 | + |
| 15 | + // UID of the referent. |
| 16 | + public uid?: string; |
| 17 | +} |
| 18 | + |
| 19 | +// TokenRequest requests a token for a given service account. |
| 20 | +export class TokenRequest implements KubernetesObject { |
| 21 | + // APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources |
| 22 | + public apiVersion: string; |
| 23 | + |
| 24 | + // Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
| 25 | + public kind: string; |
| 26 | + |
| 27 | + public metadata: apisMetaV1.ObjectMeta; |
| 28 | + |
| 29 | + public spec: TokenRequestSpec; |
| 30 | + |
| 31 | + public status?: TokenRequestStatus; |
| 32 | + |
| 33 | + constructor(desc: TokenRequest.Interface) { |
| 34 | + this.apiVersion = TokenRequest.apiVersion; |
| 35 | + this.kind = TokenRequest.kind; |
| 36 | + this.metadata = desc.metadata; |
| 37 | + this.spec = desc.spec; |
| 38 | + this.status = desc.status; |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +export function isTokenRequest(o: any): o is TokenRequest { |
| 43 | + return o && o.apiVersion === TokenRequest.apiVersion && o.kind === TokenRequest.kind; |
| 44 | +} |
| 45 | + |
| 46 | +export namespace TokenRequest { |
| 47 | + export const apiVersion = "authentication.k8s.io/v1"; |
| 48 | + export const group = "authentication.k8s.io"; |
| 49 | + export const version = "v1"; |
| 50 | + export const kind = "TokenRequest"; |
| 51 | + |
| 52 | + // TokenRequest requests a token for a given service account. |
| 53 | + export interface Interface { |
| 54 | + metadata: apisMetaV1.ObjectMeta; |
| 55 | + |
| 56 | + spec: TokenRequestSpec; |
| 57 | + |
| 58 | + status?: TokenRequestStatus; |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +// TokenRequestSpec contains client provided parameters of a token request. |
| 63 | +export class TokenRequestSpec { |
| 64 | + // Audiences are the intendend audiences of the token. A recipient of a token must identitfy themself with an identifier in the list of audiences of the token, and otherwise should reject the token. A token issued for multiple audiences may be used to authenticate against any of the audiences listed but implies a high degree of trust between the target audiences. |
| 65 | + public audiences: string[]; |
| 66 | + |
| 67 | + // BoundObjectRef is a reference to an object that the token will be bound to. The token will only be valid for as long as the bound object exists. NOTE: The API server's TokenReview endpoint will validate the BoundObjectRef, but other audiences may not. Keep ExpirationSeconds small if you want prompt revocation. |
| 68 | + public boundObjectRef?: BoundObjectReference; |
| 69 | + |
| 70 | + // ExpirationSeconds is the requested duration of validity of the request. The token issuer may return a token with a different validity duration so a client needs to check the 'expiration' field in a response. |
| 71 | + public expirationSeconds?: number; |
| 72 | + |
| 73 | + constructor(desc: TokenRequestSpec) { |
| 74 | + this.audiences = desc.audiences; |
| 75 | + this.boundObjectRef = desc.boundObjectRef; |
| 76 | + this.expirationSeconds = desc.expirationSeconds; |
| 77 | + } |
| 78 | +} |
| 79 | + |
| 80 | +// TokenRequestStatus is the result of a token request. |
| 81 | +export class TokenRequestStatus { |
| 82 | + // ExpirationTimestamp is the time of expiration of the returned token. |
| 83 | + public expirationTimestamp: apisMetaV1.Time; |
| 84 | + |
| 85 | + // Token is the opaque bearer token. |
| 86 | + public token: string; |
| 87 | + |
| 88 | + constructor(desc: TokenRequestStatus) { |
| 89 | + this.expirationTimestamp = desc.expirationTimestamp; |
| 90 | + this.token = desc.token; |
| 91 | + } |
| 92 | +} |
| 93 | + |
4 | 94 | // TokenReview attempts to authenticate a token to a known user. Note: TokenReview requests may be cached by the webhook token authenticator plugin in the kube-apiserver. |
5 | 95 | export class TokenReview implements KubernetesObject { |
6 | 96 | // APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources |
|
0 commit comments