Skip to content

Commit

Permalink
Merge pull request DependencyTrack#4177 from Gepardgame/feat/Visible-…
Browse files Browse the repository at this point in the history
…Endpoints-returns-API-Keys

Visible Endpoint returns only Visible Teams(name, uuid)
  • Loading branch information
nscuro authored Sep 26, 2024
2 parents 9d20bbf + 125cf89 commit 189dd2d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.dependencytrack.model.validation.ValidUuid;
import org.dependencytrack.persistence.QueryManager;
import org.dependencytrack.resources.v1.vo.TeamSelfResponse;
import org.dependencytrack.resources.v1.vo.VisibleTeams;
import org.owasp.security.logging.SecurityMarkers;

import jakarta.validation.Validator;
Expand Down Expand Up @@ -228,7 +229,7 @@ public Response deleteTeam(Team jsonTeam) {
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Returns a list of Teams that are visible", description = "<p></p>")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The Visible Teams", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Team.class)))),
@ApiResponse(responseCode = "200", description = "The Visible Teams", content = @Content(array = @ArraySchema(schema = @Schema(implementation = VisibleTeams.class)))),
@ApiResponse(responseCode = "401", description = "Unauthorized")
})
public Response availableTeams() {
Expand All @@ -246,7 +247,11 @@ public Response availableTeams() {
}
}

return Response.ok(teams).build();
List<VisibleTeams> response = new ArrayList<VisibleTeams>();
for (Team team : teams) {
response.add(new VisibleTeams(team.getName(), team.getUuid()));
}
return Response.ok(response).build();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* This file is part of Dependency-Track.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) OWASP Foundation. All Rights Reserved.
*/
package org.dependencytrack.resources.v1.vo;

import java.util.UUID;

public record VisibleTeams(String name, UUID uuid) {
}

0 comments on commit 189dd2d

Please sign in to comment.