Skip to content

Project (auto)create: Add Team to ACL for ApiKey principals - #1529

Merged
stevespringett merged 3 commits into
DependencyTrack:masterfrom
valentijnscholten:bom-autocreate-acl
Apr 12, 2022
Merged

Project (auto)create: Add Team to ACL for ApiKey principals#1529
stevespringett merged 3 commits into
DependencyTrack:masterfrom
valentijnscholten:bom-autocreate-acl

Conversation

@valentijnscholten

@valentijnscholten valentijnscholten commented Apr 10, 2022

Copy link
Copy Markdown
Contributor

Changes
When Project is autocreated during BOM upload and Portfolio Access Control is enabled, the ACL of the new Project should contain the Team that created the Project. fixes #1435

The same cannot yet be done for Users autocreating a Project as we don't know which Team should be added to the ACL. Users can be in 0 or more Teams.

Unit tests
I was planning on updating the unit tests to reflect this scenario. But there are no unit tests around Portfolio Access Control it seems. It would to be too big a change for me here to add them in this PR.

Notes
There already was some duplicate code in the BomResource. I didn't want to refactor too much, but tried to avoid creating more duplicate code.

Signed-off-by: Valentijn Scholten <valentijnscholten@gmail.com>
@valentijnscholten

Copy link
Copy Markdown
Contributor Author

Maybe we also have to add the Team to the ACL when creating a Project via th ProjectResource?

@valentijnscholten

Copy link
Copy Markdown
Contributor Author

Updated ProjectResource to also add the Team from ApiKey principals to the newly created Project.

@valentijnscholten valentijnscholten changed the title BOM upload autocreate: Add Team to ACL Project (auto)create: Add Team to ACL for ApiKey principals Apr 12, 2022
*/
public boolean updateNewProjectACL(Project project, Principal principal) {
if (isEnabled(ConfigPropertyConstants.ACCESS_MANAGEMENT_ACL_ENABLED) && principal instanceof ApiKey) {
ApiKey apiKey = (ApiKey) principal;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this what we want to do? If I cloned a project, I would expect all users and teams that had access to the project would also have access to the new project. This method appears to only grant access to the API key that performed the cloning.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This PR only covers creation of new projects. I was thinking about a separate PR for cloning, or do you prefer to have it combined here? It would add a field to the Clone Project request.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah correct. Different things. A separate PR for the cloning would be good.

@stevespringett
stevespringett merged commit e6f190c into DependencyTrack:master Apr 12, 2022
@stevespringett stevespringett added this to the 4.5 milestone Apr 12, 2022
@valentijnscholten
valentijnscholten deleted the bom-autocreate-acl branch May 6, 2022 18:16
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not allowed to upload sbom to project I create.

2 participants