Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/xds/rbac/rbac_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ func newRPCData(ctx context.Context) (*rpcData, error) {
if !ok {
return nil, errors.New("missing method in incoming context")
}
// gRPC-Go strips :path from the headers given to the application, but RBAC should be
// able to match against it.
md[":path"] = []string{mn}

// The connection is needed in order to find the destination address and
// port of the incoming RPC Call.
Expand Down
24 changes: 24 additions & 0 deletions test/xds/xds_server_rbac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,30 @@ func (s) TestRBACHTTPFilter(t *testing.T) {
wantStatusEmptyCall: codes.PermissionDenied,
wantStatusUnaryCall: codes.OK,
},
// This test tests an RBAC HTTP Filter which is configured to allow only
// RPC's with certain paths ("UnaryCall") via the ":path" header. Only
// unary calls passing through this RBAC HTTP Filter should proceed as
// normal, and any others should be denied.
{
name: "allow-certain-path-by-header",
rbacCfg: &rpb.RBAC{
Rules: &v3rbacpb.RBAC{
Action: v3rbacpb.RBAC_ALLOW,
Policies: map[string]*v3rbacpb.Policy{
"certain-path": {
Permissions: []*v3rbacpb.Permission{
{Rule: &v3rbacpb.Permission_Header{Header: &v3routepb.HeaderMatcher{Name: ":path", HeaderMatchSpecifier: &v3routepb.HeaderMatcher_ExactMatch{ExactMatch: "/grpc.testing.TestService/UnaryCall"}}}},
},
Principals: []*v3rbacpb.Principal{
{Identifier: &v3rbacpb.Principal_Any{Any: true}},
},
},
},
},
},
wantStatusEmptyCall: codes.PermissionDenied,
wantStatusUnaryCall: codes.OK,
},
// This test that a RBAC Config with nil rules means that every RPC is
// allowed. This maps to the line "If absent, no enforcing RBAC policy
// will be applied" from the RBAC Proto documentation for the Rules
Expand Down
Loading