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
2 changes: 1 addition & 1 deletion app/controlplane/pkg/authz/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ var ServerOperationsMap = map[string]*OperationPolicy{
// CAS Backend listing
"/controlplane.v1.CASBackendService/List": {Policies: []*Policy{PolicyCASBackendList}},
"/controlplane.v1.CASBackendService/Revalidate": {Policies: []*Policy{PolicyCASBackendUpdate}},
"/controlplane.v1.CASBackendService/Create": {Policies: []*Policy{PolicyCASBackendCreate}},
"/controlplane.v1.CASBackendService/Create": {Policies: []*Policy{PolicyCASBackendCreate}, ExternalAuthz: true},
// Available integrations
"/controlplane.v1.IntegrationsService/ListAvailable": {Policies: []*Policy{PolicyAvailableIntegrationList, PolicyAvailableIntegrationRead}},
// Registered integrations
Expand Down
32 changes: 31 additions & 1 deletion app/controlplane/pkg/authz/authz_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2024-2025 The Chainloop Authors.
// Copyright 2024-2026 The Chainloop Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -129,6 +129,36 @@ func TestDoSync(t *testing.T) {
assert.Equal(t, "delete", got[0][2])
}

func TestRequiresExternalAuthz(t *testing.T) {
testCases := []struct {
name string
operation string
want bool
}{
{
name: "CAS backend creation is forwarded to the external authorizer",
operation: "/controlplane.v1.CASBackendService/Create",
want: true,
},
{
name: "operations without external authz flag are not forwarded",
operation: "/controlplane.v1.WorkflowService/List",
want: false,
},
{
name: "unknown operations are not forwarded",
operation: "/controlplane.v1.UnknownService/Unknown",
want: false,
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.want, RequiresExternalAuthz(tc.operation))
})
}
}

func testEnforcer(t *testing.T) (*CasbinEnforcer, io.Closer) {
f, err := os.CreateTemp(t.TempDir(), "policy*.csv")
if err != nil {
Expand Down
Loading