From d96294810379bc28083e88a2633a1f52736498e0 Mon Sep 17 00:00:00 2001 From: Quanjie Lin <32855694+quanjielin@users.noreply.github.com> Date: Tue, 28 Aug 2018 11:19:58 -0700 Subject: [PATCH] add EnforcementMode to RbacConfig (#623) * add EnforcementMode to RbacConfig * add more comment * add more comment --- rbac/v1alpha1/rbac.pb.go | 118 ++++++++++++++++++++++++++------------- rbac/v1alpha1/rbac.proto | 8 +++ 2 files changed, 88 insertions(+), 38 deletions(-) diff --git a/rbac/v1alpha1/rbac.pb.go b/rbac/v1alpha1/rbac.pb.go index 15f49980..b4f49061 100644 --- a/rbac/v1alpha1/rbac.pb.go +++ b/rbac/v1alpha1/rbac.pb.go @@ -410,6 +410,13 @@ type RbacConfig struct { // A list of services or namespaces that should not be enforced by Istio RBAC policies. Note: This field have // effect only when mode is ON_WITH_EXCLUSION and will be ignored for any other modes. Exclusion *RbacConfig_Target `protobuf:"bytes,3,opt,name=exclusion" json:"exclusion,omitempty"` + // $hide_from_docs + // Indicates enforcement mode of the RbacConfig, in ENFORCED mode by default. + // It's used to verify new RbacConfig work as expected before rolling to production. + // When setting as PERMISSIVE, RBAC isn't enforced and has no impact on users. + // RBAC engine run RbacConfig in PERMISSIVE mode and logs stats. + // Invalid to set RbacConfig in PERMISSIVE and ServiceRoleBinding in ENFORCED mode. + EnforcementMode EnforcementMode `protobuf:"varint,4,opt,name=enforcement_mode,json=enforcementMode,proto3,enum=istio.rbac.v1alpha1.EnforcementMode" json:"enforcement_mode,omitempty"` } func (m *RbacConfig) Reset() { *m = RbacConfig{} } @@ -438,6 +445,13 @@ func (m *RbacConfig) GetExclusion() *RbacConfig_Target { return nil } +func (m *RbacConfig) GetEnforcementMode() EnforcementMode { + if m != nil { + return m.EnforcementMode + } + return EnforcementMode_ENFORCED +} + // Target defines a list of services or namespaces. type RbacConfig_Target struct { // A list of services. @@ -783,6 +797,11 @@ func (m *RbacConfig) MarshalTo(dAtA []byte) (int, error) { } i += n3 } + if m.EnforcementMode != 0 { + dAtA[i] = 0x20 + i++ + i = encodeVarintRbac(dAtA, i, uint64(m.EnforcementMode)) + } return i, nil } @@ -970,6 +989,9 @@ func (m *RbacConfig) Size() (n int) { l = m.Exclusion.Size() n += 1 + l + sovRbac(uint64(l)) } + if m.EnforcementMode != 0 { + n += 1 + sovRbac(uint64(m.EnforcementMode)) + } return n } @@ -1942,6 +1964,25 @@ func (m *RbacConfig) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EnforcementMode", wireType) + } + m.EnforcementMode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRbac + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EnforcementMode |= (EnforcementMode(b) & 0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipRbac(dAtA[iNdEx:]) @@ -2179,43 +2220,44 @@ var ( func init() { proto.RegisterFile("rbac/v1alpha1/rbac.proto", fileDescriptorRbac) } var fileDescriptorRbac = []byte{ - // 597 bytes of a gzipped FileDescriptorProto + // 615 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xdd, 0x6a, 0xdb, 0x4c, - 0x10, 0xcd, 0x4a, 0x8e, 0x1d, 0x8f, 0x3f, 0x12, 0x7d, 0xdb, 0xb4, 0x08, 0x53, 0x5c, 0x23, 0x4a, - 0x31, 0xa1, 0xc8, 0x24, 0xa5, 0x21, 0x14, 0x7a, 0xd1, 0xd8, 0x0a, 0x35, 0x24, 0x76, 0x58, 0xa7, - 0x3f, 0xf4, 0x26, 0xc8, 0xf2, 0xda, 0xde, 0x46, 0xde, 0x15, 0xbb, 0x92, 0x69, 0xde, 0xae, 0x97, - 0xbd, 0xec, 0x13, 0xb4, 0xc5, 0x4f, 0x52, 0x24, 0x59, 0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0x45, 0x09, 0x9b, 0x60, 0x5c, 0xd0, + 0x2b, 0x0b, 0xb5, 0x50, 0xa7, 0x46, 0x92, 0x10, 0x3f, 0x81, 0xca, 0xa5, 0x17, 0xc4, 0x34, 0x93, + 0x37, 0xcf, 0xda, 0x3f, 0x10, 0xe0, 0x05, 0x9f, 0xf6, 0x19, 0x9f, 0x30, 0x3e, 0xc5, 0x7b, 0xb0, + 0xa6, 0xe2, 0xf1, 0x57, 0xea, 0x47, 0x99, 0x63, 0x4f, 0x97, 0x2a, 0x1b, 0xa5, 0x4d, 0x24, 0xef, + 0xc6, 0xbb, 0x50, 0x95, 0x22, 0xa0, 0x84, 0x9e, 0x59, 0xa5, 0x16, 0xfa, 0x27, 0x91, 0xa4, 0x3d, + 0x24, 0x6b, 0xc6, 0x7b, 0x50, 0x9e, 0x89, 0x09, 0xb5, 0x8c, 0x16, 0xea, 0xac, 0xef, 0x3c, 0x5f, + 0x4a, 0x72, 0xf8, 0x99, 0x90, 0x3e, 0x9d, 0x51, 0x1e, 0x1d, 0x89, 0x09, 0x25, 0x9a, 0x91, 0xac, + 0x50, 0x9d, 0xeb, 0xc0, 0x18, 0xca, 0xb1, 0xa2, 0x72, 0xbe, 0xb9, 0x8e, 0x93, 0xc3, 0x4c, 0xa5, + 0x88, 0x43, 0xad, 0xa7, 0x46, 0xd2, 0x04, 0x1f, 0x02, 0x84, 0x52, 0x84, 0x54, 0x46, 0x8c, 0xa6, + 0xb7, 0xa9, 0xef, 0xbc, 0xbc, 0x6b, 0x47, 0xfb, 0x38, 0x6f, 0x77, 0x78, 0x24, 0xaf, 0xc8, 0x02, + 0xbf, 0xf1, 0x16, 0x36, 0x6e, 0x95, 0x97, 0xdc, 0x60, 0x13, 0x56, 0xb5, 0xeb, 0x99, 0x10, 0x9d, + 0xbc, 0x29, 0xed, 0xa1, 0xf6, 0x36, 0x54, 0xe7, 0x86, 0x24, 0x1b, 0x5c, 0x30, 0x3e, 0xc9, 0x36, + 0x48, 0xe2, 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0xe7, 0xba, 0x89, 0xbe, 0x34, 0x52, 0x07, 0x98, 0xe8, 0x7a, 0x21, + 0xeb, 0xde, 0x78, 0x0d, 0xc7, 0x15, 0xfd, 0x12, 0xbe, 0xfa, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x00, + 0xdb, 0x22, 0xbc, 0x25, 0x05, 0x00, 0x00, } diff --git a/rbac/v1alpha1/rbac.proto b/rbac/v1alpha1/rbac.proto index c940a0fb..1b138bda 100644 --- a/rbac/v1alpha1/rbac.proto +++ b/rbac/v1alpha1/rbac.proto @@ -247,4 +247,12 @@ message RbacConfig { // A list of services or namespaces that should not be enforced by Istio RBAC policies. Note: This field have // effect only when mode is ON_WITH_EXCLUSION and will be ignored for any other modes. Target exclusion = 3; + + // $hide_from_docs + // Indicates enforcement mode of the RbacConfig, in ENFORCED mode by default. + // It's used to verify new RbacConfig work as expected before rolling to production. + // When setting as PERMISSIVE, RBAC isn't enforced and has no impact on users. + // RBAC engine run RbacConfig in PERMISSIVE mode and logs stats. + // Invalid to set RbacConfig in PERMISSIVE and ServiceRoleBinding in ENFORCED mode. + EnforcementMode enforcement_mode = 4; }