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

[Backport] Initialize document subset bit set cache used for DLS (#46211) #46359

Merged
merged 2 commits into from
Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,6 @@ Collection<Object> createComponents(Client client, ThreadPool threadPool, Cluste
securityContext.set(new SecurityContext(settings, threadPool.getThreadContext()));
components.add(securityContext.get());

if (XPackSettings.DLS_FLS_ENABLED.get(settings)) {
dlsBitsetCache.set(new DocumentSubsetBitsetCache(settings));
}

// audit trail service construction
final List<AuditTrail> auditTrails = XPackSettings.AUDIT_ENABLED.get(settings)
? Collections.singletonList(new LoggingAuditTrail(settings, clusterService, threadPool))
Expand Down Expand Up @@ -453,6 +449,7 @@ Collection<Object> createComponents(Client client, ThreadPool threadPool, Cluste
final NativePrivilegeStore privilegeStore = new NativePrivilegeStore(settings, client, securityIndex.get());
components.add(privilegeStore);

dlsBitsetCache.set(new DocumentSubsetBitsetCache(settings));
final FieldPermissionsCache fieldPermissionsCache = new FieldPermissionsCache(settings);
final FileRolesStore fileRolesStore = new FileRolesStore(settings, env, resourceWatcherService, getLicenseState());
final NativeRolesStore nativeRolesStore = new NativeRolesStore(settings, client, getLicenseState(), securityIndex.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,17 @@ public CompositeRolesStore(Settings settings, FileRolesStore fileRolesStore, Nat
ReservedRolesStore reservedRolesStore, NativePrivilegeStore privilegeStore,
List<BiConsumer<Set<String>, ActionListener<RoleRetrievalResult>>> rolesProviders,
ThreadContext threadContext, XPackLicenseState licenseState, FieldPermissionsCache fieldPermissionsCache,
ApiKeyService apiKeyService, @Nullable DocumentSubsetBitsetCache dlsBitsetCache,
ApiKeyService apiKeyService, DocumentSubsetBitsetCache dlsBitsetCache,
Consumer<Collection<RoleDescriptor>> effectiveRoleDescriptorsConsumer) {
this.fileRolesStore = fileRolesStore;
this.dlsBitsetCache = dlsBitsetCache;
this.fileRolesStore = Objects.requireNonNull(fileRolesStore);
this.dlsBitsetCache = Objects.requireNonNull(dlsBitsetCache);
fileRolesStore.addListener(this::invalidate);
this.nativeRolesStore = nativeRolesStore;
this.privilegeStore = privilegeStore;
this.licenseState = licenseState;
this.fieldPermissionsCache = fieldPermissionsCache;
this.apiKeyService = apiKeyService;
this.effectiveRoleDescriptorsConsumer = effectiveRoleDescriptorsConsumer;
this.nativeRolesStore = Objects.requireNonNull(nativeRolesStore);
this.privilegeStore = Objects.requireNonNull(privilegeStore);
this.licenseState = Objects.requireNonNull(licenseState);
this.fieldPermissionsCache = Objects.requireNonNull(fieldPermissionsCache);
this.apiKeyService = Objects.requireNonNull(apiKeyService);
this.effectiveRoleDescriptorsConsumer = Objects.requireNonNull(effectiveRoleDescriptorsConsumer);
CacheBuilder<RoleKey, Role> builder = CacheBuilder.builder();
final int cacheSize = CACHE_SIZE_SETTING.get(settings);
if (cacheSize >= 0) {
Expand Down Expand Up @@ -415,9 +415,7 @@ public void invalidateAll() {
try (ReleasableLock ignored = roleCacheHelper.acquireUpdateLock()) {
roleCache.invalidateAll();
}
if (dlsBitsetCache != null) {
dlsBitsetCache.clear("role store invalidation");
}
dlsBitsetCache.clear("role store invalidation");
}

public void invalidate(String role) {
Expand Down
Loading