Topi Hernández Mares
06/16/2022, 2:51 PMdef is_allowed(
self,
action: str,
principal: Principal,
resource: Resource,
request_id: Optional[str] = None,
aux_data: Optional[AuxData] = None,
) -> bool:
"""Check permission for a single action
Args:
action (str): action being performed
principal (Principal): principal who is performing the action
resource (Resource): resource on which the action is being performed
request_id (None|str): request ID for the request (default None)
aux_data (None|AuxData): auxiliary data for the request
"""
resp = self.check_resources(
principal=principal,
resources=ResourceList().add(resource, {action}),
request_id=request_id,
aux_data=aux_data,
)
> return resp.get_resource(resource.id).is_allowed(action)
E AttributeError: 'NoneType' object has no attribute 'is_allowed'
I've been looking at the client code and I found that get_resource
returns None
when the request fails, but I don't know what is failing.Charith (Cerbos)
raise_on_error=True
when constructing the Cerbos client. That could give you an idea by throwing an exception.
• Set debug=True
(and maybe logger
as well) and you should be able to see the requests and responsesTopi Hernández Mares
06/16/2022, 2:58 PMCharith (Cerbos)
resp.status_msg
.Topi Hernández Mares
06/16/2022, 3:05 PMresp
?Topi Hernández Mares
06/16/2022, 3:05 PMCharith (Cerbos)
resp
you have in the above example.Topi Hernández Mares
06/16/2022, 3:08 PMTopi Hernández Mares
06/16/2022, 4:06 PMCharith (Cerbos)
Topi Hernández Mares
06/16/2022, 4:07 PM400
because I wasn't sending roles in my PrincipalTopi Hernández Mares
06/16/2022, 4:08 PM'{"code":3, "message":"invalid CheckResourcesRequest.Principal: embedded message failed validation | caused by: invalid Principal.Roles: value must contain at least 1 item(s)"}'}
Charith (Cerbos)