Skip to content

Commit a4beb72

Browse files
authored
Include mapped roles when setting userInfo in ThreadContext (#5369)
Signed-off-by: Craig Perkins <cwperx@amazon.com>
1 parent 03207f2 commit a4beb72

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1313
- Use extendedPlugins in integrationTest framework for sample resource plugin testing ([#5322](https://github.com/opensearch-project/security/pull/5322))
1414
- Refactor ResourcePermissions to refer to action groups as access levels ([#5335](https://github.com/opensearch-project/security/pull/5335))
1515
- Introduced new, performance-optimized implementation for tenant privileges ([#5339](https://github.com/opensearch-project/security/pull/5339))
16-
17-
- Performance improvements: Immutable user object ([#5212])
16+
- Performance improvements: Immutable user object ([#5212](https://github.com/opensearch-project/security/pull/5212))
17+
- Include mapped roles when setting userInfo in ThreadContext ([#5369](https://github.com/opensearch-project/security/pull/5369))
1818

1919
### Dependencies
2020
- Bump `guava_version` from 33.4.6-jre to 33.4.8-jre ([#5284](https://github.com/opensearch-project/security/pull/5284))

src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,13 @@ public boolean isInitialized() {
279279
return configModel != null && dcm != null && actionPrivileges.get() != null;
280280
}
281281

282-
private void setUserInfoInThreadContext(User user) {
282+
private void setUserInfoInThreadContext(User user, Set<String> mappedRoles) {
283283
if (threadContext.getTransient(OPENDISTRO_SECURITY_USER_INFO_THREAD_CONTEXT) == null) {
284284
StringJoiner joiner = new StringJoiner("|");
285285
// Escape any pipe characters in the values before joining
286286
joiner.add(escapePipe(user.getName()));
287287
joiner.add(escapePipe(String.join(",", user.getRoles())));
288-
joiner.add(escapePipe(String.join(",", user.getSecurityRoles())));
288+
joiner.add(escapePipe(String.join(",", mappedRoles)));
289289

290290
String requestedTenant = user.getRequestedTenant();
291291
if (!Strings.isNullOrEmpty(requestedTenant)) {
@@ -357,7 +357,7 @@ public PrivilegesEvaluatorResponse evaluate(PrivilegesEvaluationContext context)
357357
context.setMappedRoles(mappedRoles);
358358
}
359359

360-
setUserInfoInThreadContext(user);
360+
setUserInfoInThreadContext(user, mappedRoles);
361361

362362
final boolean isDebugEnabled = log.isDebugEnabled();
363363
if (isDebugEnabled) {

0 commit comments

Comments
 (0)