mirror of
https://github.com/niusmallnan/steve.git
synced 2025-07-06 19:18:43 +00:00
Support lookups where user.Info refers to a serviceaccount.
This commit is contained in:
parent
6ebfa39af8
commit
4911ec913f
@ -1,6 +1,7 @@
|
||||
package accesscontrol
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hash"
|
||||
"sort"
|
||||
|
||||
@ -51,6 +52,9 @@ func (p *policyRuleIndex) clusterRoleBindingBySubjectIndexer(crb *rbacv1.Cluster
|
||||
for _, subject := range crb.Subjects {
|
||||
if subject.APIGroup == rbacGroup && subject.Kind == p.kind && crb.RoleRef.Kind == "ClusterRole" {
|
||||
result = append(result, subject.Name)
|
||||
} else if subject.APIGroup == "" && p.kind == "User" && subject.Kind == "ServiceAccount" && subject.Namespace != "" && crb.RoleRef.Kind == "ClusterRole" {
|
||||
// Index is for Users and this references a service account
|
||||
result = append(result, fmt.Sprintf("serviceaccount:%s:%s", subject.Namespace, subject.Name))
|
||||
}
|
||||
}
|
||||
return
|
||||
@ -60,6 +64,9 @@ func (p *policyRuleIndex) roleBindingBySubject(rb *rbacv1.RoleBinding) (result [
|
||||
for _, subject := range rb.Subjects {
|
||||
if subject.APIGroup == rbacGroup && subject.Kind == p.kind {
|
||||
result = append(result, subject.Name)
|
||||
} else if subject.APIGroup == "" && p.kind == "User" && subject.Kind == "ServiceAccount" && subject.Namespace != "" {
|
||||
// Index is for Users and this references a service account
|
||||
result = append(result, fmt.Sprintf("serviceaccount:%s:%s", subject.Namespace, subject.Name))
|
||||
}
|
||||
}
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user