Allow transactions and batches with transaction permission in

AuthorizationInterceptor
This commit is contained in:
James Agnew 2018-10-16 19:54:55 -04:00
parent 0fbe897ca4
commit 4e252063b8
6 changed files with 21 additions and 7 deletions

View File

@ -83,7 +83,8 @@ public interface IAuthRuleBuilderRule {
/** /**
* This rule applies to the FHIR transaction operation. Transaction is a special * This rule applies to the FHIR transaction operation. Transaction is a special
* case in that it bundles other operations * case in that it bundles other operations. This permission also allows FHIR
* batch to be performed.
*/ */
IAuthRuleBuilderRuleTransaction transaction(); IAuthRuleBuilderRuleTransaction transaction();

View File

@ -223,7 +223,6 @@ public class RuleBuilder implements IAuthRuleBuilder {
@Override @Override
public IAuthRuleBuilderRuleTransaction transaction() { public IAuthRuleBuilderRuleTransaction transaction() {
myRuleOp = RuleOpEnum.TRANSACTION;
return new RuleBuilderRuleTransaction(); return new RuleBuilderRuleTransaction();
} }
@ -520,11 +519,20 @@ public class RuleBuilder implements IAuthRuleBuilder {
@Override @Override
public IAuthRuleBuilderRuleOpClassifierFinished andApplyNormalRules() { public IAuthRuleBuilderRuleOpClassifierFinished andApplyNormalRules() {
// Allow transaction
RuleImplOp rule = new RuleImplOp(myRuleName); RuleImplOp rule = new RuleImplOp(myRuleName);
rule.setMode(myRuleMode); rule.setMode(myRuleMode);
rule.setOp(myRuleOp); rule.setOp(RuleOpEnum.TRANSACTION);
rule.setTransactionAppliesToOp(TransactionAppliesToEnum.ANY_OPERATION); rule.setTransactionAppliesToOp(TransactionAppliesToEnum.ANY_OPERATION);
myRules.add(rule); myRules.add(rule);
// Allow batch
rule = new RuleImplOp(myRuleName);
rule.setMode(myRuleMode);
rule.setOp(RuleOpEnum.BATCH);
rule.setTransactionAppliesToOp(TransactionAppliesToEnum.ANY_OPERATION);
myRules.add(rule);
return new RuleBuilderFinished(rule); return new RuleBuilderFinished(rule);
} }

View File

@ -262,7 +262,7 @@ public class AuthorizationInterceptorDstu2Test {
httpPost.setEntity(createFhirResourceEntity(input)); httpPost.setEntity(createFhirResourceEntity(input));
status = ourClient.execute(httpPost); status = ourClient.execute(httpPost);
extractResponseAndClose(status); extractResponseAndClose(status);
assertEquals(403, status.getStatusLine().getStatusCode()); assertEquals(200, status.getStatusLine().getStatusCode());
} }
@Test @Test

View File

@ -495,7 +495,7 @@ public class AuthorizationInterceptorDstu3Test {
httpPost.setEntity(createFhirResourceEntity(input)); httpPost.setEntity(createFhirResourceEntity(input));
status = ourClient.execute(httpPost); status = ourClient.execute(httpPost);
extractResponseAndClose(status); extractResponseAndClose(status);
assertEquals(403, status.getStatusLine().getStatusCode()); assertEquals(200, status.getStatusLine().getStatusCode());
} }
@Test @Test

View File

@ -469,7 +469,7 @@ public class AuthorizationInterceptorR4Test {
} }
@Test @Test
public void testBatchWhenOnlyTransactionAllowed() throws Exception { public void testBatchAllowed() throws Exception {
ourServlet.registerInterceptor(new AuthorizationInterceptor(PolicyEnum.DENY) { ourServlet.registerInterceptor(new AuthorizationInterceptor(PolicyEnum.DENY) {
@Override @Override
public List<IAuthRule> buildRuleList(RequestDetails theRequestDetails) { public List<IAuthRule> buildRuleList(RequestDetails theRequestDetails) {
@ -498,7 +498,7 @@ public class AuthorizationInterceptorR4Test {
httpPost.setEntity(createFhirResourceEntity(input)); httpPost.setEntity(createFhirResourceEntity(input));
status = ourClient.execute(httpPost); status = ourClient.execute(httpPost);
extractResponseAndClose(status); extractResponseAndClose(status);
assertEquals(403, status.getStatusLine().getStatusCode()); assertEquals(200, status.getStatusLine().getStatusCode());
} }
@Test @Test

View File

@ -95,6 +95,11 @@
When using the testpage overlay to delete a resource, currently a crash can occur When using the testpage overlay to delete a resource, currently a crash can occur
if an unqualified ID is placed in the ID text box. This has been corrected. if an unqualified ID is placed in the ID text box. This has been corrected.
</action> </action>
<action type="fix">
AuthorizationInterceptor did not allow FHIR batch operations when the transaction()
permission is granted. This has been corrected so that transaction() allows both
batch and transaction requests to proceed.
</action>
</release> </release>
<release version="3.5.0" date="2018-09-17"> <release version="3.5.0" date="2018-09-17">