authorize based on user.Info

This commit is contained in:
deads2k
2016-07-12 13:25:07 -04:00
parent 7823c5779d
commit f6f1ab34aa
7 changed files with 35 additions and 37 deletions

View File

@@ -129,12 +129,15 @@ func newWithBackoff(kubeConfigFile string, authorizedTTL, unauthorizedTTL, initi
// }
//
func (w *WebhookAuthorizer) Authorize(attr authorizer.Attributes) (err error) {
r := &v1beta1.SubjectAccessReview{
Spec: v1beta1.SubjectAccessReviewSpec{
User: attr.GetUserName(),
Groups: attr.GetGroups(),
},
r := &v1beta1.SubjectAccessReview{}
if user := attr.GetUser(); user != nil {
r.Spec = v1beta1.SubjectAccessReviewSpec{
User: user.GetName(),
Groups: user.GetGroups(),
Extra: user.GetExtra(),
}
}
if attr.IsResourceRequest() {
r.Spec.ResourceAttributes = &v1beta1.ResourceAttributes{
Namespace: attr.GetNamespace(),