blob: a90949dc37de0d3e812a0d360d3dd8eb27d20fe9 [file] [log] [blame]
Matthias Andreas Benkard832a54e2019-01-29 09:27:38 +01001/*
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// +genclient:noVerbs
28// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
29
30// TokenReview attempts to authenticate a token to a known user.
31// Note: TokenReview requests may be cached by the webhook token authenticator
32// plugin in the kube-apiserver.
33type TokenReview struct {
34 metav1.TypeMeta `json:",inline"`
35 // +optional
36 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
37
38 // Spec holds information about the request being evaluated
39 Spec TokenReviewSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
40
41 // Status is filled in by the server and indicates whether the request can be authenticated.
42 // +optional
43 Status TokenReviewStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
44}
45
46// TokenReviewSpec is a description of the token authentication request.
47type TokenReviewSpec struct {
48 // Token is the opaque bearer token.
49 // +optional
50 Token string `json:"token,omitempty" protobuf:"bytes,1,opt,name=token"`
51}
52
53// TokenReviewStatus is the result of the token authentication request.
54type TokenReviewStatus struct {
55 // Authenticated indicates that the token was associated with a known user.
56 // +optional
57 Authenticated bool `json:"authenticated,omitempty" protobuf:"varint,1,opt,name=authenticated"`
58 // User is the UserInfo associated with the provided token.
59 // +optional
60 User UserInfo `json:"user,omitempty" protobuf:"bytes,2,opt,name=user"`
61 // Error indicates that the token couldn't be checked
62 // +optional
63 Error string `json:"error,omitempty" protobuf:"bytes,3,opt,name=error"`
64}
65
66// UserInfo holds the information about the user needed to implement the
67// user.Info interface.
68type UserInfo struct {
69 // The name that uniquely identifies this user among all active users.
70 // +optional
71 Username string `json:"username,omitempty" protobuf:"bytes,1,opt,name=username"`
72 // A unique value that identifies this user across time. If this user is
73 // deleted and another user by the same name is added, they will have
74 // different UIDs.
75 // +optional
76 UID string `json:"uid,omitempty" protobuf:"bytes,2,opt,name=uid"`
77 // The names of groups this user is a part of.
78 // +optional
79 Groups []string `json:"groups,omitempty" protobuf:"bytes,3,rep,name=groups"`
80 // Any additional information provided by the authenticator.
81 // +optional
82 Extra map[string]ExtraValue `json:"extra,omitempty" protobuf:"bytes,4,rep,name=extra"`
83}
84
85// ExtraValue masks the value so protobuf can generate
86// +protobuf.nullable=true
87// +protobuf.options.(gogoproto.goproto_stringer)=false
88type ExtraValue []string
89
90func (t ExtraValue) String() string {
91 return fmt.Sprintf("%v", []string(t))
92}