Skip to content
Closed
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
12 changes: 0 additions & 12 deletions app/controlplane/internal/server/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,6 @@ func craftMiddleware(opts *Opts) []middleware.Middleware {
selector.Server(
usercontext.CheckUserHasAccess(opts.AuthConfig.AllowList, opts.UserUseCase),
).Match(allowListEnabled()).Build(),
selector.Server(
usercontext.CheckOrgRequirements(opts.CASBackendUseCase),
).Match(requireFullyConfiguredOrgMatcher()).Build(),
).Match(requireCurrentUserMatcher()).Build(),
)

Expand Down Expand Up @@ -259,15 +256,6 @@ func requireCurrentUserMatcher() selector.MatchFunc {
}
}

func requireFullyConfiguredOrgMatcher() selector.MatchFunc {
// We do not need to remove other endpoints since this matcher is called once the requireCurrentUserMatcher one has passed
const skipRegexp = "controlplane.v1.OCIRepositoryService/.*|controlplane.v1.ContextService/Current|/controlplane.v1.OrganizationService/.*|/controlplane.v1.AuthService/DeleteAccount|controlplane.v1.CASBackendService/.*|/controlplane.v1.UserService/.*|controlplane.v1.SigningService/.*"
return func(ctx context.Context, operation string) bool {
r := regexp.MustCompile(skipRegexp)
return !r.MatchString(operation)
}
}

func allowListEnabled() selector.MatchFunc {
// the allow list should not affect the ability to know who you are and delete your account
const skipRegexp = "controlplane.v1.ContextService/Current|/controlplane.v1.AuthService/DeleteAccount"
Expand Down
22 changes: 0 additions & 22 deletions app/controlplane/internal/server/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,6 @@ func TestRequireCurrentUserMatcher(t *testing.T) {
}
}

func TestRequireFullyConfiguredOrgMatcher(t *testing.T) {
testCases := []struct {
operation string
matches bool
}{
{"/controlplane.v1.WorkflowService/List", true},
{"/controlplane.v1.WorkflowRunService/List", true},
{"/controlplane.v1.OCIRepositoryService/Save", false},
{"/controlplane.v1.OrganizationService/ListMemberships", false},
{"/controlplane.v1.OrganizationService/SetCurrent", false},
{"/controlplane.v1.CASBackendService/List", false},
{"/controlplane.v1.CASBackendService/Add", false},
}

matchFunc := requireFullyConfiguredOrgMatcher()
for _, op := range testCases {
if got, want := matchFunc(context.Background(), op.operation), op.matches; got != want {
assert.Equal(t, matchFunc(context.Background(), op.operation), op.matches)
}
}
}

func TestRequireRobotAccountMatcher(t *testing.T) {
testCases := []struct {
operation string
Expand Down

This file was deleted.

This file was deleted.

Loading