Class AuthorizationInterceptor
java.lang.Object
ca.uhn.fhir.rest.server.interceptor.auth.AuthorizationInterceptor
- All Implemented Interfaces:
IRuleApplier
This class is a base class for interceptors which can be used to
inspect requests and responses to determine whether the calling user
has permission to perform the given action.
See the HAPI FHIR Documentation on Server Security for information on how to use this interceptor.
- See Also:
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstructorAuthorizationInterceptor
(PolicyEnum theDefaultPolicy) Constructor -
Method Summary
Modifier and TypeMethodDescriptionapplyRulesAndReturnDecision
(ca.uhn.fhir.rest.api.RestOperationTypeEnum theOperation, RequestDetails theRequestDetails, org.hl7.fhir.instance.model.api.IBaseResource theInputResource, org.hl7.fhir.instance.model.api.IIdType theInputResourceId, org.hl7.fhir.instance.model.api.IBaseResource theOutputResource, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) buildRuleList
(RequestDetails theRequestDetails) Subclasses should override this method to supply the set of rules to be applied to this individual request.The default policy if no rules have been found to apply.getFlags()
This property configures any flags affecting how authorization is applied.org.slf4j.Logger
ca.uhn.fhir.context.support.IValidationSupport
protected void
handleDeny
(RequestDetails theRequestDetails, AuthorizationInterceptor.Verdict decision) Handle an access control verdict ofPolicyEnum.DENY
.protected void
handleDeny
(AuthorizationInterceptor.Verdict decision) This method should not be overridden.void
hookCascadeDeleteForConflict
(RequestDetails theRequestDetails, ca.uhn.fhir.interceptor.api.Pointcut thePointcut, org.hl7.fhir.instance.model.api.IBaseResource theResourceToDelete) void
hookDeleteExpunge
(RequestDetails theRequestDetails, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) void
hookOutgoingResponse
(RequestDetails theRequestDetails, org.hl7.fhir.instance.model.api.IBaseResource theResponseObject, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) void
hookPreShow
(RequestDetails theRequestDetails, IPreResourceShowDetails theDetails, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) void
hookResourcePreCreate
(RequestDetails theRequest, org.hl7.fhir.instance.model.api.IBaseResource theResource, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) void
hookResourcePreDelete
(RequestDetails theRequest, org.hl7.fhir.instance.model.api.IBaseResource theResource, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) void
hookResourcePreUpdate
(RequestDetails theRequest, org.hl7.fhir.instance.model.api.IBaseResource theOldResource, org.hl7.fhir.instance.model.api.IBaseResource theNewResource, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) void
incomingRequestPreHandled
(RequestDetails theRequest, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) void
initiateBulkExport
(RequestDetails theRequestDetails, BulkExportJobParameters theBulkExportOptions, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) void
setAuthorizationSearchParamMatcher
(IAuthorizationSearchParamMatcher theAuthorizationSearchParamMatcher) Sets a search parameter matcher for use in handling SMART v2 filter scopessetDefaultPolicy
(PolicyEnum theDefaultPolicy) The default policy if no rules have been found to apply.setFlags
(AuthorizationFlagsEnum... theFlags) This property configures any flags affecting how authorization is applied.setFlags
(Collection<AuthorizationFlagsEnum> theFlags) This property configures any flags affecting how authorization is applied.void
setTroubleshootingLog
(org.slf4j.Logger theTroubleshootingLog) setValidationSupport
(ca.uhn.fhir.context.support.IValidationSupport theValidationSupport) Sets a validation support module that will be used for terminology-based rulesprotected static boolean
shouldExamineChildResources
(org.hl7.fhir.instance.model.api.IBaseResource theResource, ca.uhn.fhir.context.FhirContext theFhirContext) This method determines if the given Resource should have permissions applied to the resources inside or to the Resource itself.static List
<org.hl7.fhir.instance.model.api.IBaseResource> toListOfResourcesAndExcludeContainer
(org.hl7.fhir.instance.model.api.IBaseResource theResponseObject, ca.uhn.fhir.context.FhirContext fhirContext) protected static List
<org.hl7.fhir.instance.model.api.IBaseResource> toListOfResourcesAndExcludeContainerUnlessStandalone
(org.hl7.fhir.instance.model.api.IBaseResource theResponseObject, ca.uhn.fhir.context.FhirContext fhirContext)
-
Field Details
-
REQUEST_ATTRIBUTE_BULK_DATA_EXPORT_OPTIONS
-
-
Constructor Details
-
AuthorizationInterceptor
public AuthorizationInterceptor()Constructor -
AuthorizationInterceptor
Constructor- Parameters:
theDefaultPolicy
- The default policy if no rules apply (must not be null)
-
-
Method Details
-
getTroubleshootingLog
- Specified by:
getTroubleshootingLog
in interfaceIRuleApplier
-
setTroubleshootingLog
-
applyRulesAndReturnDecision
public AuthorizationInterceptor.Verdict applyRulesAndReturnDecision(ca.uhn.fhir.rest.api.RestOperationTypeEnum theOperation, RequestDetails theRequestDetails, org.hl7.fhir.instance.model.api.IBaseResource theInputResource, org.hl7.fhir.instance.model.api.IIdType theInputResourceId, org.hl7.fhir.instance.model.api.IBaseResource theOutputResource, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) - Specified by:
applyRulesAndReturnDecision
in interfaceIRuleApplier
-
getValidationSupport
- Specified by:
getValidationSupport
in interfaceIRuleApplier
- Since:
- 6.0.0
-
setValidationSupport
public AuthorizationInterceptor setValidationSupport(ca.uhn.fhir.context.support.IValidationSupport theValidationSupport) Sets a validation support module that will be used for terminology-based rules- Parameters:
theValidationSupport
- The validation support. Null is also acceptable (this is the default), in which case the validation support module associated with theFhirContext
will be used.- Since:
- 6.0.0
-
setAuthorizationSearchParamMatcher
public void setAuthorizationSearchParamMatcher(@Nullable IAuthorizationSearchParamMatcher theAuthorizationSearchParamMatcher) Sets a search parameter matcher for use in handling SMART v2 filter scopes- Parameters:
theAuthorizationSearchParamMatcher
- The search parameter matcher. Defaults to null.
-
getSearchParamMatcher
- Specified by:
getSearchParamMatcher
in interfaceIRuleApplier
-
buildRuleList
Subclasses should override this method to supply the set of rules to be applied to this individual request.Typically this is done by examining
theRequestDetails
to find out who the current user is and then using aRuleBuilder
to create an appropriate rule chain.- Parameters:
theRequestDetails
- The individual request currently being applied
-
getDefaultPolicy
The default policy if no rules have been found to apply. Default value for this setting isPolicyEnum.DENY
-
setDefaultPolicy
The default policy if no rules have been found to apply. Default value for this setting isPolicyEnum.DENY
- Parameters:
theDefaultPolicy
- The policy (must not benull
)
-
getFlags
This property configures any flags affecting how authorization is applied. By default no flags are applied.- See Also:
-
setFlags
This property configures any flags affecting how authorization is applied. By default no flags are applied.- Parameters:
theFlags
- The flags (must not be null)- See Also:
-
setFlags
This property configures any flags affecting how authorization is applied. By default no flags are applied.- Parameters:
theFlags
- The flags (must not be null)- See Also:
-
handleDeny
protected void handleDeny(RequestDetails theRequestDetails, AuthorizationInterceptor.Verdict decision) Handle an access control verdict ofPolicyEnum.DENY
.Subclasses may override to implement specific behaviour, but default is to throw
ForbiddenOperationException
(HTTP 403) with error message citing the rule name which trigered failure- Since:
- HAPI FHIR 3.6.0
-
handleDeny
This method should not be overridden. As of HAPI FHIR 3.6.0, you should overridehandleDeny(RequestDetails, Verdict)
instead. This method will be removed in the future. -
incomingRequestPreHandled
public void incomingRequestPreHandled(RequestDetails theRequest, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) -
hookPreShow
public void hookPreShow(RequestDetails theRequestDetails, IPreResourceShowDetails theDetails, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) -
hookOutgoingResponse
public void hookOutgoingResponse(RequestDetails theRequestDetails, org.hl7.fhir.instance.model.api.IBaseResource theResponseObject, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) -
hookCascadeDeleteForConflict
public void hookCascadeDeleteForConflict(RequestDetails theRequestDetails, ca.uhn.fhir.interceptor.api.Pointcut thePointcut, org.hl7.fhir.instance.model.api.IBaseResource theResourceToDelete) -
hookDeleteExpunge
public void hookDeleteExpunge(RequestDetails theRequestDetails, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) -
initiateBulkExport
public void initiateBulkExport(RequestDetails theRequestDetails, BulkExportJobParameters theBulkExportOptions, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) -
hookResourcePreCreate
public void hookResourcePreCreate(RequestDetails theRequest, org.hl7.fhir.instance.model.api.IBaseResource theResource, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) -
hookResourcePreDelete
public void hookResourcePreDelete(RequestDetails theRequest, org.hl7.fhir.instance.model.api.IBaseResource theResource, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) -
hookResourcePreUpdate
public void hookResourcePreUpdate(RequestDetails theRequest, org.hl7.fhir.instance.model.api.IBaseResource theOldResource, org.hl7.fhir.instance.model.api.IBaseResource theNewResource, ca.uhn.fhir.interceptor.api.Pointcut thePointcut) -
toListOfResourcesAndExcludeContainerUnlessStandalone
protected static List<org.hl7.fhir.instance.model.api.IBaseResource> toListOfResourcesAndExcludeContainerUnlessStandalone(org.hl7.fhir.instance.model.api.IBaseResource theResponseObject, ca.uhn.fhir.context.FhirContext fhirContext) -
toListOfResourcesAndExcludeContainer
@Nonnull public static List<org.hl7.fhir.instance.model.api.IBaseResource> toListOfResourcesAndExcludeContainer(org.hl7.fhir.instance.model.api.IBaseResource theResponseObject, ca.uhn.fhir.context.FhirContext fhirContext) -
shouldExamineChildResources
protected static boolean shouldExamineChildResources(org.hl7.fhir.instance.model.api.IBaseResource theResource, ca.uhn.fhir.context.FhirContext theFhirContext) This method determines if the given Resource should have permissions applied to the resources inside or to the Resource itself. For Parameters resources, we include child resources when checking the permissions. For Bundle resources, we only look at resources inside if the Bundle is of type document, collection, or message.
-