Search in sources :

Example 86 with ApiKeyRequired

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();
}
Also used : RESTApiJsonResponse(io.hops.hopsworks.api.util.RESTApiJsonResponse) Users(io.hops.hopsworks.persistence.entity.user.Users) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)

Example 87 with ApiKeyRequired

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();
}
Also used : ServingWrapper(io.hops.hopsworks.common.serving.ServingWrapper) GenericEntity(javax.ws.rs.core.GenericEntity) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 88 with ApiKeyRequired

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();
}
Also used : Users(io.hops.hopsworks.persistence.entity.user.Users) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)

Example 89 with ApiKeyRequired

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();
}
Also used : Users(io.hops.hopsworks.persistence.entity.user.Users) SecretPlaintext(io.hops.hopsworks.common.dao.user.security.secrets.SecretPlaintext) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)

Example 90 with ApiKeyRequired

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();
}
Also used : Users(io.hops.hopsworks.persistence.entity.user.Users) SecretPlaintext(io.hops.hopsworks.common.dao.user.security.secrets.SecretPlaintext) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)

Aggregations

ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)175 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)171 ApiOperation (io.swagger.annotations.ApiOperation)169 Produces (javax.ws.rs.Produces)165 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)159 Path (javax.ws.rs.Path)124 Users (io.hops.hopsworks.persistence.entity.user.Users)116 GET (javax.ws.rs.GET)96 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)94 Consumes (javax.ws.rs.Consumes)45 DatasetPath (io.hops.hopsworks.common.dataset.util.DatasetPath)38 POST (javax.ws.rs.POST)32 DELETE (javax.ws.rs.DELETE)26 GenericEntity (javax.ws.rs.core.GenericEntity)25 PUT (javax.ws.rs.PUT)23 TagsDTO (io.hops.hopsworks.common.tags.TagsDTO)15 Featuregroup (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup)11 UriBuilder (javax.ws.rs.core.UriBuilder)11 Project (io.hops.hopsworks.persistence.entity.project.Project)10 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)9