diff --git a/pkg/acl/eacl/enums.go b/pkg/acl/eacl/enums.go index 39a42531..2e8fc1f2 100644 --- a/pkg/acl/eacl/enums.go +++ b/pkg/acl/eacl/enums.go @@ -96,6 +96,9 @@ const ( // HeaderFromObject is a FilterHeaderType for object header. HeaderFromObject + + // HeaderFromService is a FilterHeaderType for service header. + HeaderFromService ) // ToV2 converts Action to v2 Action enum value. @@ -343,6 +346,8 @@ func (h FilterHeaderType) ToV2() v2acl.HeaderType { return v2acl.HeaderTypeRequest case HeaderFromObject: return v2acl.HeaderTypeObject + case HeaderFromService: + return v2acl.HeaderTypeService default: return v2acl.HeaderTypeUnknown } @@ -355,6 +360,8 @@ func FilterHeaderTypeFromV2(header v2acl.HeaderType) (h FilterHeaderType) { h = HeaderFromRequest case v2acl.HeaderTypeObject: h = HeaderFromObject + case v2acl.HeaderTypeService: + h = HeaderFromService default: h = HeaderTypeUnknown } diff --git a/pkg/acl/eacl/enums_test.go b/pkg/acl/eacl/enums_test.go index 53528494..d077a898 100644 --- a/pkg/acl/eacl/enums_test.go +++ b/pkg/acl/eacl/enums_test.go @@ -43,6 +43,7 @@ var ( eacl.HeaderTypeUnknown: v2acl.HeaderTypeUnknown, eacl.HeaderFromRequest: v2acl.HeaderTypeRequest, eacl.HeaderFromObject: v2acl.HeaderTypeObject, + eacl.HeaderFromService: v2acl.HeaderTypeService, } ) @@ -104,15 +105,15 @@ func TestMatch(t *testing.T) { func TestFilterHeaderType(t *testing.T) { t.Run("known header types", func(t *testing.T) { - for i := eacl.HeaderTypeUnknown; i <= eacl.HeaderFromObject; i++ { + for i := eacl.HeaderTypeUnknown; i <= eacl.HeaderFromService; i++ { require.Equal(t, eqV2HeaderTypes[i], i.ToV2()) require.Equal(t, eacl.FilterHeaderTypeFromV2(i.ToV2()), i) } }) t.Run("unknown header types", func(t *testing.T) { - require.Equal(t, (eacl.HeaderFromObject + 1).ToV2(), v2acl.HeaderTypeUnknown) - require.Equal(t, eacl.FilterHeaderTypeFromV2(v2acl.HeaderTypeObject+1), eacl.HeaderTypeUnknown) + require.Equal(t, (eacl.HeaderFromService + 1).ToV2(), v2acl.HeaderTypeUnknown) + require.Equal(t, eacl.FilterHeaderTypeFromV2(v2acl.HeaderTypeService+1), eacl.HeaderTypeUnknown) }) } diff --git a/v2/acl/convert.go b/v2/acl/convert.go index d4a52b82..d501b568 100644 --- a/v2/acl/convert.go +++ b/v2/acl/convert.go @@ -111,6 +111,8 @@ func HeaderTypeToGRPCField(t HeaderType) acl.HeaderType { return acl.HeaderType_REQUEST case HeaderTypeObject: return acl.HeaderType_OBJECT + case HeaderTypeService: + return acl.HeaderType_SERVICE default: return acl.HeaderType_HEADER_UNSPECIFIED } @@ -123,6 +125,8 @@ func HeaderTypeFromGRPCField(t acl.HeaderType) HeaderType { return HeaderTypeRequest case acl.HeaderType_OBJECT: return HeaderTypeObject + case acl.HeaderType_SERVICE: + return HeaderTypeService default: return HeaderTypeUnknown } diff --git a/v2/acl/grpc/types.pb.go b/v2/acl/grpc/types.pb.go index 319a4723..639bdf25 100644 Binary files a/v2/acl/grpc/types.pb.go and b/v2/acl/grpc/types.pb.go differ diff --git a/v2/acl/types.go b/v2/acl/types.go index f7775319..58b310d1 100644 --- a/v2/acl/types.go +++ b/v2/acl/types.go @@ -85,6 +85,7 @@ const ( HeaderTypeUnknown HeaderType = iota HeaderTypeRequest HeaderTypeObject + HeaderTypeService ) const (