use of org.apache.nifi.registry.authorization.Permissions in project nifi-registry by apache.
the class UnsecuredNiFiRegistryClientIT method testGetAccessStatus.
@Test
public void testGetAccessStatus() throws IOException, NiFiRegistryException {
final UserClient userClient = client.getUserClient();
final CurrentUser currentUser = userClient.getAccessStatus();
Assert.assertEquals("anonymous", currentUser.getIdentity());
Assert.assertTrue(currentUser.isAnonymous());
Assert.assertNotNull(currentUser.getResourcePermissions());
Permissions fullAccess = new Permissions().withCanRead(true).withCanWrite(true).withCanDelete(true);
Assert.assertEquals(fullAccess, currentUser.getResourcePermissions().getAnyTopLevelResource());
Assert.assertEquals(fullAccess, currentUser.getResourcePermissions().getBuckets());
Assert.assertEquals(fullAccess, currentUser.getResourcePermissions().getTenants());
Assert.assertEquals(fullAccess, currentUser.getResourcePermissions().getPolicies());
Assert.assertEquals(fullAccess, currentUser.getResourcePermissions().getProxy());
}
use of org.apache.nifi.registry.authorization.Permissions in project nifi-registry by apache.
the class AuthorizationService method getPermissionsForResource.
private Permissions getPermissionsForResource(String tenantIdentifier, org.apache.nifi.registry.security.authorization.Resource resource) {
Permissions permissions = new Permissions();
permissions.setCanRead(checkTenantBelongsToPolicy(tenantIdentifier, resource, RequestAction.READ));
permissions.setCanWrite(checkTenantBelongsToPolicy(tenantIdentifier, resource, RequestAction.WRITE));
permissions.setCanDelete(checkTenantBelongsToPolicy(tenantIdentifier, resource, RequestAction.DELETE));
return permissions;
}
use of org.apache.nifi.registry.authorization.Permissions in project nifi-registry by apache.
the class AuthorizationService method getPermissionsForResource.
public Permissions getPermissionsForResource(Authorizable authorizableResource, Permissions knownParentAuthorizablePermissions) {
if (knownParentAuthorizablePermissions == null) {
return getPermissionsForResource(authorizableResource);
}
final Permissions permissions = new Permissions(knownParentAuthorizablePermissions);
NiFiUser user = NiFiUserUtils.getNiFiUser();
if (!permissions.getCanRead()) {
permissions.setCanRead(authorizableResource.isAuthorized(authorizer, RequestAction.READ, user));
}
if (!permissions.getCanWrite()) {
permissions.setCanWrite(authorizableResource.isAuthorized(authorizer, RequestAction.WRITE, user));
}
if (!permissions.getCanDelete()) {
permissions.setCanDelete(authorizableResource.isAuthorized(authorizer, RequestAction.DELETE, user));
}
return permissions;
}
use of org.apache.nifi.registry.authorization.Permissions 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.authorization.Permissions in project nifi-registry by apache.
the class PermissionsService method populateItemPermissions.
public void populateItemPermissions(final Iterable<? extends BucketItem> bucketItems) {
Permissions topLevelBucketPermissions = authorizationService.getPermissionsForResource(authorizableLookup.getBucketsAuthorizable());
bucketItems.forEach(i -> populateItemPermissions(i, topLevelBucketPermissions));
}
Aggregations