@@ -107,12 +107,12 @@ func (r *Storage) Create(ctx context.Context, obj runtime.Object, _ rest.Validat
107
107
108
108
// check for all namespaces
109
109
{
110
- allowed , err := r .hasAllNamespaceResourceAccess (ctx , in )
110
+ allowed , err := r .hasAllNamespaceResourceAccess (ctx , in , user , extra )
111
111
if err != nil {
112
112
return nil , err
113
113
}
114
114
if allowed {
115
- allowed , err = r .hasNonResourceAccess (ctx , in )
115
+ allowed , err = r .hasNonResourceAccess (ctx , in , user , extra )
116
116
if err != nil {
117
117
return nil , err
118
118
}
@@ -148,14 +148,18 @@ func (r *Storage) Create(ctx context.Context, obj runtime.Object, _ rest.Validat
148
148
return in , nil
149
149
}
150
150
151
- func (r * Storage ) hasNonResourceAccess (ctx context.Context , in * identityapi.SelfSubjectNamespaceAccessReview ) (bool , error ) {
151
+ func (r * Storage ) hasNonResourceAccess (ctx context.Context , in * identityapi.SelfSubjectNamespaceAccessReview , user user. Info , extra map [ string ]authorization. ExtraValue ) (bool , error ) {
152
152
for _ , attr := range in .Spec .NonResourceAttributes {
153
- review := & authorization.SelfSubjectAccessReview {
154
- Spec : authorization.SelfSubjectAccessReviewSpec {
153
+ review := & authorization.SubjectAccessReview {
154
+ Spec : authorization.SubjectAccessReviewSpec {
155
155
NonResourceAttributes : & attr ,
156
+ User : user .GetName (),
157
+ Groups : user .GetGroups (),
158
+ Extra : extra ,
159
+ UID : user .GetUID (),
156
160
},
157
161
}
158
- review , err := r .kc .AuthorizationV1 ().SelfSubjectAccessReviews ().Create (ctx , review , metav1.CreateOptions {})
162
+ review , err := r .kc .AuthorizationV1 ().SubjectAccessReviews ().Create (ctx , review , metav1.CreateOptions {})
159
163
if err != nil {
160
164
return false , err
161
165
}
@@ -166,16 +170,19 @@ func (r *Storage) hasNonResourceAccess(ctx context.Context, in *identityapi.Self
166
170
return true , nil
167
171
}
168
172
169
- func (r * Storage ) hasAllNamespaceResourceAccess (ctx context.Context , in * identityapi.SelfSubjectNamespaceAccessReview ) (bool , error ) {
173
+ func (r * Storage ) hasAllNamespaceResourceAccess (ctx context.Context , in * identityapi.SelfSubjectNamespaceAccessReview , user user. Info , extra map [ string ]authorization. ExtraValue ) (bool , error ) {
170
174
for _ , attr := range in .Spec .ResourceAttributes {
171
175
attr .Namespace = ""
172
- review := & authorization.SelfSubjectAccessReview {
173
- Spec : authorization.SelfSubjectAccessReviewSpec {
174
- ResourceAttributes : & attr ,
175
- NonResourceAttributes : nil ,
176
+ review := & authorization.SubjectAccessReview {
177
+ Spec : authorization.SubjectAccessReviewSpec {
178
+ ResourceAttributes : & attr ,
179
+ User : user .GetName (),
180
+ Groups : user .GetGroups (),
181
+ Extra : extra ,
182
+ UID : user .GetUID (),
176
183
},
177
184
}
178
- review , err := r .kc .AuthorizationV1 ().SelfSubjectAccessReviews ().Create (ctx , review , metav1.CreateOptions {})
185
+ review , err := r .kc .AuthorizationV1 ().SubjectAccessReviews ().Create (ctx , review , metav1.CreateOptions {})
179
186
if err != nil {
180
187
return false , err
181
188
}
0 commit comments