use of org.apache.nifi.registry.security.authorization.user.NiFiUser in project nifi-registry by apache.
the class AuthorizationService method getPermissionsForResource.
public Permissions getPermissionsForResource(Authorizable authorizableResource) {
NiFiUser user = NiFiUserUtils.getNiFiUser();
final Permissions permissions = new Permissions();
permissions.setCanRead(authorizableResource.isAuthorized(authorizer, RequestAction.READ, user));
permissions.setCanWrite(authorizableResource.isAuthorized(authorizer, RequestAction.WRITE, user));
permissions.setCanDelete(authorizableResource.isAuthorized(authorizer, RequestAction.DELETE, user));
return permissions;
}
use of org.apache.nifi.registry.security.authorization.user.NiFiUser in project nifi-registry by apache.
the class AuthorizationService method getCurrentUser.
// ---------------------- Permissions methods ---------------------------------------
public CurrentUser getCurrentUser() {
final NiFiUser user = NiFiUserUtils.getNiFiUser();
final CurrentUser currentUser = new CurrentUser();
currentUser.setIdentity(user.getIdentity());
currentUser.setAnonymous(user.isAnonymous());
currentUser.setResourcePermissions(getTopLevelPermissions());
return currentUser;
}
use of org.apache.nifi.registry.security.authorization.user.NiFiUser 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();
}
Aggregations