use of org.apache.nifi.registry.authorization.AccessPolicySummary in project nifi-registry by apache.
the class AuthorizationService method accessPolicyToSummaryDTO.
private AccessPolicySummary accessPolicyToSummaryDTO(final org.apache.nifi.registry.security.authorization.AccessPolicy accessPolicy) {
if (accessPolicy == null) {
return null;
}
Boolean isConfigurable = AuthorizerCapabilityDetection.isAccessPolicyConfigurable(authorizer, accessPolicy);
final AccessPolicySummary accessPolicySummaryDTO = new AccessPolicySummary();
accessPolicySummaryDTO.setIdentifier(accessPolicy.getIdentifier());
accessPolicySummaryDTO.setAction(accessPolicy.getAction().toString());
accessPolicySummaryDTO.setResource(accessPolicy.getResource());
accessPolicySummaryDTO.setConfigurable(isConfigurable);
return accessPolicySummaryDTO;
}
use of org.apache.nifi.registry.authorization.AccessPolicySummary in project nifi-registry by apache.
the class AuthorizationService method userToDTO.
private User userToDTO(final org.apache.nifi.registry.security.authorization.User user) {
if (user == null) {
return null;
}
String userIdentifier = user.getIdentifier();
Collection<Tenant> groupsContainingUser = userGroupProvider.getGroups().stream().filter(group -> group.getUsers().contains(userIdentifier)).map(this::tenantToDTO).collect(Collectors.toList());
Collection<AccessPolicySummary> accessPolicySummaries = getAccessPolicySummariesForUser(userIdentifier);
User userDTO = new User(user.getIdentifier(), user.getIdentity());
userDTO.setConfigurable(AuthorizerCapabilityDetection.isUserConfigurable(authorizer, user));
userDTO.setResourcePermissions(getTopLevelPermissions(userDTO.getIdentifier()));
userDTO.addUserGroups(groupsContainingUser);
userDTO.addAccessPolicies(accessPolicySummaries);
return userDTO;
}
use of org.apache.nifi.registry.authorization.AccessPolicySummary in project nifi-registry by apache.
the class SecureLdapIT method createAccessPoliciesSnapshot.
private List<AccessPolicy> createAccessPoliciesSnapshot() {
final AccessPolicySummary[] policySummaries = client.target(createURL("policies")).request().header("Authorization", "Bearer " + adminAuthToken).get(AccessPolicySummary[].class);
final List<AccessPolicy> policies = new ArrayList<>(policySummaries.length);
for (AccessPolicySummary s : policySummaries) {
AccessPolicy policy = client.target(createURL("policies/" + s.getIdentifier())).request().header("Authorization", "Bearer " + adminAuthToken).get(AccessPolicy.class);
policies.add(policy);
}
return policies;
}
use of org.apache.nifi.registry.authorization.AccessPolicySummary in project nifi-registry by apache.
the class SecureLdapIT method getPolicyByResourceAction.
/**
* A helper method to lookup access policies
*
* @return A string containing the identifier of the policy, or null if the policy identity is not found.
*/
private AccessPolicy getPolicyByResourceAction(String action, String resource) {
final AccessPolicySummary[] policies = client.target(createURL("policies")).request().header("Authorization", "Bearer " + adminAuthToken).get(AccessPolicySummary[].class);
final AccessPolicySummary matchedPolicy = Arrays.stream(policies).filter(p -> p.getAction().equalsIgnoreCase(action) && p.getResource().equalsIgnoreCase(resource)).findFirst().orElse(null);
if (matchedPolicy == null) {
return null;
}
String policyId = matchedPolicy.getIdentifier();
final AccessPolicy policy = client.target(createURL("policies/" + policyId)).request().header("Authorization", "Bearer " + adminAuthToken).get(AccessPolicy.class);
return policy;
}
use of org.apache.nifi.registry.authorization.AccessPolicySummary in project nifi-registry by apache.
the class AuthorizationService method userGroupToDTO.
private UserGroup userGroupToDTO(final org.apache.nifi.registry.security.authorization.Group userGroup) {
if (userGroup == null) {
return null;
}
Collection<Tenant> userTenants = userGroup.getUsers() != null ? userGroup.getUsers().stream().map(this::tenantIdToDTO).collect(Collectors.toSet()) : null;
Collection<AccessPolicySummary> accessPolicySummaries = getAccessPolicySummariesForUserGroup(userGroup.getIdentifier());
UserGroup userGroupDTO = new UserGroup(userGroup.getIdentifier(), userGroup.getName());
userGroupDTO.setConfigurable(AuthorizerCapabilityDetection.isGroupConfigurable(authorizer, userGroup));
userGroupDTO.setResourcePermissions(getTopLevelPermissions(userGroupDTO.getIdentifier()));
userGroupDTO.addUsers(userTenants);
userGroupDTO.addAccessPolicies(accessPolicySummaries);
return userGroupDTO;
}
Aggregations