Skip to content

Commit 71fe4a9

Browse files
authored
fix(authz): add WorkflowContractService/Apply to ServerOperationsMap (#3076)
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
1 parent 47c6200 commit 71fe4a9

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

app/controlplane/pkg/authz/authz.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ var ServerOperationsMap = map[string]*OperationPolicy{
406406
"/controlplane.v1.WorkflowContractService/Update": {Policies: []*Policy{PolicyWorkflowContractUpdate}},
407407
"/controlplane.v1.WorkflowContractService/Create": {Policies: []*Policy{PolicyWorkflowContractCreate}},
408408
"/controlplane.v1.WorkflowContractService/Delete": {Policies: []*Policy{PolicyWorkflowContractDelete}},
409+
"/controlplane.v1.WorkflowContractService/Apply": {Policies: []*Policy{PolicyWorkflowContractCreate, PolicyWorkflowContractUpdate}},
409410
// Get current information about an organization
410411
"/controlplane.v1.ContextService/Current": {Policies: []*Policy{PolicyOrganizationRead}},
411412
// Listing, create or selecting an organization does not have any required permissions,

app/controlplane/pkg/authz/middleware/middleware_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2024-2025 The Chainloop Authors.
2+
// Copyright 2024-2026 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -210,6 +210,10 @@ func TestPoliciesLookup(t *testing.T) {
210210
operation: "/controlplane.v1.OrgMetricsService",
211211
wantErr: true,
212212
},
213+
{
214+
name: "contract apply operation found",
215+
operation: "/controlplane.v1.WorkflowContractService/Apply",
216+
},
213217
}
214218

215219
for _, tc := range testCases {
@@ -224,3 +228,9 @@ func TestPoliciesLookup(t *testing.T) {
224228
})
225229
}
226230
}
231+
232+
func TestPoliciesLookupContractApply(t *testing.T) {
233+
policies, err := policiesLookup("/controlplane.v1.WorkflowContractService/Apply")
234+
assert.NoError(t, err)
235+
assert.Equal(t, []*authz.Policy{authz.PolicyWorkflowContractCreate, authz.PolicyWorkflowContractUpdate}, policies)
236+
}

0 commit comments

Comments
 (0)