Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6bba3cb
draft implementation - no support for typefilter yet
Oct 17, 2025
f795113
revise and create draft of new permissions arg format w/ implied reso…
Oct 20, 2025
4d57ea8
add new rule for group query, with tests
Oct 21, 2025
c80280d
Merge branch 'master' into jd-20251017-bulk-export-permissions
Oct 21, 2025
384ff31
- formatting
Oct 21, 2025
e070201
add Group rule builder code
Oct 21, 2025
33d0df7
implement basic Patient rule with tests
Oct 23, 2025
5575871
Implement rule building for patient by matcher
Oct 24, 2025
6ff269b
spotless
Oct 24, 2025
6c5d860
type level ITs, fix some tests and bugs
Oct 28, 2025
640c9ef
spotless
Oct 28, 2025
2f02a09
add javadocs, remove unused code after some design changes, updated s…
Oct 29, 2025
10fd885
spotless
Oct 29, 2025
af123a9
round 2 - add javadocs, remove unused code after some design changes,…
Oct 29, 2025
bd3ca50
round 4 - add javadocs, remove unused code after some design changes,…
Oct 29, 2025
5873e18
round 5 - remove todos
Oct 29, 2025
0d906c4
changelogs, more java docs
Oct 29, 2025
78324a9
Merge remote-tracking branch 'origin/rel_8_6' into jd-20251017-bulk-e…
Oct 29, 2025
9727733
round 1 of addressing review comments
Oct 30, 2025
f8b3d41
spotless
Oct 30, 2025
7fdc3a4
refactor rule classes to have a base class for common logic
Oct 30, 2025
31d143c
spotless
Oct 31, 2025
17ed1ad
Revert "spotless"
Oct 31, 2025
5f52b36
Revert "refactor rule classes to have a base class for common logic"
Oct 31, 2025
5390b9b
round 2 - address code review comments
Oct 31, 2025
1f83598
spotless
Oct 31, 2025
b50a5aa
draft implementation of combining RuleBuilder apis
Nov 17, 2025
d558587
spotless
Nov 17, 2025
544e815
query count test
Dec 2, 2025
1c83963
refactor rule classes to have a base class for common logic
Oct 30, 2025
e3cbb07
bring back refactor to simplify RuleBuilder api
Dec 2, 2025
02835c2
spotless
Dec 2, 2025
a1d3054
Merge remote-tracking branch 'origin/master' into jd-20251017-bulk-ex…
Dec 2, 2025
1f7fd13
make javadoc warning about AuthResourceResolver usage clearer
Dec 2, 2025
b864474
rename variable
Dec 3, 2025
28ceb79
Merge remote-tracking branch 'origin/master' into jd-20251017-bulk-ex…
Dec 3, 2025
6eaa1a3
address review - use UrlUtil/MatchUrlUtil
Dec 3, 2025
7301f7a
address review - refactor apply tester logic for patients
Dec 3, 2025
7fe9143
spotless
Dec 3, 2025
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
@@ -0,0 +1,4 @@
---
type: add
issue: 7342
title: "Enhanced the bulk export RuleBuilder code to support the identification of allowable Groups/Patients to export by a FHIR query matcher."
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
import ca.uhn.fhir.jpa.entity.TermValueSet;
import ca.uhn.fhir.jpa.esr.ExternallyStoredResourceServiceRegistry;
import ca.uhn.fhir.jpa.graphql.DaoRegistryGraphQLStorageServices;
import ca.uhn.fhir.jpa.interceptor.AuthResourceResolver;
import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor;
import ca.uhn.fhir.jpa.interceptor.JpaConsentContextServices;
import ca.uhn.fhir.jpa.interceptor.OverridePathBasedReferentialIntegrityForDeletesInterceptor;
Expand Down Expand Up @@ -205,6 +206,7 @@
import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId;
import ca.uhn.fhir.rest.server.interceptor.ResponseTerminologyTranslationInterceptor;
import ca.uhn.fhir.rest.server.interceptor.ResponseTerminologyTranslationSvc;
import ca.uhn.fhir.rest.server.interceptor.auth.IAuthResourceResolver;
import ca.uhn.fhir.rest.server.interceptor.consent.IConsentContextServices;
import ca.uhn.fhir.rest.server.interceptor.partition.RequestTenantPartitionInterceptor;
import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
Expand Down Expand Up @@ -530,6 +532,11 @@ public IConsentContextServices consentContextServices() {
return new JpaConsentContextServices();
}

@Bean
public IAuthResourceResolver authResourceResolver(DaoRegistry theDaoRegistry) {
return new AuthResourceResolver(theDaoRegistry);
}

@Bean
@Lazy
public DiffProvider diffProvider() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*-
* #%L
* HAPI FHIR JPA Server
* %%
* Copyright (C) 2014 - 2025 Smile CDR, Inc.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package ca.uhn.fhir.jpa.interceptor;

import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
import ca.uhn.fhir.rest.param.TokenOrListParam;
import ca.uhn.fhir.rest.server.interceptor.auth.IAuthResourceResolver;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;

import java.util.List;

/**
* Small service class to inject DB access into an interceptor
* For example, used in bulk export security to allow querying for resource to match against permission argument filters
*/
public class AuthResourceResolver implements IAuthResourceResolver {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me nervous. I get the design, but it's breaking the well-established pattern we have that auth interceptor doesn't resolve anything, it just looks at the data it's passed and makes a decision.

Instead of creating a loading infrastructure, could we add a new parameter object to STORAGE_PRE_INITIATE_BULK_EXPORT so that BulkExportJobService could handle loading the Group and pass it to AuthInterceptor as a part of the interceptor request? That way AuthInterceptor could look at it and make its decisions without needing to know how to fetch anything

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed during design, we will stick with this approach since there may be some other use cases for this, such as new features for permissioning with $meta and patch. Also, as discussed, added a query count test (BulkDataExportAuthorizationQueryCountTest) to ensure there are 2 select queries during authorization.

private final DaoRegistry myDaoRegistry;

public AuthResourceResolver(DaoRegistry myDaoRegistry) {
this.myDaoRegistry = myDaoRegistry;
}

public IBaseResource resolveResourceById(IIdType theResourceId) {
return myDaoRegistry
.getResourceDao(theResourceId.getResourceType())
.read(theResourceId, new SystemRequestDetails());
}

public List<IBaseResource> resolveResourcesByIds(List<String> theResourceIds, String theResourceType) {
TokenOrListParam t = new TokenOrListParam(null, theResourceIds.toArray(String[]::new));

SearchParameterMap m = new SearchParameterMap();
m.add(Constants.PARAM_ID, t);
return myDaoRegistry.getResourceDao(theResourceType).searchForResources(m, new SystemRequestDetails());
}
}
Loading
Loading