Skip to content

Commit ebd8999

Browse files
moar fixes
1 parent 3931a0e commit ebd8999

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealm.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ private void authenticateWithCache(UsernamePasswordToken token, ActionListener<A
131131
});
132132
if (authenticationInCache.get()) {
133133
// there is a cached or an inflight authenticate request
134-
listenableCacheEntry.addListener(ActionListener.wrap(cachedResult -> {
134+
listenableCacheEntry.addListener(listener.delegateFailureAndWrap((delegate, cachedResult) -> {
135135
final boolean credsMatch = cachedResult.verify(token.credentials());
136136
if (cachedResult.authenticationResult.isAuthenticated()) {
137137
if (credsMatch) {
138138
// cached credential hash matches the credential hash for this forestalled request
139-
handleCachedAuthentication(cachedResult.user, ActionListener.wrap(authResult -> {
139+
handleCachedAuthentication(cachedResult.user, delegate.delegateFailureAndWrap((delegate2, authResult) -> {
140140
if (authResult.isAuthenticated()) {
141141
logger.debug(
142142
"realm [{}] authenticated user [{}], with roles [{}] (cached)",
@@ -152,8 +152,8 @@ private void authenticateWithCache(UsernamePasswordToken token, ActionListener<A
152152
authResult.getMessage()
153153
);
154154
}
155-
listener.onResponse(authResult);
156-
}, listener::onFailure));
155+
delegate2.onResponse(authResult);
156+
}));
157157
} else {
158158
logger.trace(
159159
"realm [{}], provided credentials for user [{}] do not match (known good) cached credentials,"
@@ -166,7 +166,7 @@ private void authenticateWithCache(UsernamePasswordToken token, ActionListener<A
166166
// clear cache and try to reach the authentication source again because password
167167
// might have changed there and the local cached hash got stale
168168
cache.invalidate(token.principal(), listenableCacheEntry);
169-
authenticateWithCache(token, listener);
169+
authenticateWithCache(token, delegate);
170170
}
171171
} else if (credsMatch) {
172172
// not authenticated but instead of hammering reuse the result. a new
@@ -178,7 +178,7 @@ private void authenticateWithCache(UsernamePasswordToken token, ActionListener<A
178178
cachedResult.authenticationResult.getStatus(),
179179
cachedResult.authenticationResult.getMessage()
180180
);
181-
listener.onResponse(cachedResult.authenticationResult);
181+
delegate.onResponse(cachedResult.authenticationResult);
182182
} else {
183183
logger.trace(
184184
"realm [{}], provided credentials for user [{}] do not match (possibly invalid) cached credentials,"
@@ -187,9 +187,9 @@ private void authenticateWithCache(UsernamePasswordToken token, ActionListener<A
187187
token.principal()
188188
);
189189
cache.invalidate(token.principal(), listenableCacheEntry);
190-
authenticateWithCache(token, listener);
190+
authenticateWithCache(token, delegate);
191191
}
192-
}, listener::onFailure), threadPool.executor(ThreadPool.Names.GENERIC), threadPool.getThreadContext());
192+
}), threadPool.executor(ThreadPool.Names.GENERIC), threadPool.getThreadContext());
193193
} else {
194194
logger.trace(
195195
"realm [{}] does not have a cached result for user [{}]; attempting fresh authentication",

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -828,24 +828,24 @@ private void authorizeBulkItems(
828828
AuditLevel.ACCESS_DENIED,
829829
authentication,
830830
action,
831-
resolvedIndicesSet.toArray(new String[0]),
831+
resolvedIndicesSet.toArray(Strings.EMPTY_ARRAY),
832832
BulkItemRequest.class.getSimpleName(),
833833
request.remoteAddress(),
834834
authzInfo
835835
)
836836
);
837-
actionToGrantedIndicesMap.forEach((action, resolvedIndicesSet) -> {
838-
auditTrail.explicitIndexAccessEvent(
837+
actionToGrantedIndicesMap.forEach(
838+
(action, resolvedIndicesSet) -> auditTrail.explicitIndexAccessEvent(
839839
requestId,
840840
AuditLevel.ACCESS_GRANTED,
841841
authentication,
842842
action,
843-
resolvedIndicesSet.toArray(new String[0]),
843+
resolvedIndicesSet.toArray(Strings.EMPTY_ARRAY),
844844
BulkItemRequest.class.getSimpleName(),
845845
request.remoteAddress(),
846846
authzInfo
847-
);
848-
});
847+
)
848+
);
849849
delegate2.onResponse(null);
850850
}
851851
);

0 commit comments

Comments
 (0)