k8c.io/api/v3@v3.0.0-20230904060738-b0a93889c0b6/pkg/apis/kubermatic/v1/user.go (about)

     1  /*
     2  Copyright 2023 The Kubermatic Kubernetes Platform contributors.
     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 v1
    18  
    19  import (
    20  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    21  )
    22  
    23  // +genclient
    24  // +kubebuilder:resource:scope=Cluster
    25  // +kubebuilder:object:generate=true
    26  // +kubebuilder:object:root=true
    27  // +kubebuilder:subresource:status
    28  // +kubebuilder:printcolumn:JSONPath=".spec.email",name="Email",type="string"
    29  // +kubebuilder:printcolumn:JSONPath=".spec.name",name="HumanReadableName",type="string"
    30  // +kubebuilder:printcolumn:JSONPath=".spec.admin",name="Admin",type="boolean"
    31  // +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name="Age",type="date"
    32  
    33  // User specifies a KKP user.
    34  type User struct {
    35  	metav1.TypeMeta   `json:",inline"`
    36  	metav1.ObjectMeta `json:"metadata,omitempty"`
    37  
    38  	Spec   UserSpec   `json:"spec,omitempty"`
    39  	Status UserStatus `json:"status,omitempty"`
    40  }
    41  
    42  // UserStatus stores status information about a user.
    43  type UserStatus struct {
    44  	// LastSeen is the date and time this user last used the KKP dashboard.
    45  	LastSeen metav1.Time `json:"lastSeen,omitempty"`
    46  }
    47  
    48  // UserSpec specifies a user.
    49  type UserSpec struct {
    50  	// Name is the full name of this user.
    51  	Name string `json:"name"`
    52  	// Email is the email address of this user. Emails must be globally unique across all KKP users.
    53  	Email string `json:"email"`
    54  	// IsAdmin defines whether this user is an administrator with additional permissions.
    55  	// +kubebuilder:default=false
    56  	IsAdmin bool `json:"admin"`
    57  	// Groups holds the information to which groups the user belongs to. Set automatically when logging in to the
    58  	// KKP API, and used by the KKP API.
    59  	Groups []string `json:"groups,omitempty"`
    60  
    61  	// Settings contains both user-configurable and system-owned configuration for the KKP dashboard.
    62  	DashboardSettings *UserDashboardSettings `json:"dashboardSettings,omitempty"`
    63  
    64  	// InvalidTokensReference is a reference to a Secret that contains invalidated
    65  	// login tokens. The tokens are used to provide a safe logout mechanism.
    66  	InvalidTokensReference *GlobalSecretKeySelector `json:"invalidTokensReference,omitempty"`
    67  }
    68  
    69  // UserDashboardSettings represent the settings for a user within the KKP dashboard.
    70  type UserDashboardSettings struct {
    71  	SelectedTheme            string `json:"selectedTheme,omitempty"`
    72  	ItemsPerPage             int8   `json:"itemsPerPage,omitempty"`
    73  	SelectProjectTableView   bool   `json:"selectProjectTableView,omitempty"`
    74  	CollapseSidenav          bool   `json:"collapseSidenav,omitempty"`
    75  	LastSeenChangelogVersion string `json:"lastSeenChangelogVersion,omitempty"`
    76  	UseClustersView          bool   `json:"useClustersView,omitempty"`
    77  }
    78  
    79  // +kubebuilder:object:generate=true
    80  // +kubebuilder:object:root=true
    81  
    82  // UserList is a list of users.
    83  type UserList struct {
    84  	metav1.TypeMeta `json:",inline"`
    85  	metav1.ListMeta `json:"metadata,omitempty"`
    86  
    87  	Items []User `json:"items"`
    88  }