mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-23 22:46:59 +00:00
30 lines
670 B
Go
30 lines
670 B
Go
// Copyright 2020-2023 Project Capsule Authors.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package utils
|
|
|
|
import (
|
|
authenticationv1 "k8s.io/api/authentication/v1"
|
|
|
|
capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2"
|
|
)
|
|
|
|
func IsTenantOwner(owners capsulev1beta2.OwnerListSpec, userInfo authenticationv1.UserInfo) bool {
|
|
for _, owner := range owners {
|
|
switch owner.Kind {
|
|
case capsulev1beta2.UserOwner, capsulev1beta2.ServiceAccountOwner:
|
|
if userInfo.Username == owner.Name {
|
|
return true
|
|
}
|
|
case capsulev1beta2.GroupOwner:
|
|
for _, group := range userInfo.Groups {
|
|
if group == owner.Name {
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|