Search in sources :

Example 6 with CurrentUser

use of org.apache.nifi.registry.authorization.CurrentUser in project nifi-registry by apache.

the class AccessResource method getAccessStatus.

/**
 * Gets the current client's identity and authorized permissions.
 *
 * @param httpServletRequest the servlet request
 * @return An object describing the current client identity, as determined by the server, and it's permissions.
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Returns the current client's authenticated identity and permissions to top-level resources", response = CurrentUser.class, authorizations = { @Authorization(value = "Authorization") })
@ApiResponses({ @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409 + " The NiFi Registry might be running unsecured.") })
public Response getAccessStatus(@Context HttpServletRequest httpServletRequest) {
    final NiFiUser user = NiFiUserUtils.getNiFiUser();
    if (user == null) {
        // Not expected to happen unless the nifi registry server has been seriously misconfigured.
        throw new WebApplicationException(new Throwable("Unable to access details for current user."));
    }
    final CurrentUser currentUser = authorizationService.getCurrentUser();
    return generateOkResponse(currentUser).build();
}
Also used : NiFiUser(org.apache.nifi.registry.security.authorization.user.NiFiUser) WebApplicationException(javax.ws.rs.WebApplicationException) CurrentUser(org.apache.nifi.registry.authorization.CurrentUser) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

CurrentUser (org.apache.nifi.registry.authorization.CurrentUser)6 Test (org.junit.Test)4 Permissions (org.apache.nifi.registry.authorization.Permissions)3 UserClient (org.apache.nifi.registry.client.UserClient)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 NiFiUser (org.apache.nifi.registry.security.authorization.user.NiFiUser)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Response (javax.ws.rs.core.Response)1 AccessPolicy (org.apache.nifi.registry.authorization.AccessPolicy)1 Tenant (org.apache.nifi.registry.authorization.Tenant)1 Bucket (org.apache.nifi.registry.bucket.Bucket)1