Skip to content

Commit

Permalink
Merge branch 'couchbase/7.6.0' into trinity
Browse files Browse the repository at this point in the history
 * MB-60429: audit properly convert unknown domains

Change-Id: I0478fe479c4dc53c258303254ce4cddf792e56d7
  • Loading branch information
bryandmc committed Feb 2, 2024
2 parents da80161 + e27ab15 commit 13b530a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/menelaus_web_audit.erl
Expand Up @@ -86,6 +86,8 @@ audit_user_exists({_, ExtOrUnknown}) when ExtOrUnknown =:= external
%% since external users might not exist in CB users database and still be
%% able to perform auditable actions
true;
audit_user_exists({_, bad_domain}) ->
false;
audit_user_exists(Identity) ->
SpecIds = [{N, local} || N <- memcached_permissions:spec_users()],
menelaus_users:user_exists(Identity) orelse lists:member(Identity, SpecIds).
Expand Down Expand Up @@ -210,7 +212,7 @@ validate_users(Name, State) ->
UsersFound =
lists:map(
fun ({U, [N, S]}) ->
Identity = {N, menelaus_web_rbac:domain_to_atom(S)},
Identity = {N, domain_to_atom(S)},
case audit_user_exists(Identity) of
true ->
Identity;
Expand All @@ -229,6 +231,17 @@ validate_users(Name, State) ->
end
end, Name, State).

known_domains() ->
["local", "external", "unknown"].

domain_to_atom(Domain) ->
case lists:member(Domain, known_domains()) of
true ->
list_to_atom(Domain);
false ->
bad_domain
end.

validators(Config) ->
Descriptors = orddict:from_list(ns_audit_cfg:get_descriptors(Config)),
[validator:has_params(_),
Expand Down
1 change: 0 additions & 1 deletion src/menelaus_web_rbac.erl
Expand Up @@ -44,7 +44,6 @@
handle_get_password_policy/1,
handle_post_password_policy/1,
assert_no_users_upgrade/0,
domain_to_atom/1,
handle_put_group/2,
handle_delete_group/2,
handle_get_groups/2,
Expand Down

0 comments on commit 13b530a

Please sign in to comment.