diff --git a/examples/src/main/java/example/AuthorizationInterceptors.java b/examples/src/main/java/example/AuthorizationInterceptors.java
index 0bc661c5bd03..3f84c3531dbe 100644
--- a/examples/src/main/java/example/AuthorizationInterceptors.java
+++ b/examples/src/main/java/example/AuthorizationInterceptors.java
@@ -2,33 +2,89 @@
import java.util.List;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+
import ca.uhn.fhir.model.dstu2.resource.Patient;
+import ca.uhn.fhir.model.primitive.IdDt;
+import ca.uhn.fhir.rest.annotation.ResourceParam;
+import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.method.RequestDetails;
+import ca.uhn.fhir.rest.server.IResourceProvider;
+import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;
import ca.uhn.fhir.rest.server.interceptor.auth.AuthorizationInterceptor;
import ca.uhn.fhir.rest.server.interceptor.auth.IAuthRule;
import ca.uhn.fhir.rest.server.interceptor.auth.RuleBuilder;
public class AuthorizationInterceptors {
+ public class PatientResourceProvider implements IResourceProvider
+ {
+
+ @Override
+ public Class extends IBaseResource> getResourceType() {
+ return Patient.class;
+ }
+
+ public MethodOutcome create(@ResourceParam Patient thePatient, RequestDetails theRequestDetails) {
+
+ return new MethodOutcome(); // populate this
+ }
+
+ }
+
+ //START SNIPPET: patientAndAdmin
public class PatientAndAdminAuthorizationInterceptor extends AuthorizationInterceptor {
+
@Override
public List
+ * See the HAPI FHIR
+ * Documentation on Server Security
+ * for information on how to use this interceptor.
+ *
AuthorizationInterceptor is a new feature in HAPI FHIR, and has not yet been heavily tested. Use with caution, and do lots of testing! We welcome - feedback and suggestions on this feature. + feedback and suggestions on this feature. In addition, this documentation is + not yet complete. More examples and details will be added soon! Please get in + touch if you'd like to help test, have suggestions, etc.
@@ -96,6 +98,45 @@ might be detemrined to belong to an administrator user, and could be declared to be allowed to do anything.
+ +
+ The AuthorizationInterceptor is used by subclassing it and then registering your
+ subclass with the RestfulServer
. The following example shows a subclassed
+ interceptor implementing some basic rules:
+
+ The AuthorizationInterceptor works by examining the client request + in order to determine whether "write" operations are legal, and looks at + the response from the server in order to determine whether "read" operations + are legal. +
+
+ This approach has limitations however: If a request has a conditional operation,
+ such as a delete operation which uses a search URL, or a create operation which
+ uses an If-None-Exist
header, the interceptor will not know the
+ actual target until the server actually processes the request.
+
+ For better security, individual resource providers should notify interceptors + about their actual targets in the event of any "write" operations (create, + operations embedded in transactions, etc.) +
++ The mechanism for doing this isn't yet fully documented, this will be improved + over the next release cycle (post 1.5). Please get in touch on our google group + if you want to help! +
+ +