From ed1702647530d5dd58e849deba3747fb36c8d00b Mon Sep 17 00:00:00 2001 From: rkorytkowski Date: Thu, 1 Aug 2024 17:54:57 +0200 Subject: [PATCH] RESTWS-952 Require authentication for fetching CustomDatatypes --- .../v1_0/resource/openmrs1_9/CustomDatatypeResource1_9.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CustomDatatypeResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CustomDatatypeResource1_9.java index 72b40d62a..7762a01b4 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CustomDatatypeResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CustomDatatypeResource1_9.java @@ -14,6 +14,7 @@ import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.RefProperty; import io.swagger.models.properties.StringProperty; +import org.openmrs.api.APIAuthenticationException; import org.openmrs.api.context.Context; import org.openmrs.customdatatype.CustomDatatype; import org.openmrs.customdatatype.CustomDatatypeHandler; @@ -129,6 +130,9 @@ protected PageableResult doGetAll(RequestContext context) throws ResponseExcepti } private List getAllCustomDatatypes() { + if(!Context.isAuthenticated()) { + throw new APIAuthenticationException("User must be authenticated!"); + } List datatypeClassnames = CustomDatatypeUtil.getDatatypeClassnames(); List datatypes = new ArrayList();