Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduced error cases to supress case_clause errors because of bifrost delayed response. #3408

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/oc_erchef/apps/oc_chef_authz/src/oc_chef_authz.erl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ create_entity_if_authorized(Context, OrgId, CreatorAId, ObjectType) ->
{error, forbidden};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will still fail with a 500 in case of a non-forbidden error return, which I think is correct - but it does mean that we'll potentially lose logging/error info here. Let's create a new issue to confirm & fix that if needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - I think it would be useful to add the matcher for the {error, Error} case from

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That error would also need to propogate all the way up through

case oc_chef_authz:create_entity_if_authorized(AuthzCtx, OrgId, superuser, Type) of
,
Result = oc_chef_authz:create_entity_if_authorized(Context#context.authz_context,
,
case oc_chef_authz:create_entity_if_authorized(AuthzContext, OrgId,
into the modules calling those functions.

true ->
create_entity_with_container_acl(CreatorAId, ContainerAId, ObjectType)

end.

%%%
Expand Down Expand Up @@ -318,7 +319,7 @@ get_data_for_id([Id | _Ids] = OIds , [{RId, RData} | Resources], Denied, Permitt
%
-spec is_authorized_on_resource(requestor_id(), resource_type(), object_id(),
'actor'|'group', actor_id(), access_method())
-> true|false|{error,server_error}.
-> true|false|{error,any()}.
is_authorized_on_resource(RequestorId, ResourceType, ResourceId, ActorType, ActorId, AccessMethod)
when is_atom(ResourceType) and is_atom(ActorType) and is_atom(AccessMethod) ->
Url = make_url([pluralize_resource(ResourceType), ResourceId, <<"acl">>,
Expand All @@ -328,7 +329,7 @@ is_authorized_on_resource(RequestorId, ResourceType, ResourceId, ActorType, Acto
%% This api returns not found for any missing permission
{error, not_found} -> false;
%% Otherwise, we expect server_error; not forbidden
{error, server_error} -> {error, server_error}
{error, Error} -> {error, Error}
end.

%
Expand Down