Allows conversions to be automatically generated, and the name is not
externally visible.
| ... | ... |
@@ -189,7 +189,7 @@ type ResourceAccessReview struct {
|
| 189 | 189 |
unversioned.TypeMeta |
| 190 | 190 |
|
| 191 | 191 |
// Action describes the action being tested |
| 192 |
- Action AuthorizationAttributes |
|
| 192 |
+ Action |
|
| 193 | 193 |
} |
| 194 | 194 |
|
| 195 | 195 |
// SubjectAccessReviewResponse describes whether or not a user or group can perform an action |
| ... | ... |
@@ -209,7 +209,7 @@ type SubjectAccessReview struct {
|
| 209 | 209 |
unversioned.TypeMeta |
| 210 | 210 |
|
| 211 | 211 |
// Action describes the action being tested |
| 212 |
- Action AuthorizationAttributes |
|
| 212 |
+ Action |
|
| 213 | 213 |
// User is optional. If both User and Groups are empty, the current authenticated user is used. |
| 214 | 214 |
User string |
| 215 | 215 |
// Groups is optional. Groups is the list of groups to which the User belongs. |
| ... | ... |
@@ -226,7 +226,7 @@ type LocalResourceAccessReview struct {
|
| 226 | 226 |
unversioned.TypeMeta |
| 227 | 227 |
|
| 228 | 228 |
// Action describes the action being tested |
| 229 |
- Action AuthorizationAttributes |
|
| 229 |
+ Action |
|
| 230 | 230 |
} |
| 231 | 231 |
|
| 232 | 232 |
// LocalSubjectAccessReview is an object for requesting information about whether a user or group can perform an action in a particular namespace |
| ... | ... |
@@ -234,7 +234,7 @@ type LocalSubjectAccessReview struct {
|
| 234 | 234 |
unversioned.TypeMeta |
| 235 | 235 |
|
| 236 | 236 |
// Action describes the action being tested. The Namespace element is FORCED to the current namespace. |
| 237 |
- Action AuthorizationAttributes |
|
| 237 |
+ Action |
|
| 238 | 238 |
// User is optional. If both User and Groups are empty, the current authenticated user is used. |
| 239 | 239 |
User string |
| 240 | 240 |
// Groups is optional. Groups is the list of groups to which the User belongs. |
| ... | ... |
@@ -246,8 +246,8 @@ type LocalSubjectAccessReview struct {
|
| 246 | 246 |
Scopes []string |
| 247 | 247 |
} |
| 248 | 248 |
|
| 249 |
-// AuthorizationAttributes describes a request to be authorized |
|
| 250 |
-type AuthorizationAttributes struct {
|
|
| 249 |
+// Action describes a request to be authorized |
|
| 250 |
+type Action struct {
|
|
| 251 | 251 |
// Namespace is the namespace of the action being requested. Currently, there is no distinction between no namespace and all namespaces |
| 252 | 252 |
Namespace string |
| 253 | 253 |
// Verb is one of: get, list, watch, create, update, delete |
| ... | ... |
@@ -13,115 +13,54 @@ import ( |
| 13 | 13 |
uservalidation "github.com/openshift/origin/pkg/user/api/validation" |
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 |
-func Convert_v1_ResourceAccessReview_To_api_ResourceAccessReview(in *ResourceAccessReview, out *newer.ResourceAccessReview, s conversion.Scope) error {
|
|
| 17 |
- if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
|
|
| 18 |
- return err |
|
| 19 |
- } |
|
| 20 |
- if err := s.DefaultConvert(&in.AuthorizationAttributes, &out.Action, conversion.IgnoreMissingFields); err != nil {
|
|
| 21 |
- return err |
|
| 22 |
- } |
|
| 23 |
- |
|
| 24 |
- return nil |
|
| 25 |
-} |
|
| 26 |
- |
|
| 27 |
-func Convert_api_ResourceAccessReview_To_v1_ResourceAccessReview(in *newer.ResourceAccessReview, out *ResourceAccessReview, s conversion.Scope) error {
|
|
| 28 |
- if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
|
|
| 29 |
- return err |
|
| 30 |
- } |
|
| 31 |
- if err := s.DefaultConvert(&in.Action, &out.AuthorizationAttributes, conversion.IgnoreMissingFields); err != nil {
|
|
| 32 |
- return err |
|
| 33 |
- } |
|
| 34 |
- |
|
| 35 |
- return nil |
|
| 36 |
-} |
|
| 37 |
- |
|
| 38 |
-func Convert_v1_LocalResourceAccessReview_To_api_LocalResourceAccessReview(in *LocalResourceAccessReview, out *newer.LocalResourceAccessReview, s conversion.Scope) error {
|
|
| 39 |
- if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
|
|
| 40 |
- return err |
|
| 41 |
- } |
|
| 42 |
- if err := s.DefaultConvert(&in.AuthorizationAttributes, &out.Action, conversion.IgnoreMissingFields); err != nil {
|
|
| 43 |
- return err |
|
| 44 |
- } |
|
| 45 |
- |
|
| 46 |
- return nil |
|
| 47 |
-} |
|
| 48 |
- |
|
| 49 |
-func Convert_api_LocalResourceAccessReview_To_v1_LocalResourceAccessReview(in *newer.LocalResourceAccessReview, out *LocalResourceAccessReview, s conversion.Scope) error {
|
|
| 50 |
- if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
|
|
| 51 |
- return err |
|
| 52 |
- } |
|
| 53 |
- if err := s.DefaultConvert(&in.Action, &out.AuthorizationAttributes, conversion.IgnoreMissingFields); err != nil {
|
|
| 54 |
- return err |
|
| 55 |
- } |
|
| 56 |
- |
|
| 57 |
- return nil |
|
| 58 |
-} |
|
| 59 |
- |
|
| 60 | 16 |
func Convert_v1_SubjectAccessReview_To_api_SubjectAccessReview(in *SubjectAccessReview, out *newer.SubjectAccessReview, s conversion.Scope) error {
|
| 61 |
- if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
|
|
| 62 |
- return err |
|
| 63 |
- } |
|
| 64 |
- if err := s.DefaultConvert(&in.AuthorizationAttributes, &out.Action, conversion.IgnoreMissingFields); err != nil {
|
|
| 17 |
+ if err := autoConvert_v1_SubjectAccessReview_To_api_SubjectAccessReview(in, out, s); err != nil {
|
|
| 65 | 18 |
return err |
| 66 | 19 |
} |
| 67 | 20 |
|
| 68 | 21 |
out.Groups = sets.NewString(in.GroupsSlice...) |
| 69 |
- |
|
| 70 | 22 |
return nil |
| 71 | 23 |
} |
| 72 | 24 |
|
| 73 | 25 |
func Convert_api_SubjectAccessReview_To_v1_SubjectAccessReview(in *newer.SubjectAccessReview, out *SubjectAccessReview, s conversion.Scope) error {
|
| 74 |
- if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
|
|
| 75 |
- return err |
|
| 76 |
- } |
|
| 77 |
- if err := s.DefaultConvert(&in.Action, &out.AuthorizationAttributes, conversion.IgnoreMissingFields); err != nil {
|
|
| 26 |
+ if err := autoConvert_api_SubjectAccessReview_To_v1_SubjectAccessReview(in, out, s); err != nil {
|
|
| 78 | 27 |
return err |
| 79 | 28 |
} |
| 80 | 29 |
|
| 81 | 30 |
out.GroupsSlice = in.Groups.List() |
| 82 |
- |
|
| 83 | 31 |
return nil |
| 84 | 32 |
} |
| 85 | 33 |
|
| 86 | 34 |
func Convert_v1_LocalSubjectAccessReview_To_api_LocalSubjectAccessReview(in *LocalSubjectAccessReview, out *newer.LocalSubjectAccessReview, s conversion.Scope) error {
|
| 87 |
- if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
|
|
| 88 |
- return err |
|
| 89 |
- } |
|
| 90 |
- if err := s.DefaultConvert(&in.AuthorizationAttributes, &out.Action, conversion.IgnoreMissingFields); err != nil {
|
|
| 35 |
+ if err := autoConvert_v1_LocalSubjectAccessReview_To_api_LocalSubjectAccessReview(in, out, s); err != nil {
|
|
| 91 | 36 |
return err |
| 92 | 37 |
} |
| 93 | 38 |
|
| 94 | 39 |
out.Groups = sets.NewString(in.GroupsSlice...) |
| 95 |
- |
|
| 96 | 40 |
return nil |
| 97 | 41 |
} |
| 98 | 42 |
|
| 99 | 43 |
func Convert_api_LocalSubjectAccessReview_To_v1_LocalSubjectAccessReview(in *newer.LocalSubjectAccessReview, out *LocalSubjectAccessReview, s conversion.Scope) error {
|
| 100 |
- if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
|
|
| 101 |
- return err |
|
| 102 |
- } |
|
| 103 |
- if err := s.DefaultConvert(&in.Action, &out.AuthorizationAttributes, conversion.IgnoreMissingFields); err != nil {
|
|
| 44 |
+ if err := autoConvert_api_LocalSubjectAccessReview_To_v1_LocalSubjectAccessReview(in, out, s); err != nil {
|
|
| 104 | 45 |
return err |
| 105 | 46 |
} |
| 106 | 47 |
|
| 107 | 48 |
out.GroupsSlice = in.Groups.List() |
| 108 |
- |
|
| 109 | 49 |
return nil |
| 110 | 50 |
} |
| 111 | 51 |
|
| 112 | 52 |
func Convert_v1_ResourceAccessReviewResponse_To_api_ResourceAccessReviewResponse(in *ResourceAccessReviewResponse, out *newer.ResourceAccessReviewResponse, s conversion.Scope) error {
|
| 113 |
- if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
|
|
| 53 |
+ if err := autoConvert_v1_ResourceAccessReviewResponse_To_api_ResourceAccessReviewResponse(in, out, s); err != nil {
|
|
| 114 | 54 |
return err |
| 115 | 55 |
} |
| 116 | 56 |
|
| 117 | 57 |
out.Users = sets.NewString(in.UsersSlice...) |
| 118 | 58 |
out.Groups = sets.NewString(in.GroupsSlice...) |
| 119 |
- |
|
| 120 | 59 |
return nil |
| 121 | 60 |
} |
| 122 | 61 |
|
| 123 | 62 |
func Convert_api_ResourceAccessReviewResponse_To_v1_ResourceAccessReviewResponse(in *newer.ResourceAccessReviewResponse, out *ResourceAccessReviewResponse, s conversion.Scope) error {
|
| 124 |
- if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
|
|
| 63 |
+ if err := autoConvert_api_ResourceAccessReviewResponse_To_v1_ResourceAccessReviewResponse(in, out, s); err != nil {
|
|
| 125 | 64 |
return err |
| 126 | 65 |
} |
| 127 | 66 |
|
| ... | ... |
@@ -5,8 +5,8 @@ package v1 |
| 5 | 5 |
// by hack/update-generated-swagger-descriptions.sh and should be run after a full build of OpenShift. |
| 6 | 6 |
// ==== DO NOT EDIT THIS FILE MANUALLY ==== |
| 7 | 7 |
|
| 8 |
-var map_AuthorizationAttributes = map[string]string{
|
|
| 9 |
- "": "AuthorizationAttributes describes a request to the API server", |
|
| 8 |
+var map_Action = map[string]string{
|
|
| 9 |
+ "": "Action describes a request to the API server", |
|
| 10 | 10 |
"namespace": "Namespace is the namespace of the action being requested. Currently, there is no distinction between no namespace and all namespaces", |
| 11 | 11 |
"verb": "Verb is one of: get, list, watch, create, update, delete", |
| 12 | 12 |
"resourceAPIGroup": "Group is the API group of the resource Serialized as resourceAPIGroup to avoid confusion with the 'groups' field when inlined", |
| ... | ... |
@@ -16,8 +16,8 @@ var map_AuthorizationAttributes = map[string]string{
|
| 16 | 16 |
"content": "Content is the actual content of the request for create and update", |
| 17 | 17 |
} |
| 18 | 18 |
|
| 19 |
-func (AuthorizationAttributes) SwaggerDoc() map[string]string {
|
|
| 20 |
- return map_AuthorizationAttributes |
|
| 19 |
+func (Action) SwaggerDoc() map[string]string {
|
|
| 20 |
+ return map_Action |
|
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 | 23 |
var map_ClusterPolicy = map[string]string{
|
| ... | ... |
@@ -173,8 +173,8 @@ type ResourceAccessReviewResponse struct {
|
| 173 | 173 |
type ResourceAccessReview struct {
|
| 174 | 174 |
unversioned.TypeMeta `json:",inline"` |
| 175 | 175 |
|
| 176 |
- // AuthorizationAttributes describes the action being tested. |
|
| 177 |
- AuthorizationAttributes `json:",inline" protobuf:"bytes,1,opt,name=authorizationAttributes"` |
|
| 176 |
+ // Action describes the action being tested. |
|
| 177 |
+ Action `json:",inline" protobuf:"bytes,1,opt,name=Action"` |
|
| 178 | 178 |
} |
| 179 | 179 |
|
| 180 | 180 |
// SubjectAccessReviewResponse describes whether or not a user or group can perform an action |
| ... | ... |
@@ -197,8 +197,8 @@ type OptionalScopes []string |
| 197 | 197 |
type SubjectAccessReview struct {
|
| 198 | 198 |
unversioned.TypeMeta `json:",inline"` |
| 199 | 199 |
|
| 200 |
- // AuthorizationAttributes describes the action being tested. |
|
| 201 |
- AuthorizationAttributes `json:",inline" protobuf:"bytes,1,opt,name=authorizationAttributes"` |
|
| 200 |
+ // Action describes the action being tested. |
|
| 201 |
+ Action `json:",inline" protobuf:"bytes,1,opt,name=Action"` |
|
| 202 | 202 |
// User is optional. If both User and Groups are empty, the current authenticated user is used. |
| 203 | 203 |
User string `json:"user" protobuf:"bytes,2,opt,name=user"` |
| 204 | 204 |
// GroupsSlice is optional. Groups is the list of groups to which the User belongs. |
| ... | ... |
@@ -214,16 +214,16 @@ type SubjectAccessReview struct {
|
| 214 | 214 |
type LocalResourceAccessReview struct {
|
| 215 | 215 |
unversioned.TypeMeta `json:",inline"` |
| 216 | 216 |
|
| 217 |
- // AuthorizationAttributes describes the action being tested. The Namespace element is FORCED to the current namespace. |
|
| 218 |
- AuthorizationAttributes `json:",inline" protobuf:"bytes,1,opt,name=authorizationAttributes"` |
|
| 217 |
+ // Action describes the action being tested. The Namespace element is FORCED to the current namespace. |
|
| 218 |
+ Action `json:",inline" protobuf:"bytes,1,opt,name=Action"` |
|
| 219 | 219 |
} |
| 220 | 220 |
|
| 221 | 221 |
// LocalSubjectAccessReview is an object for requesting information about whether a user or group can perform an action in a particular namespace |
| 222 | 222 |
type LocalSubjectAccessReview struct {
|
| 223 | 223 |
unversioned.TypeMeta `json:",inline"` |
| 224 | 224 |
|
| 225 |
- // AuthorizationAttributes describes the action being tested. The Namespace element is FORCED to the current namespace. |
|
| 226 |
- AuthorizationAttributes `json:",inline" protobuf:"bytes,1,opt,name=authorizationAttributes"` |
|
| 225 |
+ // Action describes the action being tested. The Namespace element is FORCED to the current namespace. |
|
| 226 |
+ Action `json:",inline" protobuf:"bytes,1,opt,name=Action"` |
|
| 227 | 227 |
// User is optional. If both User and Groups are empty, the current authenticated user is used. |
| 228 | 228 |
User string `json:"user" protobuf:"bytes,2,opt,name=user"` |
| 229 | 229 |
// Groups is optional. Groups is the list of groups to which the User belongs. |
| ... | ... |
@@ -235,8 +235,8 @@ type LocalSubjectAccessReview struct {
|
| 235 | 235 |
Scopes OptionalScopes `json:"scopes" protobuf:"bytes,4,rep,name=scopes"` |
| 236 | 236 |
} |
| 237 | 237 |
|
| 238 |
-// AuthorizationAttributes describes a request to the API server |
|
| 239 |
-type AuthorizationAttributes struct {
|
|
| 238 |
+// Action describes a request to the API server |
|
| 239 |
+type Action struct {
|
|
| 240 | 240 |
// Namespace is the namespace of the action being requested. Currently, there is no distinction between no namespace and all namespaces |
| 241 | 241 |
Namespace string `json:"namespace" protobuf:"bytes,1,opt,name=namespace"` |
| 242 | 242 |
// Verb is one of: get, list, watch, create, update, delete |
| ... | ... |
@@ -16,12 +16,12 @@ var _ = kauthorizer.Attributes(AdapterAttributes{})
|
| 16 | 16 |
type AdapterAttributes struct {
|
| 17 | 17 |
namespace string |
| 18 | 18 |
user user.Info |
| 19 |
- authorizationAttributes oauthorizer.AuthorizationAttributes |
|
| 19 |
+ authorizationAttributes oauthorizer.Action |
|
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 | 22 |
// OriginAuthorizerAttributes adapts Kubernetes authorization attributes to Origin authorization attributes |
| 23 | 23 |
// Note that some info (like resourceName, apiVersion, apiGroup) is not available from the Kubernetes attributes |
| 24 |
-func OriginAuthorizerAttributes(kattrs kauthorizer.Attributes) (kapi.Context, oauthorizer.AuthorizationAttributes) {
|
|
| 24 |
+func OriginAuthorizerAttributes(kattrs kauthorizer.Attributes) (kapi.Context, oauthorizer.Action) {
|
|
| 25 | 25 |
// Build a context to hold the namespace and user info |
| 26 | 26 |
ctx := kapi.NewContext() |
| 27 | 27 |
ctx = kapi.WithNamespace(ctx, kattrs.GetNamespace()) |
| ... | ... |
@@ -55,7 +55,7 @@ func OriginAuthorizerAttributes(kattrs kauthorizer.Attributes) (kapi.Context, oa |
| 55 | 55 |
|
| 56 | 56 |
// KubernetesAuthorizerAttributes adapts Origin authorization attributes to Kubernetes authorization attributes |
| 57 | 57 |
// The returned attributes can be passed to OriginAuthorizerAttributes to access extra information from the Origin attributes interface |
| 58 |
-func KubernetesAuthorizerAttributes(namespace string, user user.Info, oattrs oauthorizer.AuthorizationAttributes) kauthorizer.Attributes {
|
|
| 58 |
+func KubernetesAuthorizerAttributes(namespace string, user user.Info, oattrs oauthorizer.Action) kauthorizer.Attributes {
|
|
| 59 | 59 |
return AdapterAttributes{
|
| 60 | 60 |
namespace: namespace, |
| 61 | 61 |
user: user, |
| ... | ... |
@@ -113,7 +113,7 @@ func TestAttributeIntersection(t *testing.T) {
|
| 113 | 113 |
) |
| 114 | 114 |
|
| 115 | 115 |
kattributesType := reflect.TypeOf((*kauthorizer.Attributes)(nil)).Elem() |
| 116 |
- oattributesType := reflect.TypeOf((*oauthorizer.AuthorizationAttributes)(nil)).Elem() |
|
| 116 |
+ oattributesType := reflect.TypeOf((*oauthorizer.Action)(nil)).Elem() |
|
| 117 | 117 |
|
| 118 | 118 |
kattributesMethods := sets.NewString() |
| 119 | 119 |
for i := 0; i < kattributesType.NumMethod(); i++ {
|
| ... | ... |
@@ -21,9 +21,9 @@ type DefaultAuthorizationAttributes struct {
|
| 21 | 21 |
URL string |
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 |
-// ToDefaultAuthorizationAttributes coerces AuthorizationAttributes to DefaultAuthorizationAttributes. Namespace is not included |
|
| 24 |
+// ToDefaultAuthorizationAttributes coerces Action to DefaultAuthorizationAttributes. Namespace is not included |
|
| 25 | 25 |
// because the authorizer takes that information on the context |
| 26 |
-func ToDefaultAuthorizationAttributes(in authorizationapi.AuthorizationAttributes) DefaultAuthorizationAttributes {
|
|
| 26 |
+func ToDefaultAuthorizationAttributes(in authorizationapi.Action) DefaultAuthorizationAttributes {
|
|
| 27 | 27 |
return DefaultAuthorizationAttributes{
|
| 28 | 28 |
Verb: in.Verb, |
| 29 | 29 |
APIGroup: in.Group, |
| ... | ... |
@@ -136,8 +136,8 @@ func splitPath(thePath string) []string {
|
| 136 | 136 |
return strings.Split(thePath, "/") |
| 137 | 137 |
} |
| 138 | 138 |
|
| 139 |
-// DefaultAuthorizationAttributes satisfies the AuthorizationAttributes interface |
|
| 140 |
-var _ AuthorizationAttributes = DefaultAuthorizationAttributes{}
|
|
| 139 |
+// DefaultAuthorizationAttributes satisfies the Action interface |
|
| 140 |
+var _ Action = DefaultAuthorizationAttributes{}
|
|
| 141 | 141 |
|
| 142 | 142 |
func (a DefaultAuthorizationAttributes) GetAPIVersion() string {
|
| 143 | 143 |
return a.APIVersion |
| ... | ... |
@@ -16,7 +16,7 @@ func NewAuthorizationAttributeBuilder(contextMapper kapi.RequestContextMapper, i |
| 16 | 16 |
return &openshiftAuthorizationAttributeBuilder{contextMapper, infoResolver}
|
| 17 | 17 |
} |
| 18 | 18 |
|
| 19 |
-func (a *openshiftAuthorizationAttributeBuilder) GetAttributes(req *http.Request) (AuthorizationAttributes, error) {
|
|
| 19 |
+func (a *openshiftAuthorizationAttributeBuilder) GetAttributes(req *http.Request) (Action, error) {
|
|
| 20 | 20 |
requestInfo, err := a.infoResolver.GetRequestInfo(req) |
| 21 | 21 |
if err != nil {
|
| 22 | 22 |
return nil, err |
| ... | ... |
@@ -7,13 +7,13 @@ import ( |
| 7 | 7 |
) |
| 8 | 8 |
|
| 9 | 9 |
func TestAuthorizationAttributes(t *testing.T) {
|
| 10 |
- // Wrapper to make sure additions to the AuthorizationAttributes interface get corresponding fields added in api.AuthorizationAttributes |
|
| 11 |
- // If an additional function is required to satisfy this interface, the data for it should come from the contained authorizationapi.AuthorizationAttributes |
|
| 12 |
- var _ AuthorizationAttributes = authorizationAttributesAdapter{}
|
|
| 10 |
+ // Wrapper to make sure additions to the Action interface get corresponding fields added in api.Action |
|
| 11 |
+ // If an additional function is required to satisfy this interface, the data for it should come from the contained authorizationapi.Action |
|
| 12 |
+ var _ Action = authorizationAttributesAdapter{}
|
|
| 13 | 13 |
} |
| 14 | 14 |
|
| 15 | 15 |
type authorizationAttributesAdapter struct {
|
| 16 |
- attrs authorizationapi.AuthorizationAttributes |
|
| 16 |
+ attrs authorizationapi.Action |
|
| 17 | 17 |
} |
| 18 | 18 |
|
| 19 | 19 |
func (a authorizationAttributesAdapter) GetVerb() string {
|
| ... | ... |
@@ -37,17 +37,17 @@ func (a authorizationAttributesAdapter) GetResourceName() string {
|
| 37 | 37 |
} |
| 38 | 38 |
|
| 39 | 39 |
func (a authorizationAttributesAdapter) GetRequestAttributes() interface{} {
|
| 40 |
- // AuthorizationAttributes doesn't currently support request attributes, |
|
| 40 |
+ // Action doesn't currently support request attributes, |
|
| 41 | 41 |
// because they cannot be reliably serialized |
| 42 | 42 |
return nil |
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 | 45 |
func (a authorizationAttributesAdapter) IsNonResourceURL() bool {
|
| 46 |
- // AuthorizationAttributes currently only supports resource authorization checks |
|
| 46 |
+ // Action currently only supports resource authorization checks |
|
| 47 | 47 |
return false |
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 | 50 |
func (a authorizationAttributesAdapter) GetURL() string {
|
| 51 |
- // AuthorizationAttributes currently only supports resource authorization checks |
|
| 51 |
+ // Action currently only supports resource authorization checks |
|
| 52 | 52 |
return "" |
| 53 | 53 |
} |
| ... | ... |
@@ -18,7 +18,7 @@ func NewAuthorizer(ruleResolver rulevalidation.AuthorizationRuleResolver, forbid |
| 18 | 18 |
return &openshiftAuthorizer{ruleResolver, forbiddenMessageMaker}
|
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
-func (a *openshiftAuthorizer) Authorize(ctx kapi.Context, passedAttributes AuthorizationAttributes) (bool, string, error) {
|
|
| 21 |
+func (a *openshiftAuthorizer) Authorize(ctx kapi.Context, passedAttributes Action) (bool, string, error) {
|
|
| 22 | 22 |
attributes := CoerceToDefaultAuthorizationAttributes(passedAttributes) |
| 23 | 23 |
|
| 24 | 24 |
// keep track of errors in case we are unable to authorize the action. |
| ... | ... |
@@ -63,7 +63,7 @@ func (a *openshiftAuthorizer) Authorize(ctx kapi.Context, passedAttributes Autho |
| 63 | 63 |
// If we got an error, then the list of subjects may not be complete, but it does not contain any incorrect names. |
| 64 | 64 |
// This is done because policy rules are purely additive and policy determinations |
| 65 | 65 |
// can be made on the basis of those rules that are found. |
| 66 |
-func (a *openshiftAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes AuthorizationAttributes) (sets.String, sets.String, error) {
|
|
| 66 |
+func (a *openshiftAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes Action) (sets.String, sets.String, error) {
|
|
| 67 | 67 |
errs := []error{}
|
| 68 | 68 |
|
| 69 | 69 |
masterContext := kapi.WithNamespace(ctx, kapi.NamespaceNone) |
| ... | ... |
@@ -87,7 +87,7 @@ func (a *openshiftAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes Au |
| 87 | 87 |
return users, groups, kerrors.NewAggregate(errs) |
| 88 | 88 |
} |
| 89 | 89 |
|
| 90 |
-func (a *openshiftAuthorizer) getAllowedSubjectsFromNamespaceBindings(ctx kapi.Context, passedAttributes AuthorizationAttributes) (sets.String, sets.String, error) {
|
|
| 90 |
+func (a *openshiftAuthorizer) getAllowedSubjectsFromNamespaceBindings(ctx kapi.Context, passedAttributes Action) (sets.String, sets.String, error) {
|
|
| 91 | 91 |
attributes := CoerceToDefaultAuthorizationAttributes(passedAttributes) |
| 92 | 92 |
|
| 93 | 93 |
errs := []error{}
|
| ... | ... |
@@ -129,7 +129,7 @@ func (a *openshiftAuthorizer) getAllowedSubjectsFromNamespaceBindings(ctx kapi.C |
| 129 | 129 |
// authorizeWithNamespaceRules returns isAllowed, reason, and error. If an error is returned, isAllowed and reason are still valid. This seems strange |
| 130 | 130 |
// but errors are not always fatal to the authorization process. It is entirely possible to get an error and be able to continue determine authorization |
| 131 | 131 |
// status in spite of it. This is most common when a bound role is missing, but enough roles are still present and bound to authorize the request. |
| 132 |
-func (a *openshiftAuthorizer) authorizeWithNamespaceRules(ctx kapi.Context, passedAttributes AuthorizationAttributes) (bool, string, error) {
|
|
| 132 |
+func (a *openshiftAuthorizer) authorizeWithNamespaceRules(ctx kapi.Context, passedAttributes Action) (bool, string, error) {
|
|
| 133 | 133 |
attributes := CoerceToDefaultAuthorizationAttributes(passedAttributes) |
| 134 | 134 |
|
| 135 | 135 |
allRules, ruleRetrievalError := a.ruleResolver.GetEffectivePolicyRules(ctx) |
| ... | ... |
@@ -153,7 +153,7 @@ func (a *openshiftAuthorizer) authorizeWithNamespaceRules(ctx kapi.Context, pass |
| 153 | 153 |
|
| 154 | 154 |
// TODO this may or may not be the behavior we want for managing rules. As a for instance, a verb might be specified |
| 155 | 155 |
// that our attributes builder will never satisfy. For now, I think gets us close. Maybe a warning message of some kind? |
| 156 |
-func CoerceToDefaultAuthorizationAttributes(passedAttributes AuthorizationAttributes) *DefaultAuthorizationAttributes {
|
|
| 156 |
+func CoerceToDefaultAuthorizationAttributes(passedAttributes Action) *DefaultAuthorizationAttributes {
|
|
| 157 | 157 |
attributes, ok := passedAttributes.(*DefaultAuthorizationAttributes) |
| 158 | 158 |
if !ok {
|
| 159 | 159 |
attributes = &DefaultAuthorizationAttributes{
|
| ... | ... |
@@ -60,7 +60,7 @@ func NewAuthorizer(a authorizer.Authorizer, ttl time.Duration, cacheSize int) (a |
| 60 | 60 |
}, nil |
| 61 | 61 |
} |
| 62 | 62 |
|
| 63 |
-func (c *CacheAuthorizer) Authorize(ctx kapi.Context, a authorizer.AuthorizationAttributes) (allowed bool, reason string, err error) {
|
|
| 63 |
+func (c *CacheAuthorizer) Authorize(ctx kapi.Context, a authorizer.Action) (allowed bool, reason string, err error) {
|
|
| 64 | 64 |
key, err := cacheKey(ctx, a) |
| 65 | 65 |
if err != nil {
|
| 66 | 66 |
glog.V(5).Infof("could not build cache key for %#v: %v", a, err)
|
| ... | ... |
@@ -92,7 +92,7 @@ func (c *CacheAuthorizer) Authorize(ctx kapi.Context, a authorizer.Authorization |
| 92 | 92 |
return allowed, reason, err |
| 93 | 93 |
} |
| 94 | 94 |
|
| 95 |
-func (c *CacheAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes authorizer.AuthorizationAttributes) (sets.String, sets.String, error) {
|
|
| 95 |
+func (c *CacheAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes authorizer.Action) (sets.String, sets.String, error) {
|
|
| 96 | 96 |
key, err := cacheKey(ctx, attributes) |
| 97 | 97 |
if err != nil {
|
| 98 | 98 |
glog.V(5).Infof("could not build cache key for %#v: %v", attributes, err)
|
| ... | ... |
@@ -123,7 +123,7 @@ func (c *CacheAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes author |
| 123 | 123 |
return users, groups, err |
| 124 | 124 |
} |
| 125 | 125 |
|
| 126 |
-func cacheKey(ctx kapi.Context, a authorizer.AuthorizationAttributes) (string, error) {
|
|
| 126 |
+func cacheKey(ctx kapi.Context, a authorizer.Action) (string, error) {
|
|
| 127 | 127 |
if a.GetRequestAttributes() != nil {
|
| 128 | 128 |
// TODO: see if we can serialize this? |
| 129 | 129 |
return "", errors.New("cannot cache request attributes")
|
| ... | ... |
@@ -21,7 +21,7 @@ func TestAuthorizer(t *testing.T) {
|
| 21 | 21 |
func TestCacheKey(t *testing.T) {
|
| 22 | 22 |
tests := map[string]struct {
|
| 23 | 23 |
Context kapi.Context |
| 24 |
- Attrs authorizer.AuthorizationAttributes |
|
| 24 |
+ Attrs authorizer.Action |
|
| 25 | 25 |
|
| 26 | 26 |
ExpectedKey string |
| 27 | 27 |
ExpectedErr bool |
| ... | ... |
@@ -80,7 +80,7 @@ func TestCacheKeyFields(t *testing.T) {
|
| 80 | 80 |
// These are results we don't expect to be in the cache key |
| 81 | 81 |
expectedMissingKeys := sets.NewString("requestattributes")
|
| 82 | 82 |
|
| 83 |
- attrType := reflect.TypeOf((*authorizer.AuthorizationAttributes)(nil)).Elem() |
|
| 83 |
+ attrType := reflect.TypeOf((*authorizer.Action)(nil)).Elem() |
|
| 84 | 84 |
for i := 0; i < attrType.NumMethod(); i++ {
|
| 85 | 85 |
name := attrType.Method(i).Name |
| 86 | 86 |
name = strings.TrimPrefix(name, "Get") |
| ... | ... |
@@ -10,19 +10,19 @@ import ( |
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 | 12 |
type Authorizer interface {
|
| 13 |
- Authorize(ctx kapi.Context, a AuthorizationAttributes) (allowed bool, reason string, err error) |
|
| 14 |
- GetAllowedSubjects(ctx kapi.Context, attributes AuthorizationAttributes) (sets.String, sets.String, error) |
|
| 13 |
+ Authorize(ctx kapi.Context, a Action) (allowed bool, reason string, err error) |
|
| 14 |
+ GetAllowedSubjects(ctx kapi.Context, attributes Action) (sets.String, sets.String, error) |
|
| 15 | 15 |
} |
| 16 | 16 |
|
| 17 | 17 |
type AuthorizationAttributeBuilder interface {
|
| 18 |
- GetAttributes(request *http.Request) (AuthorizationAttributes, error) |
|
| 18 |
+ GetAttributes(request *http.Request) (Action, error) |
|
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 | 21 |
type RequestInfoResolver interface {
|
| 22 | 22 |
GetRequestInfo(req *http.Request) (kapiserver.RequestInfo, error) |
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 |
-type AuthorizationAttributes interface {
|
|
| 25 |
+type Action interface {
|
|
| 26 | 26 |
GetVerb() string |
| 27 | 27 |
GetAPIVersion() string |
| 28 | 28 |
GetAPIGroup() string |
| ... | ... |
@@ -46,5 +46,5 @@ type ForbiddenMessageMaker interface {
|
| 46 | 46 |
type MessageContext struct {
|
| 47 | 47 |
User user.Info |
| 48 | 48 |
Namespace string |
| 49 |
- Attributes AuthorizationAttributes |
|
| 49 |
+ Attributes Action |
|
| 50 | 50 |
} |
| ... | ... |
@@ -12,7 +12,7 @@ import ( |
| 12 | 12 |
authorizationapi "github.com/openshift/origin/pkg/authorization/api" |
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 |
-func IsPersonalAccessReview(a AuthorizationAttributes) (bool, error) {
|
|
| 15 |
+func IsPersonalAccessReview(a Action) (bool, error) {
|
|
| 16 | 16 |
switch extendedAttributes := a.GetRequestAttributes().(type) {
|
| 17 | 17 |
case *http.Request: |
| 18 | 18 |
return isPersonalAccessReviewFromRequest(a, extendedAttributes) |
| ... | ... |
@@ -30,7 +30,7 @@ func IsPersonalAccessReview(a AuthorizationAttributes) (bool, error) {
|
| 30 | 30 |
} |
| 31 | 31 |
|
| 32 | 32 |
// isPersonalAccessReviewFromRequest this variant handles the case where we have an httpRequest |
| 33 |
-func isPersonalAccessReviewFromRequest(a AuthorizationAttributes, req *http.Request) (bool, error) {
|
|
| 33 |
+func isPersonalAccessReviewFromRequest(a Action, req *http.Request) (bool, error) {
|
|
| 34 | 34 |
// TODO once we're integrated with the api installer, we should have direct access to the deserialized content |
| 35 | 35 |
// for now, this only happens on subjectaccessreviews with a personal check, pay the double retrieve and decode cost |
| 36 | 36 |
body, err := ioutil.ReadAll(req.Body) |
| ... | ... |
@@ -30,7 +30,7 @@ func NewAuthorizer(client RemoteAuthorizerClient) (authorizer.Authorizer, error) |
| 30 | 30 |
return &RemoteAuthorizer{client}, nil
|
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 |
-func (r *RemoteAuthorizer) Authorize(ctx kapi.Context, a authorizer.AuthorizationAttributes) (bool, string, error) {
|
|
| 33 |
+func (r *RemoteAuthorizer) Authorize(ctx kapi.Context, a authorizer.Action) (bool, string, error) {
|
|
| 34 | 34 |
var ( |
| 35 | 35 |
result *authzapi.SubjectAccessReviewResponse |
| 36 | 36 |
err error |
| ... | ... |
@@ -70,7 +70,7 @@ func (r *RemoteAuthorizer) Authorize(ctx kapi.Context, a authorizer.Authorizatio |
| 70 | 70 |
return result.Allowed, result.Reason, nil |
| 71 | 71 |
} |
| 72 | 72 |
|
| 73 |
-func (r *RemoteAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes authorizer.AuthorizationAttributes) (sets.String, sets.String, error) {
|
|
| 73 |
+func (r *RemoteAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes authorizer.Action) (sets.String, sets.String, error) {
|
|
| 74 | 74 |
var ( |
| 75 | 75 |
result *authzapi.ResourceAccessReviewResponse |
| 76 | 76 |
err error |
| ... | ... |
@@ -92,8 +92,8 @@ func (r *RemoteAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes autho |
| 92 | 92 |
return result.Users, result.Groups, nil |
| 93 | 93 |
} |
| 94 | 94 |
|
| 95 |
-func getAction(namespace string, attributes authorizer.AuthorizationAttributes) authzapi.AuthorizationAttributes {
|
|
| 96 |
- return authzapi.AuthorizationAttributes{
|
|
| 95 |
+func getAction(namespace string, attributes authorizer.Action) authzapi.Action {
|
|
| 96 |
+ return authzapi.Action{
|
|
| 97 | 97 |
Namespace: namespace, |
| 98 | 98 |
Verb: attributes.GetVerb(), |
| 99 | 99 |
Group: attributes.GetAPIGroup(), |
| ... | ... |
@@ -101,10 +101,10 @@ func getAction(namespace string, attributes authorizer.AuthorizationAttributes) |
| 101 | 101 |
Resource: attributes.GetResource(), |
| 102 | 102 |
ResourceName: attributes.GetResourceName(), |
| 103 | 103 |
|
| 104 |
- // TODO: missing from authorizer.AuthorizationAttributes: |
|
| 104 |
+ // TODO: missing from authorizer.Action: |
|
| 105 | 105 |
// Content |
| 106 | 106 |
|
| 107 |
- // TODO: missing from authzapi.AuthorizationAttributes |
|
| 107 |
+ // TODO: missing from authzapi.Action |
|
| 108 | 108 |
// RequestAttributes (unserializable?) |
| 109 | 109 |
// IsNonResourceURL |
| 110 | 110 |
// URL (doesn't make sense for remote authz?) |
| ... | ... |
@@ -23,7 +23,7 @@ func NewAuthorizer(delegate defaultauthorizer.Authorizer, clusterPolicyGetter cl |
| 23 | 23 |
return &scopeAuthorizer{delegate: delegate, clusterPolicyGetter: clusterPolicyGetter, forbiddenMessageMaker: forbiddenMessageMaker}
|
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 |
-func (a *scopeAuthorizer) Authorize(ctx kapi.Context, passedAttributes defaultauthorizer.AuthorizationAttributes) (bool, string, error) {
|
|
| 26 |
+func (a *scopeAuthorizer) Authorize(ctx kapi.Context, passedAttributes defaultauthorizer.Action) (bool, string, error) {
|
|
| 27 | 27 |
user, exists := kapi.UserFrom(ctx) |
| 28 | 28 |
if !exists {
|
| 29 | 29 |
return false, "", fmt.Errorf("user missing from context")
|
| ... | ... |
@@ -67,6 +67,6 @@ func (a *scopeAuthorizer) Authorize(ctx kapi.Context, passedAttributes defaultau |
| 67 | 67 |
|
| 68 | 68 |
// TODO remove this. We don't logically need it, but it requires splitting our interface |
| 69 | 69 |
// GetAllowedSubjects returns the subjects it knows can perform the action. |
| 70 |
-func (a *scopeAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes defaultauthorizer.AuthorizationAttributes) (sets.String, sets.String, error) {
|
|
| 70 |
+func (a *scopeAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes defaultauthorizer.Action) (sets.String, sets.String, error) {
|
|
| 71 | 71 |
return a.delegate.GetAllowedSubjects(ctx, attributes) |
| 72 | 72 |
} |
| ... | ... |
@@ -113,11 +113,11 @@ type fakeAuthorizer struct {
|
| 113 | 113 |
called bool |
| 114 | 114 |
} |
| 115 | 115 |
|
| 116 |
-func (a *fakeAuthorizer) Authorize(ctx kapi.Context, passedAttributes defaultauthorizer.AuthorizationAttributes) (bool, string, error) {
|
|
| 116 |
+func (a *fakeAuthorizer) Authorize(ctx kapi.Context, passedAttributes defaultauthorizer.Action) (bool, string, error) {
|
|
| 117 | 117 |
a.called = true |
| 118 | 118 |
return a.allowed, "", nil |
| 119 | 119 |
} |
| 120 | 120 |
|
| 121 |
-func (a *fakeAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes defaultauthorizer.AuthorizationAttributes) (sets.String, sets.String, error) {
|
|
| 121 |
+func (a *fakeAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes defaultauthorizer.Action) (sets.String, sets.String, error) {
|
|
| 122 | 122 |
return nil, nil, nil |
| 123 | 123 |
} |
| ... | ... |
@@ -27,7 +27,7 @@ type testAuthorizer struct {
|
| 27 | 27 |
actualAttributes authorizer.DefaultAuthorizationAttributes |
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 |
-func (a *testAuthorizer) Authorize(ctx kapi.Context, attributes authorizer.AuthorizationAttributes) (allowed bool, reason string, err error) {
|
|
| 30 |
+func (a *testAuthorizer) Authorize(ctx kapi.Context, attributes authorizer.Action) (allowed bool, reason string, err error) {
|
|
| 31 | 31 |
// allow the initial check for "can I run this RAR at all" |
| 32 | 32 |
if attributes.GetResource() == "localresourceaccessreviews" {
|
| 33 | 33 |
return true, "", nil |
| ... | ... |
@@ -35,7 +35,7 @@ func (a *testAuthorizer) Authorize(ctx kapi.Context, attributes authorizer.Autho |
| 35 | 35 |
|
| 36 | 36 |
return false, "", errors.New("Unsupported")
|
| 37 | 37 |
} |
| 38 |
-func (a *testAuthorizer) GetAllowedSubjects(ctx kapi.Context, passedAttributes authorizer.AuthorizationAttributes) (sets.String, sets.String, error) {
|
|
| 38 |
+func (a *testAuthorizer) GetAllowedSubjects(ctx kapi.Context, passedAttributes authorizer.Action) (sets.String, sets.String, error) {
|
|
| 39 | 39 |
attributes, ok := passedAttributes.(authorizer.DefaultAuthorizationAttributes) |
| 40 | 40 |
if !ok {
|
| 41 | 41 |
return nil, nil, errors.New("unexpected type for test")
|
| ... | ... |
@@ -54,7 +54,7 @@ func TestNoNamespace(t *testing.T) {
|
| 54 | 54 |
err: "namespace is required on this type: ", |
| 55 | 55 |
}, |
| 56 | 56 |
reviewRequest: &authorizationapi.LocalResourceAccessReview{
|
| 57 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 57 |
+ Action: authorizationapi.Action{
|
|
| 58 | 58 |
Namespace: "", |
| 59 | 59 |
Verb: "get", |
| 60 | 60 |
Resource: "pods", |
| ... | ... |
@@ -68,7 +68,7 @@ func TestNoNamespace(t *testing.T) {
|
| 68 | 68 |
func TestConflictingNamespace(t *testing.T) {
|
| 69 | 69 |
authorizer := &testAuthorizer{}
|
| 70 | 70 |
reviewRequest := &authorizationapi.LocalResourceAccessReview{
|
| 71 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 71 |
+ Action: authorizationapi.Action{
|
|
| 72 | 72 |
Namespace: "foo", |
| 73 | 73 |
Verb: "get", |
| 74 | 74 |
Resource: "pods", |
| ... | ... |
@@ -93,7 +93,7 @@ func TestEmptyReturn(t *testing.T) {
|
| 93 | 93 |
groups: sets.String{},
|
| 94 | 94 |
}, |
| 95 | 95 |
reviewRequest: &authorizationapi.LocalResourceAccessReview{
|
| 96 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 96 |
+ Action: authorizationapi.Action{
|
|
| 97 | 97 |
Namespace: "unittest", |
| 98 | 98 |
Verb: "get", |
| 99 | 99 |
Resource: "pods", |
| ... | ... |
@@ -111,7 +111,7 @@ func TestNoErrors(t *testing.T) {
|
| 111 | 111 |
groups: sets.NewString("three", "four"),
|
| 112 | 112 |
}, |
| 113 | 113 |
reviewRequest: &authorizationapi.LocalResourceAccessReview{
|
| 114 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 114 |
+ Action: authorizationapi.Action{
|
|
| 115 | 115 |
Namespace: "unittest", |
| 116 | 116 |
Verb: "delete", |
| 117 | 117 |
Resource: "deploymentConfig", |
| ... | ... |
@@ -32,7 +32,7 @@ type testAuthorizer struct {
|
| 32 | 32 |
actualUserInfo user.Info |
| 33 | 33 |
} |
| 34 | 34 |
|
| 35 |
-func (a *testAuthorizer) Authorize(ctx kapi.Context, passedAttributes authorizer.AuthorizationAttributes) (allowed bool, reason string, err error) {
|
|
| 35 |
+func (a *testAuthorizer) Authorize(ctx kapi.Context, passedAttributes authorizer.Action) (allowed bool, reason string, err error) {
|
|
| 36 | 36 |
a.actualUserInfo, _ = kapi.UserFrom(ctx) |
| 37 | 37 |
|
| 38 | 38 |
// allow the initial check for "can I run this SAR at all" |
| ... | ... |
@@ -52,7 +52,7 @@ func (a *testAuthorizer) Authorize(ctx kapi.Context, passedAttributes authorizer |
| 52 | 52 |
} |
| 53 | 53 |
return a.allowed, a.reason, errors.New(a.err) |
| 54 | 54 |
} |
| 55 |
-func (a *testAuthorizer) GetAllowedSubjects(ctx kapi.Context, passedAttributes authorizer.AuthorizationAttributes) (sets.String, sets.String, error) {
|
|
| 55 |
+func (a *testAuthorizer) GetAllowedSubjects(ctx kapi.Context, passedAttributes authorizer.Action) (sets.String, sets.String, error) {
|
|
| 56 | 56 |
return sets.String{}, sets.String{}, nil
|
| 57 | 57 |
} |
| 58 | 58 |
|
| ... | ... |
@@ -63,7 +63,7 @@ func TestNoNamespace(t *testing.T) {
|
| 63 | 63 |
err: "namespace is required on this type: ", |
| 64 | 64 |
}, |
| 65 | 65 |
reviewRequest: &authorizationapi.LocalSubjectAccessReview{
|
| 66 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 66 |
+ Action: authorizationapi.Action{
|
|
| 67 | 67 |
Namespace: "", |
| 68 | 68 |
Verb: "get", |
| 69 | 69 |
Resource: "pods", |
| ... | ... |
@@ -81,7 +81,7 @@ func TestConflictingNamespace(t *testing.T) {
|
| 81 | 81 |
allowed: false, |
| 82 | 82 |
} |
| 83 | 83 |
reviewRequest := &authorizationapi.LocalSubjectAccessReview{
|
| 84 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 84 |
+ Action: authorizationapi.Action{
|
|
| 85 | 85 |
Namespace: "foo", |
| 86 | 86 |
Verb: "get", |
| 87 | 87 |
Resource: "pods", |
| ... | ... |
@@ -108,7 +108,7 @@ func TestEmptyReturn(t *testing.T) {
|
| 108 | 108 |
reason: "because reasons", |
| 109 | 109 |
}, |
| 110 | 110 |
reviewRequest: &authorizationapi.LocalSubjectAccessReview{
|
| 111 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 111 |
+ Action: authorizationapi.Action{
|
|
| 112 | 112 |
Namespace: "unittest", |
| 113 | 113 |
Verb: "get", |
| 114 | 114 |
Resource: "pods", |
| ... | ... |
@@ -133,7 +133,7 @@ func TestNoErrors(t *testing.T) {
|
| 133 | 133 |
reason: "because good things", |
| 134 | 134 |
}, |
| 135 | 135 |
reviewRequest: &authorizationapi.LocalSubjectAccessReview{
|
| 136 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 136 |
+ Action: authorizationapi.Action{
|
|
| 137 | 137 |
Namespace: "unittest", |
| 138 | 138 |
Verb: "delete", |
| 139 | 139 |
Resource: "deploymentConfigs", |
| ... | ... |
@@ -156,7 +156,7 @@ func TestErrors(t *testing.T) {
|
| 156 | 156 |
err: "some-random-failure", |
| 157 | 157 |
}, |
| 158 | 158 |
reviewRequest: &authorizationapi.LocalSubjectAccessReview{
|
| 159 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 159 |
+ Action: authorizationapi.Action{
|
|
| 160 | 160 |
Namespace: "unittest", |
| 161 | 161 |
Verb: "get", |
| 162 | 162 |
Resource: "pods", |
| ... | ... |
@@ -176,7 +176,7 @@ func TestRegularWithScopes(t *testing.T) {
|
| 176 | 176 |
reason: "because good things", |
| 177 | 177 |
}, |
| 178 | 178 |
reviewRequest: &authorizationapi.LocalSubjectAccessReview{
|
| 179 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 179 |
+ Action: authorizationapi.Action{
|
|
| 180 | 180 |
Namespace: "unittest", |
| 181 | 181 |
Verb: "delete", |
| 182 | 182 |
Resource: "deploymentConfigs", |
| ... | ... |
@@ -205,7 +205,7 @@ func TestSelfWithDefaultScopes(t *testing.T) {
|
| 205 | 205 |
reason: "because good things", |
| 206 | 206 |
}, |
| 207 | 207 |
reviewRequest: &authorizationapi.LocalSubjectAccessReview{
|
| 208 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 208 |
+ Action: authorizationapi.Action{
|
|
| 209 | 209 |
Namespace: "unittest", |
| 210 | 210 |
Verb: "delete", |
| 211 | 211 |
Resource: "deploymentConfigs", |
| ... | ... |
@@ -233,7 +233,7 @@ func TestSelfWithClearedScopes(t *testing.T) {
|
| 233 | 233 |
reason: "because good things", |
| 234 | 234 |
}, |
| 235 | 235 |
reviewRequest: &authorizationapi.LocalSubjectAccessReview{
|
| 236 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 236 |
+ Action: authorizationapi.Action{
|
|
| 237 | 237 |
Namespace: "unittest", |
| 238 | 238 |
Verb: "delete", |
| 239 | 239 |
Resource: "deploymentConfigs", |
| ... | ... |
@@ -27,7 +27,7 @@ type testAuthorizer struct {
|
| 27 | 27 |
actualAttributes authorizer.DefaultAuthorizationAttributes |
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 |
-func (a *testAuthorizer) Authorize(ctx kapi.Context, attributes authorizer.AuthorizationAttributes) (allowed bool, reason string, err error) {
|
|
| 30 |
+func (a *testAuthorizer) Authorize(ctx kapi.Context, attributes authorizer.Action) (allowed bool, reason string, err error) {
|
|
| 31 | 31 |
// allow the initial check for "can I run this RAR at all" |
| 32 | 32 |
if attributes.GetResource() == "localresourceaccessreviews" {
|
| 33 | 33 |
if len(a.deniedNamespaces) != 0 && a.deniedNamespaces.Has(kapi.NamespaceValue(ctx)) {
|
| ... | ... |
@@ -39,7 +39,7 @@ func (a *testAuthorizer) Authorize(ctx kapi.Context, attributes authorizer.Autho |
| 39 | 39 |
|
| 40 | 40 |
return false, "", errors.New("unsupported")
|
| 41 | 41 |
} |
| 42 |
-func (a *testAuthorizer) GetAllowedSubjects(ctx kapi.Context, passedAttributes authorizer.AuthorizationAttributes) (sets.String, sets.String, error) {
|
|
| 42 |
+func (a *testAuthorizer) GetAllowedSubjects(ctx kapi.Context, passedAttributes authorizer.Action) (sets.String, sets.String, error) {
|
|
| 43 | 43 |
attributes, ok := passedAttributes.(authorizer.DefaultAuthorizationAttributes) |
| 44 | 44 |
if !ok {
|
| 45 | 45 |
return nil, nil, errors.New("unexpected type for test")
|
| ... | ... |
@@ -61,7 +61,7 @@ func TestDeniedNamespace(t *testing.T) {
|
| 61 | 61 |
deniedNamespaces: sets.NewString("foo"),
|
| 62 | 62 |
}, |
| 63 | 63 |
reviewRequest: &authorizationapi.ResourceAccessReview{
|
| 64 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 64 |
+ Action: authorizationapi.Action{
|
|
| 65 | 65 |
Namespace: "foo", |
| 66 | 66 |
Verb: "get", |
| 67 | 67 |
Resource: "pods", |
| ... | ... |
@@ -79,7 +79,7 @@ func TestEmptyReturn(t *testing.T) {
|
| 79 | 79 |
groups: sets.String{},
|
| 80 | 80 |
}, |
| 81 | 81 |
reviewRequest: &authorizationapi.ResourceAccessReview{
|
| 82 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 82 |
+ Action: authorizationapi.Action{
|
|
| 83 | 83 |
Verb: "get", |
| 84 | 84 |
Resource: "pods", |
| 85 | 85 |
}, |
| ... | ... |
@@ -96,7 +96,7 @@ func TestNoErrors(t *testing.T) {
|
| 96 | 96 |
groups: sets.NewString("three", "four"),
|
| 97 | 97 |
}, |
| 98 | 98 |
reviewRequest: &authorizationapi.ResourceAccessReview{
|
| 99 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 99 |
+ Action: authorizationapi.Action{
|
|
| 100 | 100 |
Verb: "delete", |
| 101 | 101 |
Resource: "deploymentConfig", |
| 102 | 102 |
}, |
| ... | ... |
@@ -32,7 +32,7 @@ type testAuthorizer struct {
|
| 32 | 32 |
actualUserInfo user.Info |
| 33 | 33 |
} |
| 34 | 34 |
|
| 35 |
-func (a *testAuthorizer) Authorize(ctx kapi.Context, passedAttributes authorizer.AuthorizationAttributes) (allowed bool, reason string, err error) {
|
|
| 35 |
+func (a *testAuthorizer) Authorize(ctx kapi.Context, passedAttributes authorizer.Action) (allowed bool, reason string, err error) {
|
|
| 36 | 36 |
a.actualUserInfo, _ = kapi.UserFrom(ctx) |
| 37 | 37 |
|
| 38 | 38 |
// allow the initial check for "can I run this SAR at all" |
| ... | ... |
@@ -56,7 +56,7 @@ func (a *testAuthorizer) Authorize(ctx kapi.Context, passedAttributes authorizer |
| 56 | 56 |
} |
| 57 | 57 |
return a.allowed, a.reason, errors.New(a.err) |
| 58 | 58 |
} |
| 59 |
-func (a *testAuthorizer) GetAllowedSubjects(ctx kapi.Context, passedAttributes authorizer.AuthorizationAttributes) (sets.String, sets.String, error) {
|
|
| 59 |
+func (a *testAuthorizer) GetAllowedSubjects(ctx kapi.Context, passedAttributes authorizer.Action) (sets.String, sets.String, error) {
|
|
| 60 | 60 |
return sets.String{}, sets.String{}, nil
|
| 61 | 61 |
} |
| 62 | 62 |
|
| ... | ... |
@@ -68,7 +68,7 @@ func TestDeniedNamespace(t *testing.T) {
|
| 68 | 68 |
deniedNamespaces: sets.NewString("foo"),
|
| 69 | 69 |
}, |
| 70 | 70 |
reviewRequest: &authorizationapi.SubjectAccessReview{
|
| 71 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 71 |
+ Action: authorizationapi.Action{
|
|
| 72 | 72 |
Namespace: "foo", |
| 73 | 73 |
Verb: "get", |
| 74 | 74 |
Resource: "pods", |
| ... | ... |
@@ -88,7 +88,7 @@ func TestEmptyReturn(t *testing.T) {
|
| 88 | 88 |
reason: "because reasons", |
| 89 | 89 |
}, |
| 90 | 90 |
reviewRequest: &authorizationapi.SubjectAccessReview{
|
| 91 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 91 |
+ Action: authorizationapi.Action{
|
|
| 92 | 92 |
Verb: "get", |
| 93 | 93 |
Resource: "pods", |
| 94 | 94 |
}, |
| ... | ... |
@@ -112,7 +112,7 @@ func TestNoErrors(t *testing.T) {
|
| 112 | 112 |
reason: "because good things", |
| 113 | 113 |
}, |
| 114 | 114 |
reviewRequest: &authorizationapi.SubjectAccessReview{
|
| 115 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 115 |
+ Action: authorizationapi.Action{
|
|
| 116 | 116 |
Verb: "delete", |
| 117 | 117 |
Resource: "deploymentConfigs", |
| 118 | 118 |
}, |
| ... | ... |
@@ -134,7 +134,7 @@ func TestErrors(t *testing.T) {
|
| 134 | 134 |
err: "some-random-failure", |
| 135 | 135 |
}, |
| 136 | 136 |
reviewRequest: &authorizationapi.SubjectAccessReview{
|
| 137 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 137 |
+ Action: authorizationapi.Action{
|
|
| 138 | 138 |
Verb: "get", |
| 139 | 139 |
Resource: "pods", |
| 140 | 140 |
}, |
| ... | ... |
@@ -153,7 +153,7 @@ func TestRegularWithScopes(t *testing.T) {
|
| 153 | 153 |
reason: "because good things", |
| 154 | 154 |
}, |
| 155 | 155 |
reviewRequest: &authorizationapi.SubjectAccessReview{
|
| 156 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 156 |
+ Action: authorizationapi.Action{
|
|
| 157 | 157 |
Verb: "delete", |
| 158 | 158 |
Resource: "deploymentConfigs", |
| 159 | 159 |
}, |
| ... | ... |
@@ -181,7 +181,7 @@ func TestSelfWithDefaultScopes(t *testing.T) {
|
| 181 | 181 |
reason: "because good things", |
| 182 | 182 |
}, |
| 183 | 183 |
reviewRequest: &authorizationapi.SubjectAccessReview{
|
| 184 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 184 |
+ Action: authorizationapi.Action{
|
|
| 185 | 185 |
Verb: "delete", |
| 186 | 186 |
Resource: "deploymentConfigs", |
| 187 | 187 |
}, |
| ... | ... |
@@ -208,7 +208,7 @@ func TestSelfWithClearedScopes(t *testing.T) {
|
| 208 | 208 |
reason: "because good things", |
| 209 | 209 |
}, |
| 210 | 210 |
reviewRequest: &authorizationapi.SubjectAccessReview{
|
| 211 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 211 |
+ Action: authorizationapi.Action{
|
|
| 212 | 212 |
Verb: "delete", |
| 213 | 213 |
Resource: "deploymentConfigs", |
| 214 | 214 |
}, |
| ... | ... |
@@ -104,7 +104,7 @@ func (a *buildByStrategy) checkBuildAuthorization(build *buildapi.Build, attr ad |
| 104 | 104 |
} |
| 105 | 105 |
subjectAccessReview := authorizationapi.AddUserToLSAR(attr.GetUserInfo(), |
| 106 | 106 |
&authorizationapi.LocalSubjectAccessReview{
|
| 107 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 107 |
+ Action: authorizationapi.Action{
|
|
| 108 | 108 |
Verb: "create", |
| 109 | 109 |
Group: resource.Group, |
| 110 | 110 |
Resource: resource.Resource, |
| ... | ... |
@@ -123,7 +123,7 @@ func (a *buildByStrategy) checkBuildConfigAuthorization(buildConfig *buildapi.Bu |
| 123 | 123 |
} |
| 124 | 124 |
subjectAccessReview := authorizationapi.AddUserToLSAR(attr.GetUserInfo(), |
| 125 | 125 |
&authorizationapi.LocalSubjectAccessReview{
|
| 126 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 126 |
+ Action: authorizationapi.Action{
|
|
| 127 | 127 |
Verb: "create", |
| 128 | 128 |
Group: resource.Group, |
| 129 | 129 |
Resource: resource.Resource, |
| ... | ... |
@@ -117,7 +117,7 @@ func (o DiagnosticsOptions) makeClusterClients(rawConfig *clientcmdapi.Config, c |
| 117 | 117 |
o.Logger.Debug("CED1006", fmt.Sprintf("Error creating client for context '%s':\n%v", contextName, err))
|
| 118 | 118 |
return nil, nil, false, "", nil |
| 119 | 119 |
} else {
|
| 120 |
- subjectAccessReview := authorizationapi.SubjectAccessReview{Action: authorizationapi.AuthorizationAttributes{
|
|
| 120 |
+ subjectAccessReview := authorizationapi.SubjectAccessReview{Action: authorizationapi.Action{
|
|
| 121 | 121 |
// if you can do everything, you're the cluster admin. |
| 122 | 122 |
Verb: "*", |
| 123 | 123 |
Group: "*", |
| ... | ... |
@@ -139,7 +139,7 @@ func (o *canIOptions) Run() (bool, error) {
|
| 139 | 139 |
} |
| 140 | 140 |
|
| 141 | 141 |
sar := &authorizationapi.SubjectAccessReview{
|
| 142 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 142 |
+ Action: authorizationapi.Action{
|
|
| 143 | 143 |
Namespace: o.Namespace, |
| 144 | 144 |
Verb: o.Verb, |
| 145 | 145 |
Group: o.Resource.Group, |
| ... | ... |
@@ -94,7 +94,7 @@ func resourceFor(mapper meta.RESTMapper, resourceArg string) unversioned.GroupVe |
| 94 | 94 |
} |
| 95 | 95 |
|
| 96 | 96 |
func (o *whoCanOptions) run() error {
|
| 97 |
- authorizationAttributes := authorizationapi.AuthorizationAttributes{
|
|
| 97 |
+ authorizationAttributes := authorizationapi.Action{
|
|
| 98 | 98 |
Verb: o.verb, |
| 99 | 99 |
Group: o.resource.Group, |
| 100 | 100 |
Resource: o.resource.Resource, |
| ... | ... |
@@ -232,7 +232,7 @@ func (c *MasterConfig) ensureComponentAuthorizationRules() {
|
| 232 | 232 |
} |
| 233 | 233 |
|
| 234 | 234 |
// Wait until the policy cache has caught up before continuing |
| 235 |
- review := &authorizationapi.SubjectAccessReview{Action: authorizationapi.AuthorizationAttributes{Verb: "get", Group: authorizationapi.GroupName, Resource: "clusterpolicies"}}
|
|
| 235 |
+ review := &authorizationapi.SubjectAccessReview{Action: authorizationapi.Action{Verb: "get", Group: authorizationapi.GroupName, Resource: "clusterpolicies"}}
|
|
| 236 | 236 |
err = wait.PollImmediate(100*time.Millisecond, 30*time.Second, func() (done bool, err error) {
|
| 237 | 237 |
result, err := c.PolicyClient().SubjectAccessReviews().Create(review) |
| 238 | 238 |
if err == nil && result.Allowed {
|
| ... | ... |
@@ -105,7 +105,7 @@ func (c *MasterConfig) authorizationFilter(handler http.Handler) http.Handler {
|
| 105 | 105 |
} |
| 106 | 106 |
|
| 107 | 107 |
// forbidden renders a simple forbidden error |
| 108 |
-func forbidden(reason string, attributes authorizer.AuthorizationAttributes, w http.ResponseWriter, req *http.Request) {
|
|
| 108 |
+func forbidden(reason string, attributes authorizer.Action, w http.ResponseWriter, req *http.Request) {
|
|
| 109 | 109 |
kind := "" |
| 110 | 110 |
resource := "" |
| 111 | 111 |
group := "" |
| ... | ... |
@@ -24,7 +24,7 @@ import ( |
| 24 | 24 |
|
| 25 | 25 |
type impersonateAuthorizer struct{}
|
| 26 | 26 |
|
| 27 |
-func (impersonateAuthorizer) Authorize(ctx kapi.Context, a authorizer.AuthorizationAttributes) (allowed bool, reason string, err error) {
|
|
| 27 |
+func (impersonateAuthorizer) Authorize(ctx kapi.Context, a authorizer.Action) (allowed bool, reason string, err error) {
|
|
| 28 | 28 |
user, exists := kapi.UserFrom(ctx) |
| 29 | 29 |
if !exists {
|
| 30 | 30 |
return false, "missing user", nil |
| ... | ... |
@@ -63,7 +63,7 @@ func (impersonateAuthorizer) Authorize(ctx kapi.Context, a authorizer.Authorizat |
| 63 | 63 |
return false, "deny by default", nil |
| 64 | 64 |
} |
| 65 | 65 |
|
| 66 |
-func (impersonateAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes authorizer.AuthorizationAttributes) (sets.String, sets.String, error) {
|
|
| 66 |
+func (impersonateAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes authorizer.Action) (sets.String, sets.String, error) {
|
|
| 67 | 67 |
return nil, nil, nil |
| 68 | 68 |
} |
| 69 | 69 |
|
| ... | ... |
@@ -77,7 +77,7 @@ func (d *MasterNode) CanRun() (bool, error) {
|
| 77 | 77 |
} |
| 78 | 78 |
} |
| 79 | 79 |
|
| 80 |
- can, err := userCan(d.OsClient, authorizationapi.AuthorizationAttributes{
|
|
| 80 |
+ can, err := userCan(d.OsClient, authorizationapi.Action{
|
|
| 81 | 81 |
Verb: "list", |
| 82 | 82 |
Group: kapi.GroupName, |
| 83 | 83 |
Resource: "nodes", |
| ... | ... |
@@ -65,7 +65,7 @@ func (d *NodeDefinitions) CanRun() (bool, error) {
|
| 65 | 65 |
if d.KubeClient == nil || d.OsClient == nil {
|
| 66 | 66 |
return false, errors.New("must have kube and os client")
|
| 67 | 67 |
} |
| 68 |
- can, err := userCan(d.OsClient, authorizationapi.AuthorizationAttributes{
|
|
| 68 |
+ can, err := userCan(d.OsClient, authorizationapi.Action{
|
|
| 69 | 69 |
Verb: "list", |
| 70 | 70 |
Group: kapi.GroupName, |
| 71 | 71 |
Resource: "nodes", |
| ... | ... |
@@ -156,7 +156,7 @@ func (d *ClusterRegistry) CanRun() (bool, error) {
|
| 156 | 156 |
if d.OsClient == nil || d.KubeClient == nil {
|
| 157 | 157 |
return false, fmt.Errorf("must have kube and os clients")
|
| 158 | 158 |
} |
| 159 |
- return userCan(d.OsClient, authorizationapi.AuthorizationAttributes{
|
|
| 159 |
+ return userCan(d.OsClient, authorizationapi.Action{
|
|
| 160 | 160 |
Namespace: kapi.NamespaceDefault, |
| 161 | 161 |
Verb: "get", |
| 162 | 162 |
Group: kapi.GroupName, |
| ... | ... |
@@ -38,7 +38,7 @@ func (d *ClusterRoleBindings) CanRun() (bool, error) {
|
| 38 | 38 |
return false, fmt.Errorf("must have client.SubjectAccessReviews")
|
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 |
- return userCan(d.SARClient, authorizationapi.AuthorizationAttributes{
|
|
| 41 |
+ return userCan(d.SARClient, authorizationapi.Action{
|
|
| 42 | 42 |
Verb: "list", |
| 43 | 43 |
Group: authorizationapi.GroupName, |
| 44 | 44 |
Resource: "clusterrolebindings", |
| ... | ... |
@@ -39,7 +39,7 @@ func (d *ClusterRoles) CanRun() (bool, error) {
|
| 39 | 39 |
return false, fmt.Errorf("must have client.SubjectAccessReviews")
|
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 |
- return userCan(d.SARClient, authorizationapi.AuthorizationAttributes{
|
|
| 42 |
+ return userCan(d.SARClient, authorizationapi.Action{
|
|
| 43 | 43 |
Verb: "list", |
| 44 | 44 |
Group: authorizationapi.GroupName, |
| 45 | 45 |
Resource: "clusterroles", |
| ... | ... |
@@ -94,7 +94,7 @@ func (d *ClusterRouter) CanRun() (bool, error) {
|
| 94 | 94 |
if d.KubeClient == nil || d.OsClient == nil {
|
| 95 | 95 |
return false, errors.New("must have kube and os client")
|
| 96 | 96 |
} |
| 97 |
- can, err := userCan(d.OsClient, authorizationapi.AuthorizationAttributes{
|
|
| 97 |
+ can, err := userCan(d.OsClient, authorizationapi.Action{
|
|
| 98 | 98 |
Namespace: kapi.NamespaceDefault, |
| 99 | 99 |
Verb: "get", |
| 100 | 100 |
Group: deployapi.GroupName, |
| ... | ... |
@@ -5,7 +5,7 @@ import ( |
| 5 | 5 |
osclient "github.com/openshift/origin/pkg/client" |
| 6 | 6 |
) |
| 7 | 7 |
|
| 8 |
-func userCan(sarClient osclient.SubjectAccessReviews, action authorizationapi.AuthorizationAttributes) (bool, error) {
|
|
| 8 |
+func userCan(sarClient osclient.SubjectAccessReviews, action authorizationapi.Action) (bool, error) {
|
|
| 9 | 9 |
resp, err := sarClient.SubjectAccessReviews().Create(&authorizationapi.SubjectAccessReview{Action: action})
|
| 10 | 10 |
if err != nil {
|
| 11 | 11 |
return false, err |
| ... | ... |
@@ -388,7 +388,7 @@ func verifyOpenShiftUser(ctx context.Context, client client.UsersInterface) erro |
| 388 | 388 |
|
| 389 | 389 |
func verifyImageStreamAccess(ctx context.Context, namespace, imageRepo, verb string, client client.LocalSubjectAccessReviewsNamespacer) error {
|
| 390 | 390 |
sar := authorizationapi.LocalSubjectAccessReview{
|
| 391 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 391 |
+ Action: authorizationapi.Action{
|
|
| 392 | 392 |
Verb: verb, |
| 393 | 393 |
Group: imageapi.GroupName, |
| 394 | 394 |
Resource: "imagestreams/layers", |
| ... | ... |
@@ -415,7 +415,7 @@ func verifyImageStreamAccess(ctx context.Context, namespace, imageRepo, verb str |
| 415 | 415 |
|
| 416 | 416 |
func verifyPruneAccess(ctx context.Context, client client.SubjectAccessReviews) error {
|
| 417 | 417 |
sar := authorizationapi.SubjectAccessReview{
|
| 418 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 418 |
+ Action: authorizationapi.Action{
|
|
| 419 | 419 |
Verb: "delete", |
| 420 | 420 |
Group: imageapi.GroupName, |
| 421 | 421 |
Resource: "images", |
| ... | ... |
@@ -238,7 +238,7 @@ func NewEnvironmentConfig() (*Config, error) {
|
| 238 | 238 |
return true, nil |
| 239 | 239 |
} |
| 240 | 240 |
req := &authapi.LocalSubjectAccessReview{
|
| 241 |
- Action: authapi.AuthorizationAttributes{
|
|
| 241 |
+ Action: authapi.Action{
|
|
| 242 | 242 |
Verb: "get", |
| 243 | 243 |
Group: kapi.GroupName, |
| 244 | 244 |
Resource: "pods", |
| ... | ... |
@@ -434,7 +434,7 @@ func (v *TagVerifier) Verify(old, stream *api.ImageStream, user user.Info) field |
| 434 | 434 |
} |
| 435 | 435 |
|
| 436 | 436 |
subjectAccessReview := authorizationapi.SubjectAccessReview{
|
| 437 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 437 |
+ Action: authorizationapi.Action{
|
|
| 438 | 438 |
Verb: "get", |
| 439 | 439 |
Group: api.GroupName, |
| 440 | 440 |
Resource: "imagestreams", |
| ... | ... |
@@ -309,7 +309,7 @@ func TestTagVerifier(t *testing.T) {
|
| 309 | 309 |
t.Errorf("%s: sar namespace: expected %v, got %v", name, e, a)
|
| 310 | 310 |
} |
| 311 | 311 |
expectedSar := &authorizationapi.SubjectAccessReview{
|
| 312 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 312 |
+ Action: authorizationapi.Action{
|
|
| 313 | 313 |
Verb: "get", |
| 314 | 314 |
Resource: "imagestreams", |
| 315 | 315 |
ResourceName: "otherstream", |
| ... | ... |
@@ -62,7 +62,7 @@ func NewReviewer(resourceAccessReviewsNamespacer client.LocalResourceAccessRevie |
| 62 | 62 |
// Review performs a resource access review for the given resource by name |
| 63 | 63 |
func (r *reviewer) Review(name string) (Review, error) {
|
| 64 | 64 |
resourceAccessReview := &authorizationapi.LocalResourceAccessReview{
|
| 65 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 65 |
+ Action: authorizationapi.Action{
|
|
| 66 | 66 |
Verb: "get", |
| 67 | 67 |
Group: kapi.GroupName, |
| 68 | 68 |
Resource: "namespaces", |
| ... | ... |
@@ -204,7 +204,7 @@ func (r *REST) List(ctx kapi.Context, options *kapi.ListOptions) (runtime.Object |
| 204 | 204 |
// So we'll escalate for the subject access review to determine rights |
| 205 | 205 |
accessReview := authorizationapi.AddUserToSAR(userInfo, |
| 206 | 206 |
&authorizationapi.SubjectAccessReview{
|
| 207 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 207 |
+ Action: authorizationapi.Action{
|
|
| 208 | 208 |
Verb: "create", |
| 209 | 209 |
Group: projectapi.GroupName, |
| 210 | 210 |
Resource: "projectrequests", |
| ... | ... |
@@ -430,7 +430,7 @@ func fakeAuthorizer(t *testing.T) authorizer.Authorizer {
|
| 430 | 430 |
} |
| 431 | 431 |
} |
| 432 | 432 |
|
| 433 |
-func (a *fakeTestAuthorizer) Authorize(ctx kapi.Context, passedAttributes authorizer.AuthorizationAttributes) (bool, string, error) {
|
|
| 433 |
+func (a *fakeTestAuthorizer) Authorize(ctx kapi.Context, passedAttributes authorizer.Action) (bool, string, error) {
|
|
| 434 | 434 |
a.t.Logf("Authorize: ctx: %#v", ctx)
|
| 435 | 435 |
ui, ok := kapi.UserFrom(ctx) |
| 436 | 436 |
if !ok {
|
| ... | ... |
@@ -444,7 +444,7 @@ func (a *fakeTestAuthorizer) Authorize(ctx kapi.Context, passedAttributes author |
| 444 | 444 |
return false, "", nil |
| 445 | 445 |
} |
| 446 | 446 |
|
| 447 |
-func (a *fakeTestAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes authorizer.AuthorizationAttributes) (sets.String, sets.String, error) {
|
|
| 447 |
+func (a *fakeTestAuthorizer) GetAllowedSubjects(ctx kapi.Context, attributes authorizer.Action) (sets.String, sets.String, error) {
|
|
| 448 | 448 |
return nil, nil, nil |
| 449 | 449 |
} |
| 450 | 450 |
|
| ... | ... |
@@ -432,11 +432,11 @@ func TestAuthorizationResourceAccessReview(t *testing.T) {
|
| 432 | 432 |
} |
| 433 | 433 |
|
| 434 | 434 |
requestWhoCanViewDeploymentConfigs := &authorizationapi.ResourceAccessReview{
|
| 435 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "get", Resource: "deploymentconfigs"},
|
|
| 435 |
+ Action: authorizationapi.Action{Verb: "get", Resource: "deploymentconfigs"},
|
|
| 436 | 436 |
} |
| 437 | 437 |
|
| 438 | 438 |
localRequestWhoCanViewDeploymentConfigs := &authorizationapi.LocalResourceAccessReview{
|
| 439 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "get", Resource: "deploymentconfigs"},
|
|
| 439 |
+ Action: authorizationapi.Action{Verb: "get", Resource: "deploymentconfigs"},
|
|
| 440 | 440 |
} |
| 441 | 441 |
|
| 442 | 442 |
{
|
| ... | ... |
@@ -607,7 +607,7 @@ func TestAuthorizationSubjectAccessReviewAPIGroup(t *testing.T) {
|
| 607 | 607 |
localInterface: clusterAdminClient.LocalSubjectAccessReviews("hammer-project"),
|
| 608 | 608 |
localReview: &authorizationapi.LocalSubjectAccessReview{
|
| 609 | 609 |
User: "harold", |
| 610 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "get", Group: "extensions", Resource: "horizontalpodautoscalers"},
|
|
| 610 |
+ Action: authorizationapi.Action{Verb: "get", Group: "extensions", Resource: "horizontalpodautoscalers"},
|
|
| 611 | 611 |
}, |
| 612 | 612 |
response: authorizationapi.SubjectAccessReviewResponse{
|
| 613 | 613 |
Allowed: true, |
| ... | ... |
@@ -620,7 +620,7 @@ func TestAuthorizationSubjectAccessReviewAPIGroup(t *testing.T) {
|
| 620 | 620 |
localInterface: clusterAdminClient.LocalSubjectAccessReviews("hammer-project"),
|
| 621 | 621 |
localReview: &authorizationapi.LocalSubjectAccessReview{
|
| 622 | 622 |
User: "harold", |
| 623 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "get", Group: "", Resource: "horizontalpodautoscalers"},
|
|
| 623 |
+ Action: authorizationapi.Action{Verb: "get", Group: "", Resource: "horizontalpodautoscalers"},
|
|
| 624 | 624 |
}, |
| 625 | 625 |
response: authorizationapi.SubjectAccessReviewResponse{
|
| 626 | 626 |
Allowed: false, |
| ... | ... |
@@ -633,7 +633,7 @@ func TestAuthorizationSubjectAccessReviewAPIGroup(t *testing.T) {
|
| 633 | 633 |
localInterface: clusterAdminClient.LocalSubjectAccessReviews("hammer-project"),
|
| 634 | 634 |
localReview: &authorizationapi.LocalSubjectAccessReview{
|
| 635 | 635 |
User: "harold", |
| 636 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "get", Group: "foo", Resource: "horizontalpodautoscalers"},
|
|
| 636 |
+ Action: authorizationapi.Action{Verb: "get", Group: "foo", Resource: "horizontalpodautoscalers"},
|
|
| 637 | 637 |
}, |
| 638 | 638 |
response: authorizationapi.SubjectAccessReviewResponse{
|
| 639 | 639 |
Allowed: false, |
| ... | ... |
@@ -646,7 +646,7 @@ func TestAuthorizationSubjectAccessReviewAPIGroup(t *testing.T) {
|
| 646 | 646 |
localInterface: clusterAdminClient.LocalSubjectAccessReviews("hammer-project"),
|
| 647 | 647 |
localReview: &authorizationapi.LocalSubjectAccessReview{
|
| 648 | 648 |
User: "harold", |
| 649 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "get", Group: "*", Resource: "horizontalpodautoscalers"},
|
|
| 649 |
+ Action: authorizationapi.Action{Verb: "get", Group: "*", Resource: "horizontalpodautoscalers"},
|
|
| 650 | 650 |
}, |
| 651 | 651 |
response: authorizationapi.SubjectAccessReviewResponse{
|
| 652 | 652 |
Allowed: false, |
| ... | ... |
@@ -660,7 +660,7 @@ func TestAuthorizationSubjectAccessReviewAPIGroup(t *testing.T) {
|
| 660 | 660 |
description: "cluster admin told they can get extensions.horizontalpodautoscalers in project hammer-project", |
| 661 | 661 |
localInterface: clusterAdminClient.LocalSubjectAccessReviews("any-project"),
|
| 662 | 662 |
localReview: &authorizationapi.LocalSubjectAccessReview{
|
| 663 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "get", Group: "extensions", Resource: "horizontalpodautoscalers"},
|
|
| 663 |
+ Action: authorizationapi.Action{Verb: "get", Group: "extensions", Resource: "horizontalpodautoscalers"},
|
|
| 664 | 664 |
}, |
| 665 | 665 |
response: authorizationapi.SubjectAccessReviewResponse{
|
| 666 | 666 |
Allowed: true, |
| ... | ... |
@@ -672,7 +672,7 @@ func TestAuthorizationSubjectAccessReviewAPIGroup(t *testing.T) {
|
| 672 | 672 |
description: "cluster admin told they can get horizontalpodautoscalers (with no API group) in project any-project", |
| 673 | 673 |
localInterface: clusterAdminClient.LocalSubjectAccessReviews("any-project"),
|
| 674 | 674 |
localReview: &authorizationapi.LocalSubjectAccessReview{
|
| 675 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "get", Group: "", Resource: "horizontalpodautoscalers"},
|
|
| 675 |
+ Action: authorizationapi.Action{Verb: "get", Group: "", Resource: "horizontalpodautoscalers"},
|
|
| 676 | 676 |
}, |
| 677 | 677 |
response: authorizationapi.SubjectAccessReviewResponse{
|
| 678 | 678 |
Allowed: true, |
| ... | ... |
@@ -684,7 +684,7 @@ func TestAuthorizationSubjectAccessReviewAPIGroup(t *testing.T) {
|
| 684 | 684 |
description: "cluster admin told they can get horizontalpodautoscalers (with invalid API group) in project any-project", |
| 685 | 685 |
localInterface: clusterAdminClient.LocalSubjectAccessReviews("any-project"),
|
| 686 | 686 |
localReview: &authorizationapi.LocalSubjectAccessReview{
|
| 687 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "get", Group: "foo", Resource: "horizontalpodautoscalers"},
|
|
| 687 |
+ Action: authorizationapi.Action{Verb: "get", Group: "foo", Resource: "horizontalpodautoscalers"},
|
|
| 688 | 688 |
}, |
| 689 | 689 |
response: authorizationapi.SubjectAccessReviewResponse{
|
| 690 | 690 |
Allowed: true, |
| ... | ... |
@@ -696,7 +696,7 @@ func TestAuthorizationSubjectAccessReviewAPIGroup(t *testing.T) {
|
| 696 | 696 |
description: "cluster admin told they can get horizontalpodautoscalers (with * API group) in project any-project", |
| 697 | 697 |
localInterface: clusterAdminClient.LocalSubjectAccessReviews("any-project"),
|
| 698 | 698 |
localReview: &authorizationapi.LocalSubjectAccessReview{
|
| 699 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "get", Group: "*", Resource: "horizontalpodautoscalers"},
|
|
| 699 |
+ Action: authorizationapi.Action{Verb: "get", Group: "*", Resource: "horizontalpodautoscalers"},
|
|
| 700 | 700 |
}, |
| 701 | 701 |
response: authorizationapi.SubjectAccessReviewResponse{
|
| 702 | 702 |
Allowed: true, |
| ... | ... |
@@ -767,14 +767,14 @@ func TestAuthorizationSubjectAccessReview(t *testing.T) {
|
| 767 | 767 |
} |
| 768 | 768 |
askCanDannyGetProject := &authorizationapi.SubjectAccessReview{
|
| 769 | 769 |
User: "danny", |
| 770 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "get", Resource: "projects"},
|
|
| 770 |
+ Action: authorizationapi.Action{Verb: "get", Resource: "projects"},
|
|
| 771 | 771 |
} |
| 772 | 772 |
subjectAccessReviewTest{
|
| 773 | 773 |
description: "cluster admin told danny can get project default", |
| 774 | 774 |
localInterface: clusterAdminClient.LocalSubjectAccessReviews("default"),
|
| 775 | 775 |
localReview: &authorizationapi.LocalSubjectAccessReview{
|
| 776 | 776 |
User: "danny", |
| 777 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "get", Resource: "projects"},
|
|
| 777 |
+ Action: authorizationapi.Action{Verb: "get", Resource: "projects"},
|
|
| 778 | 778 |
}, |
| 779 | 779 |
response: authorizationapi.SubjectAccessReviewResponse{
|
| 780 | 780 |
Allowed: true, |
| ... | ... |
@@ -827,7 +827,7 @@ func TestAuthorizationSubjectAccessReview(t *testing.T) {
|
| 827 | 827 |
|
| 828 | 828 |
askCanValerieGetProject := &authorizationapi.LocalSubjectAccessReview{
|
| 829 | 829 |
User: "valerie", |
| 830 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "get", Resource: "projects"},
|
|
| 830 |
+ Action: authorizationapi.Action{Verb: "get", Resource: "projects"},
|
|
| 831 | 831 |
} |
| 832 | 832 |
subjectAccessReviewTest{
|
| 833 | 833 |
description: "harold told valerie can get project hammer-project", |
| ... | ... |
@@ -852,7 +852,7 @@ func TestAuthorizationSubjectAccessReview(t *testing.T) {
|
| 852 | 852 |
|
| 853 | 853 |
askCanEdgarDeletePods := &authorizationapi.LocalSubjectAccessReview{
|
| 854 | 854 |
User: "edgar", |
| 855 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "delete", Resource: "pods"},
|
|
| 855 |
+ Action: authorizationapi.Action{Verb: "delete", Resource: "pods"},
|
|
| 856 | 856 |
} |
| 857 | 857 |
subjectAccessReviewTest{
|
| 858 | 858 |
description: "mark told edgar can delete pods in mallet-project", |
| ... | ... |
@@ -893,7 +893,7 @@ func TestAuthorizationSubjectAccessReview(t *testing.T) {
|
| 893 | 893 |
|
| 894 | 894 |
askCanHaroldUpdateProject := &authorizationapi.LocalSubjectAccessReview{
|
| 895 | 895 |
User: "harold", |
| 896 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "update", Resource: "projects"},
|
|
| 896 |
+ Action: authorizationapi.Action{Verb: "update", Resource: "projects"},
|
|
| 897 | 897 |
} |
| 898 | 898 |
subjectAccessReviewTest{
|
| 899 | 899 |
description: "harold told harold can update project hammer-project", |
| ... | ... |
@@ -908,7 +908,7 @@ func TestAuthorizationSubjectAccessReview(t *testing.T) {
|
| 908 | 908 |
|
| 909 | 909 |
askCanClusterAdminsCreateProject := &authorizationapi.SubjectAccessReview{
|
| 910 | 910 |
Groups: sets.NewString("system:cluster-admins"),
|
| 911 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "create", Resource: "projects"},
|
|
| 911 |
+ Action: authorizationapi.Action{Verb: "create", Resource: "projects"},
|
|
| 912 | 912 |
} |
| 913 | 913 |
subjectAccessReviewTest{
|
| 914 | 914 |
description: "cluster admin told cluster admins can create projects", |
| ... | ... |
@@ -928,7 +928,7 @@ func TestAuthorizationSubjectAccessReview(t *testing.T) {
|
| 928 | 928 |
}.run(t) |
| 929 | 929 |
|
| 930 | 930 |
askCanICreatePods := &authorizationapi.LocalSubjectAccessReview{
|
| 931 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "create", Resource: "pods"},
|
|
| 931 |
+ Action: authorizationapi.Action{Verb: "create", Resource: "pods"},
|
|
| 932 | 932 |
} |
| 933 | 933 |
subjectAccessReviewTest{
|
| 934 | 934 |
description: "harold told he can create pods in project hammer-project", |
| ... | ... |
@@ -996,7 +996,7 @@ func TestAuthorizationSubjectAccessReview(t *testing.T) {
|
| 996 | 996 |
}.run(t) |
| 997 | 997 |
|
| 998 | 998 |
askCanICreatePolicyBindings := &authorizationapi.LocalSubjectAccessReview{
|
| 999 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "create", Resource: "policybindings"},
|
|
| 999 |
+ Action: authorizationapi.Action{Verb: "create", Resource: "policybindings"},
|
|
| 1000 | 1000 |
} |
| 1001 | 1001 |
subjectAccessReviewTest{
|
| 1002 | 1002 |
description: "harold told he can create policybindings in project hammer-project", |
| ... | ... |
@@ -1037,7 +1037,7 @@ func TestAuthorizationSubjectAccessReview(t *testing.T) {
|
| 1037 | 1037 |
description: "empty token impersonate can't see pods in namespace", |
| 1038 | 1038 |
localInterface: otherAdminClient.ImpersonateLocalSubjectAccessReviews("hammer-project", ""),
|
| 1039 | 1039 |
localReview: &authorizationapi.LocalSubjectAccessReview{
|
| 1040 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "list", Resource: "pods"},
|
|
| 1040 |
+ Action: authorizationapi.Action{Verb: "list", Resource: "pods"},
|
|
| 1041 | 1041 |
}, |
| 1042 | 1042 |
err: `impersonating token may not be empty`, |
| 1043 | 1043 |
}.run(t) |
| ... | ... |
@@ -1045,7 +1045,7 @@ func TestAuthorizationSubjectAccessReview(t *testing.T) {
|
| 1045 | 1045 |
description: "empty token impersonate can't see pods in cluster", |
| 1046 | 1046 |
clusterInterface: otherAdminClient.ImpersonateSubjectAccessReviews(""),
|
| 1047 | 1047 |
clusterReview: &authorizationapi.SubjectAccessReview{
|
| 1048 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "list", Resource: "pods"},
|
|
| 1048 |
+ Action: authorizationapi.Action{Verb: "list", Resource: "pods"},
|
|
| 1049 | 1049 |
}, |
| 1050 | 1050 |
err: `impersonating token may not be empty`, |
| 1051 | 1051 |
}.run(t) |
| ... | ... |
@@ -1054,7 +1054,7 @@ func TestAuthorizationSubjectAccessReview(t *testing.T) {
|
| 1054 | 1054 |
description: "danny impersonate can't see pods in hammer namespace", |
| 1055 | 1055 |
localInterface: otherAdminClient.ImpersonateLocalSubjectAccessReviews("hammer-project", dannyConfig.BearerToken),
|
| 1056 | 1056 |
localReview: &authorizationapi.LocalSubjectAccessReview{
|
| 1057 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "list", Resource: "pods"},
|
|
| 1057 |
+ Action: authorizationapi.Action{Verb: "list", Resource: "pods"},
|
|
| 1058 | 1058 |
}, |
| 1059 | 1059 |
response: authorizationapi.SubjectAccessReviewResponse{
|
| 1060 | 1060 |
Allowed: false, |
| ... | ... |
@@ -1066,7 +1066,7 @@ func TestAuthorizationSubjectAccessReview(t *testing.T) {
|
| 1066 | 1066 |
description: "danny impersonate can't see pods in cluster", |
| 1067 | 1067 |
clusterInterface: otherAdminClient.ImpersonateSubjectAccessReviews(dannyConfig.BearerToken), |
| 1068 | 1068 |
clusterReview: &authorizationapi.SubjectAccessReview{
|
| 1069 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "list", Resource: "pods"},
|
|
| 1069 |
+ Action: authorizationapi.Action{Verb: "list", Resource: "pods"},
|
|
| 1070 | 1070 |
}, |
| 1071 | 1071 |
response: authorizationapi.SubjectAccessReviewResponse{
|
| 1072 | 1072 |
Allowed: false, |
| ... | ... |
@@ -1077,7 +1077,7 @@ func TestAuthorizationSubjectAccessReview(t *testing.T) {
|
| 1077 | 1077 |
description: "danny impersonate can see pods in default", |
| 1078 | 1078 |
localInterface: otherAdminClient.ImpersonateLocalSubjectAccessReviews("default", dannyConfig.BearerToken),
|
| 1079 | 1079 |
localReview: &authorizationapi.LocalSubjectAccessReview{
|
| 1080 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "list", Resource: "pods"},
|
|
| 1080 |
+ Action: authorizationapi.Action{Verb: "list", Resource: "pods"},
|
|
| 1081 | 1081 |
}, |
| 1082 | 1082 |
response: authorizationapi.SubjectAccessReviewResponse{
|
| 1083 | 1083 |
Allowed: true, |
| ... | ... |
@@ -1118,7 +1118,7 @@ func TestOldLocalSubjectAccessReviewEndpoint(t *testing.T) {
|
| 1118 | 1118 |
// simple check |
| 1119 | 1119 |
{
|
| 1120 | 1120 |
sar := &authorizationapi.SubjectAccessReview{
|
| 1121 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 1121 |
+ Action: authorizationapi.Action{
|
|
| 1122 | 1122 |
Verb: "get", |
| 1123 | 1123 |
Resource: "imagestreams/layers", |
| 1124 | 1124 |
}, |
| ... | ... |
@@ -1144,7 +1144,7 @@ func TestOldLocalSubjectAccessReviewEndpoint(t *testing.T) {
|
| 1144 | 1144 |
// namespace forced to allowed namespace so we can't trick the server into leaking |
| 1145 | 1145 |
{
|
| 1146 | 1146 |
sar := &authorizationapi.SubjectAccessReview{
|
| 1147 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 1147 |
+ Action: authorizationapi.Action{
|
|
| 1148 | 1148 |
Namespace: "sneaky-user", |
| 1149 | 1149 |
Verb: "get", |
| 1150 | 1150 |
Resource: "imagestreams/layers", |
| ... | ... |
@@ -1191,7 +1191,7 @@ func TestOldLocalSubjectAccessReviewEndpoint(t *testing.T) {
|
| 1191 | 1191 |
} |
| 1192 | 1192 |
|
| 1193 | 1193 |
sar := &authorizationapi.SubjectAccessReview{
|
| 1194 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 1194 |
+ Action: authorizationapi.Action{
|
|
| 1195 | 1195 |
Verb: "get", |
| 1196 | 1196 |
Resource: "imagestreams/layers", |
| 1197 | 1197 |
}, |
| ... | ... |
@@ -1247,7 +1247,7 @@ func TestOldLocalResourceAccessReviewEndpoint(t *testing.T) {
|
| 1247 | 1247 |
// simple check |
| 1248 | 1248 |
{
|
| 1249 | 1249 |
rar := &authorizationapi.ResourceAccessReview{
|
| 1250 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 1250 |
+ Action: authorizationapi.Action{
|
|
| 1251 | 1251 |
Verb: "get", |
| 1252 | 1252 |
Resource: "imagestreams/layers", |
| 1253 | 1253 |
}, |
| ... | ... |
@@ -1273,7 +1273,7 @@ func TestOldLocalResourceAccessReviewEndpoint(t *testing.T) {
|
| 1273 | 1273 |
// namespace forced to allowed namespace so we can't trick the server into leaking |
| 1274 | 1274 |
{
|
| 1275 | 1275 |
rar := &authorizationapi.ResourceAccessReview{
|
| 1276 |
- Action: authorizationapi.AuthorizationAttributes{
|
|
| 1276 |
+ Action: authorizationapi.Action{
|
|
| 1277 | 1277 |
Namespace: "sneaky-user", |
| 1278 | 1278 |
Verb: "get", |
| 1279 | 1279 |
Resource: "imagestreams/layers", |
| ... | ... |
@@ -157,7 +157,7 @@ func TestBootstrapPolicySelfSubjectAccessReviews(t *testing.T) {
|
| 157 | 157 |
|
| 158 | 158 |
// can I get a subjectaccessreview on myself even if I have no rights to do it generally |
| 159 | 159 |
askCanICreatePolicyBindings := &authorizationapi.LocalSubjectAccessReview{
|
| 160 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "create", Resource: "policybindings"},
|
|
| 160 |
+ Action: authorizationapi.Action{Verb: "create", Resource: "policybindings"},
|
|
| 161 | 161 |
} |
| 162 | 162 |
subjectAccessReviewTest{
|
| 163 | 163 |
localInterface: valerieOpenshiftClient.LocalSubjectAccessReviews("openshift"),
|
| ... | ... |
@@ -172,7 +172,7 @@ func TestBootstrapPolicySelfSubjectAccessReviews(t *testing.T) {
|
| 172 | 172 |
// I shouldn't be allowed to ask whether someone else can perform an action |
| 173 | 173 |
askCanClusterAdminsCreateProject := &authorizationapi.LocalSubjectAccessReview{
|
| 174 | 174 |
Groups: sets.NewString("system:cluster-admins"),
|
| 175 |
- Action: authorizationapi.AuthorizationAttributes{Verb: "create", Resource: "projects"},
|
|
| 175 |
+ Action: authorizationapi.Action{Verb: "create", Resource: "projects"},
|
|
| 176 | 176 |
} |
| 177 | 177 |
subjectAccessReviewTest{
|
| 178 | 178 |
localInterface: valerieOpenshiftClient.LocalSubjectAccessReviews("openshift"),
|
| ... | ... |
@@ -213,7 +213,7 @@ func TestSelfSubjectAccessReviewsNonExistingNamespace(t *testing.T) {
|
| 213 | 213 |
// ensure that a SAR for a non-exisitng namespace gives a SAR response and not a |
| 214 | 214 |
// namespace doesn't exist response from admisison. |
| 215 | 215 |
askCanICreatePodsInNonExistingNamespace := &authorizationapi.LocalSubjectAccessReview{
|
| 216 |
- Action: authorizationapi.AuthorizationAttributes{Namespace: "foo", Verb: "create", Resource: "pods"},
|
|
| 216 |
+ Action: authorizationapi.Action{Namespace: "foo", Verb: "create", Resource: "pods"},
|
|
| 217 | 217 |
} |
| 218 | 218 |
subjectAccessReviewTest{
|
| 219 | 219 |
description: "ensure SAR for non-existing namespace does not leak namespace info", |
| ... | ... |
@@ -18,7 +18,7 @@ const ( |
| 18 | 18 |
// WaitForPolicyUpdate checks if the given client can perform the named verb and action. |
| 19 | 19 |
// If PolicyCachePollTimeout is reached without the expected condition matching, an error is returned |
| 20 | 20 |
func WaitForPolicyUpdate(c *client.Client, namespace, verb string, resource unversioned.GroupResource, allowed bool) error {
|
| 21 |
- review := &authorizationapi.LocalSubjectAccessReview{Action: authorizationapi.AuthorizationAttributes{Verb: verb, Group: resource.Group, Resource: resource.Resource}}
|
|
| 21 |
+ review := &authorizationapi.LocalSubjectAccessReview{Action: authorizationapi.Action{Verb: verb, Group: resource.Group, Resource: resource.Resource}}
|
|
| 22 | 22 |
err := wait.Poll(PolicyCachePollInterval, PolicyCachePollTimeout, func() (bool, error) {
|
| 23 | 23 |
response, err := c.LocalSubjectAccessReviews(namespace).Create(review) |
| 24 | 24 |
if err != nil {
|
| ... | ... |
@@ -32,7 +32,7 @@ func WaitForPolicyUpdate(c *client.Client, namespace, verb string, resource unve |
| 32 | 32 |
// WaitForClusterPolicyUpdate checks if the given client can perform the named verb and action. |
| 33 | 33 |
// If PolicyCachePollTimeout is reached without the expected condition matching, an error is returned |
| 34 | 34 |
func WaitForClusterPolicyUpdate(c *client.Client, verb string, resource unversioned.GroupResource, allowed bool) error {
|
| 35 |
- review := &authorizationapi.SubjectAccessReview{Action: authorizationapi.AuthorizationAttributes{Verb: verb, Group: resource.Group, Resource: resource.Resource}}
|
|
| 35 |
+ review := &authorizationapi.SubjectAccessReview{Action: authorizationapi.Action{Verb: verb, Group: resource.Group, Resource: resource.Resource}}
|
|
| 36 | 36 |
err := wait.Poll(PolicyCachePollInterval, PolicyCachePollTimeout, func() (bool, error) {
|
| 37 | 37 |
response, err := c.SubjectAccessReviews().Create(review) |
| 38 | 38 |
if err != nil {
|