use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class UsersResource method getSharedSecret.
@GET
@Path("secrets/shared")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Gets the value of a shared 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 getSharedSecret(@QueryParam("name") String secretName, @QueryParam("owner") String ownerUsername, @Context SecurityContext sc) throws UserException, ServiceException, ProjectException {
Users caller = jWTHelper.getUserPrincipal(sc);
SecretPlaintext secret = secretsController.getShared(caller, ownerUsername, secretName);
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 deleteAllSecrets.
@DELETE
@Path("secrets")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Deletes all secrets of a user")
@ApiKeyRequired(acceptedScopes = { ApiScope.USER }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response deleteAllSecrets(@Context SecurityContext sc, @Context HttpServletRequest req) throws UserException {
Users user = jWTHelper.getUserPrincipal(sc);
secretsController.deleteAll(user);
return Response.ok().build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class UsersResource method gitProviders.
@ApiOperation(value = "Get git providers with the configured secrets", response = GitProviderSecretsDTO.class)
@GET
@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 gitProviders(@Context SecurityContext sc, @Context UriInfo uriInfo) {
Users user = jWTHelper.getUserPrincipal(sc);
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 KafkaResource method getSchema.
@ApiOperation(value = "Get avro schema of a subject and version.")
@GET
@Path("/subjects/{subject}/versions/{version}/schema")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.KAFKA }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getSchema(@PathParam("subject") String subject, @PathParam("version") String version, @Context SecurityContext sc) {
try {
SubjectDTO dto = subjectsController.getSubjectDetails(project, subject, version);
GenericEntity<String> entity = new GenericEntity<String>(dto.getSchema()) {
};
return Response.ok().entity(entity).build();
} catch (SchemaException e) {
SchemaRegistryError error = new SchemaRegistryError(e.getErrorCode().getCode(), e.getErrorCode().getMessage());
return Response.status(e.getErrorCode().getRespStatus()).entity(error).build();
}
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class KafkaResource method addAclsToTopic.
@ApiOperation(value = "Add a new ACL for a specified topic.")
@POST
@Path("/topics/{topic}/acls")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.KAFKA }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response addAclsToTopic(@Context UriInfo uriInfo, @PathParam("topic") String topicName, AclDTO aclDto, @Context SecurityContext sc) throws KafkaException, ProjectException, UserException {
Pair<TopicAcls, Response.Status> aclTuple = kafkaController.addAclsToTopic(topicName, project.getId(), aclDto);
AclDTO dto = aclBuilder.build(uriInfo, aclTuple.getLeft());
return Response.status(aclTuple.getRight()).entity(dto).build();
}
Aggregations