use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class UsersResource method addSecret.
@POST
@Path("secrets")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Stores a secret for user")
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.USER }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response addSecret(SecretDTO secret, @Context SecurityContext sc, @Context HttpServletRequest req) throws UserException {
Users user = jWTHelper.getUserPrincipal(sc);
secretsController.add(user, secret.getName(), secret.getSecret(), secret.getVisibility(), secret.getProjectIdScope());
RESTApiJsonResponse response = new RESTApiJsonResponse();
response.setSuccessMessage("Added new secret");
return Response.ok().entity(response).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class ServingService method get.
@GET
@Path("/{servingId}")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.SERVING }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Get info about a serving instance for the project", response = ServingView.class)
public Response get(@Context SecurityContext sc, @ApiParam(value = "Id of the Serving instance", required = true) @PathParam("servingId") Integer servingId) throws ServingException, KafkaException, CryptoPasswordNotFoundException {
if (servingId == null) {
throw new IllegalArgumentException("servingId was not provided");
}
ServingWrapper servingWrapper = servingController.get(project, servingId);
ServingView servingView = new ServingView(servingWrapper);
GenericEntity<ServingView> servingEntity = new GenericEntity<ServingView>(servingView) {
};
return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(servingEntity).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class UsersResource method setGitProvider.
@ApiOperation(value = "Configure a Git Provider secrets", response = GitProviderSecretsDTO.class)
@POST
@Path("/git/provider")
@Produces(MediaType.APPLICATION_JSON)
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.GIT }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response setGitProvider(@Context SecurityContext sc, @Context UriInfo uriInfo, GitProviderSecretsDTO gitProviderSecretsDTO) throws UserException {
Users user = jWTHelper.getUserPrincipal(sc);
gitCommandOperationUtil.createAuthenticationSecret(user, gitProviderSecretsDTO.getUsername(), gitProviderSecretsDTO.getToken(), gitProviderSecretsDTO.getGitProvider());
GitProviderSecretsDTO dto = gitProvidersSecretsBuilder.build(uriInfo, user);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class UsersResource method getSecret.
@GET
@Path("secrets/{secretName}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Gets the value of a private secret", response = SecretDTO.class)
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.USER }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getSecret(@PathParam("secretName") String name, @Context SecurityContext sc) throws UserException {
Users user = jWTHelper.getUserPrincipal(sc);
SecretPlaintext secret = secretsController.get(user, name);
SecretDTO dto = secretsBuilder.build(Arrays.asList(secret), true);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class UsersResource method getAllSecrets.
@GET
@Path("secrets")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Retrieves all secrets' names of a user", response = SecretDTO.class)
@ApiKeyRequired(acceptedScopes = { ApiScope.USER }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getAllSecrets(@Context SecurityContext sc) throws UserException {
Users user = jWTHelper.getUserPrincipal(sc);
List<SecretPlaintext> secrets = secretsController.getAllForUser(user);
SecretDTO dto = secretsBuilder.build(secrets, false);
return Response.ok().entity(dto).build();
}
Aggregations