Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-owner can update artifact #5635

Merged
merged 1 commit into from
Dec 2, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,11 @@ private ArtifactMetaData handleIfExistsReturnOrUpdate(String groupId, String art
return updateArtifactInternal(groupId, artifactId, version, artifactName, artifactDescription, content, contentType, references);
}

private ArtifactMetaData updateArtifactInternal(String groupId, String artifactId, String version,
/**
* Internally updates the artifact. This method has to be annotated with @Authorized because it's used by the ifExists feature. This has been refactored in 3.0.
*/
@Authorized(style = AuthorizedStyle.GroupAndArtifact, level = AuthorizedLevel.Write)
protected ArtifactMetaData updateArtifactInternal(String groupId, String artifactId, String version,
String name, String description,
ContentHandle content, String contentType, List<ArtifactReference> references) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ public void testOwnerOnlyAuthorization() throws Exception {
clientDev.updateArtifactMetaData(groupId, artifactId, updatedMetaData);
});

// Dev user cannot update with ifExists the same artifact because Dev user is not the owner
Assertions.assertThrows(ForbiddenException.class, () -> {
clientDev.createArtifact(groupId, artifactId, ArtifactType.JSON, IfExists.RETURN_OR_UPDATE, new ByteArrayInputStream("{fffff}".getBytes()));
});

// But the admin user CAN make the change.
clientAdmin.updateArtifactMetaData(groupId, artifactId, updatedMetaData);

Expand Down
Loading