Skip to content

Commit

Permalink
Additional trace logging for Native Role Mappings
Browse files Browse the repository at this point in the history
Adds trace logging in a couple of places in `NativeRoleMappingStore`
to assist in debugging the sequence of changes from role mapping
update (e.g. via `ReservedRoleMappingAction`) and the resolution of
user access
  • Loading branch information
tvernum committed Sep 29, 2023
1 parent ae17505 commit 2ae5bf5
Showing 1 changed file with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,17 @@ protected void loadMappings(ActionListener<List<ExpressionRoleMapping>> listener
ScrollHelper.fetchAllByEntity(
client,
request,
new ContextPreservingActionListener<>(
supplier,
ActionListener.wrap(
(Collection<ExpressionRoleMapping> mappings) -> listener.onResponse(
mappings.stream().filter(Objects::nonNull).toList()
),
ex -> {
logger.error(
() -> format("failed to load role mappings from index [%s] skipping all mappings.", SECURITY_MAIN_ALIAS),
ex
);
listener.onResponse(Collections.emptyList());
}
)
),
new ContextPreservingActionListener<>(supplier, ActionListener.wrap((Collection<ExpressionRoleMapping> mappings) -> {
final List<ExpressionRoleMapping> mappingList = mappings.stream().filter(Objects::nonNull).toList();
logger.debug("successfully loaded [{}] role-mapping(s) from [{}]", mappingList.size(), securityIndex.aliasName());
listener.onResponse(mappingList);
}, ex -> {
logger.error(
() -> format("failed to load role mappings from index [%s] skipping all mappings.", SECURITY_MAIN_ALIAS),
ex
);
listener.onResponse(Collections.emptyList());
})),
doc -> buildMapping(getNameFromId(doc.getId()), doc.getSourceRef())
);
}
Expand Down Expand Up @@ -200,6 +196,7 @@ private <Request, Result> void modifyMapping(
);
} else {
try {
logger.trace("Modifying role mapping [{}] for [{}]", name, request.getClass().getSimpleName());
inner.accept(request, ActionListener.wrap(r -> refreshRealms(listener, r), listener::onFailure));
} catch (Exception e) {
logger.error(() -> "failed to modify role-mapping [" + name + "]", e);
Expand Down

0 comments on commit 2ae5bf5

Please sign in to comment.