-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
553 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,28 @@ | ||
# kubectl-bindrole | ||
|
||
Finding Kubernetes Roles bound to a specified ServiceAccount, Group or User. | ||
|
||
|
||
## Design | ||
|
||
```bash | ||
$ kubectl bindrole test-user | ||
|
||
[ServiceAccount] default/test-user | ||
Secrets: | ||
* default/test-user-token | ||
BindedRoles: | ||
* */edit | ||
* default/test-role | ||
|
||
Policies: | ||
- Name: default/test-role | ||
APIPolicies: |- | ||
|
||
PodSecurityPolicies: |- | ||
|
||
- Name: edit | ||
APIPolicies: |- | ||
PodSecurityPolicies: |- | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package explorer | ||
|
||
import rbacv1 "k8s.io/api/rbac/v1" | ||
|
||
const ( | ||
VerbGet uint = 1 << iota | ||
VerbList | ||
VerbWatch | ||
VerbCreate | ||
VerbUpdate | ||
VerbPatch | ||
VerbDelete | ||
VerbDeletionC | ||
) | ||
|
||
type ResourceAPIPolicy struct { | ||
Resource Resource | ||
APIVerbFlag uint | ||
OtherVerbs []string | ||
ResourceName []string | ||
NonResourceURL []string | ||
} | ||
|
||
func NewResourceAPIPolicy(res Resource, rule rbacv1.PolicyRule) *ResourceAPIPolicy { | ||
rapip := &ResourceAPIPolicy{ | ||
Resource: res, | ||
OtherVerbs: []string{}, | ||
ResourceName: rule.ResourceNames, | ||
NonResourceURL: rule.NonResourceURLs, | ||
} | ||
rapip.SetVerbs(rule.Verbs) | ||
return rapip | ||
} | ||
|
||
func (r *ResourceAPIPolicy) SetVerbs(verbs []string) { | ||
for _, v := range verbs { | ||
switch v { | ||
case "get": | ||
r.APIVerbFlag |= VerbGet | ||
case "list": | ||
r.APIVerbFlag |= VerbList | ||
case "update": | ||
r.APIVerbFlag |= VerbUpdate | ||
case "delete": | ||
r.APIVerbFlag |= VerbDelete | ||
case "deletecollection": | ||
r.APIVerbFlag |= VerbDeletionC | ||
case "patch": | ||
r.APIVerbFlag |= VerbPatch | ||
case "create": | ||
r.APIVerbFlag |= VerbCreate | ||
case "watch": | ||
r.APIVerbFlag |= VerbWatch | ||
default: | ||
r.OtherVerbs = append(r.OtherVerbs, v) | ||
} | ||
} | ||
} |
Oops, something went wrong.