Open Amorik opened 4 years ago
This is certainly odd behavior, and could be a bug. I'll dig into it and see what I can find...
We see the data for the global /policies
resource because the root process group inherits it. The NiFi WebUI handles it by checking if the returned resource matches the requested one (Web UI Check). The bug is from the PoliciesApi
get_access_policy_for_resource not performing that check.
Not sure how you could fix it for the regular method as well as the callback one.
~This is a bug in Nifi and it's API. The fact that the Nifi Web UI ( 1 specific client ) accounts for this is wrong. if the api provides it it is either right or an api bug~
Isn't this just a case of policy inheritance though? The root-pg starts with the global policies and you can override them through the API. This is the Jira issue that implemented the check for the Web UI.
OK, I miss understood something. It is policy inheritance as you say. The method is documented as:
"""
Gets an access policy for the specified action and resource
Will return the effective policy if no component specific policy exists for the specified action and resource. Must have Read permissions to the policy with the desired action and resource. Permissions for the policy that is returned will be indicated in the response. This means the client could be authorized to get the policy for a given component but the effective policy may be inherited from an ancestor Process Group. If the client does not have permissions to that policy, the response will not include the policy and the permissions in the response will be marked accordingly. If the client does not have permissions to the policy of the desired action and resource a 403 response will be returned.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
So it is working as it is documented. The policy, though inherited is the policy for that component, so I think this api is working correctly. I think that the caller can perform the check as you found in the webui, or maybe a new higher level function the behaves the way you are expecting could work?
Description
By default NiFi does not add any policies to the root canvas resource, so used nipyapi to do this for a handful of test accounts, including the initial admin. This worked for the majority of the resources with the exception of the
/policies/process-groups/
Attempting to use the function
get_access_policy_for_resource
with the resource/policies/process-group
results in the return of the policy of the global resource/policies
.Response should have been of the type
None
or if the argumentauto_create
was set toTrue
create the policy and return it. If the policy was per-existing (created manually or via the UI) then the correct response is returned.What I Did
Example Snippet:
Result:
Note that setting
auto_create
toTrue
ends in the same result. Between each test theauthorizations.xml
files was confirmed not to have changed and never contained the desired policy.I have not tested this against other component-types.
Urgency
Not urgent.
To workaround the issue I've taken to using the
create_access_policy
and just ignore errors when attempting to create policies for/policies/process-group
.