Skip to content

Conversation

@Piskoo
Copy link
Collaborator

@Piskoo Piskoo commented Dec 5, 2025

This PR adds a new organization-level setting that allows administrators to restrict contract creation to be only available for organization admins, preventing their creation by org members and project admins.

When setting is enabled and non-admin user tries to run att init without specifying contract an error is returned:

chainloop att init --project myproject --workflow newworkflow --replace
ERR failed to initialize the attestation: can't create the workflow: authorization error: only organization admins can create contracts

Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
@Piskoo Piskoo marked this pull request as ready for review December 7, 2025 13:21
var projectID *uuid.UUID
if req.ProjectReference.IsSet() {
// Check if organization prevents project-scoped contracts
if org.PreventProjectScopedContracts {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the only place a contract is created? can you check during attestation init?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to double check that a contract can only be created on-demand from this use case. I remember it was also created during a workflow creation, or attestation init.

Would you mind posting there an evaluation of those entrypoints and how this feature will work with the other preventWorkflowCreation feature?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is what we want. What we want is to only allow administrators to create contracts if this setting is set

@migmartri
Copy link
Member

also, what's the use-case here? Can anybody create project contracts? can admins do it?

Copy link
Member

@migmartri migmartri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my inline coments

Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
@Piskoo Piskoo marked this pull request as draft December 12, 2025 12:02
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
@Piskoo
Copy link
Collaborator Author

Piskoo commented Dec 12, 2025

Updated with what have discussed.

is this the only place a contract is created? can you check during attestation init?

We could also restrict creation of the default contract that is created when no contract was specified in workflow creation, but is that desired behavior?

@Piskoo Piskoo marked this pull request as ready for review December 12, 2025 12:17
@migmartri
Copy link
Member

Updated with what have discussed.

is this the only place a contract is created? can you check during attestation init?

We could also restrict creation of the default contract that is created when no contract was specified in workflow creation, but is that desired behavior?

I think so yes

The idea of this feature is to prevent contract sprawl, and the main source of sprawl is the attestation process.

Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
@Piskoo
Copy link
Collaborator Author

Piskoo commented Dec 12, 2025

Updated with what have discussed.

is this the only place a contract is created? can you check during attestation init?

We could also restrict creation of the default contract that is created when no contract was specified in workflow creation, but is that desired behavior?

I think so yes

The idea of this feature is to prevent contract sprawl, and the main source of sprawl is the attestation process.

Alright, added validation to att init as well

@migmartri
Copy link
Member

Updated with what have discussed.

is this the only place a contract is created? can you check during attestation init?

We could also restrict creation of the default contract that is created when no contract was specified in workflow creation, but is that desired behavior?

I think so yes
The idea of this feature is to prevent contract sprawl, and the main source of sprawl is the attestation process.

Alright, added validation to att init as well

Thanks

Does it work in workflow create too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants