Skip to content

Commit

Permalink
MM-860: Implemented anti-csrf tokens for OpenMRS protection against C…
Browse files Browse the repository at this point in the history
…SRF attacks
  • Loading branch information
jnsereko committed Jul 16, 2021
1 parent 241f1d5 commit bbdb15e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.ArgumentMatcher;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openmrs.scheduler.SchedulerService;
Expand Down Expand Up @@ -47,16 +48,11 @@ public void shouldSaveNewTaskIfNotAlreadyRegistered() {

new ReferenceApplicationActivator().setupHL7ProcessingTask(schedulerService);

verify(schedulerService).saveTaskDefinition(Matchers.argThat(new BaseMatcher<TaskDefinition>() {
verify(schedulerService).saveTaskDefinition(Matchers.argThat(new ArgumentMatcher<TaskDefinition>() {

@Override
public boolean matches(Object obj) {
return obj instanceof TaskDefinition
&& ProcessHL7InQueueTask.class.getName().equals(((TaskDefinition) obj).getTaskClass());
}

@Override
public void describeTo(Description description) {
public boolean matches(TaskDefinition obj) {
return ProcessHL7InQueueTask.class.getName().equals(obj.getTaskClass());
}
}));

Expand Down
5 changes: 5 additions & 0 deletions api/src/test/resources/TestingApplicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<property name="mappingJarLocations">
<ref bean="mappingJarResources"/>
</property>
<property name="packagesToScan">
<list>
<value>org.openmrs</value>
</list>
</property>
<!-- default properties must be set in the hibernate.default.properties -->
</bean>

Expand Down
1 change: 1 addition & 0 deletions omod/src/main/webapp/pages/login.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
<% } %>
<input id="loginButton" class="btn ${ ui.message(selectLocation ? "btn-success" : "confirm") }" type="submit"
value="${ ui.message(selectLocation ? "general.done" : "referenceapplication.login.button") }"/>
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</p>
<% if(!selectLocation) {%>
<p>
Expand Down
22 changes: 11 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<openMRSVersion>2.0.1</openMRSVersion>
<openMRSVersion>2.5.0-SNAPSHOT</openMRSVersion>
<webservicesRestModuleVersion>2.6</webservicesRestModuleVersion>
<appointmentschedulingVersion>1.3</appointmentschedulingVersion>
<appframeworkVersion>2.9</appframeworkVersion>
<appframeworkVersion>2.16.0</appframeworkVersion>
<referencemetadataVersion>2.5.0</referencemetadataVersion>
<reportingcompatibilityVersion>2.0.2</reportingcompatibilityVersion>
<calculationVersion>1.2</calculationVersion>
<serialization.xstreamVersion>0.2.12</serialization.xstreamVersion>
<reportingVersion>0.10.6</reportingVersion>
<htmlformentryVersion>3.3.0</htmlformentryVersion>
<htmlformentryVersion>4.0.1</htmlformentryVersion>
<htmlformentryuiVersion>1.6.1</htmlformentryuiVersion>
<idgenVersion>4.4.0</idgenVersion>
<registrationcoreVersion>1.6</registrationcoreVersion>
<idgenVersion>4.7.0</idgenVersion>
<registrationcoreVersion>1.11.0</registrationcoreVersion>
<namephoneticsVersion>1.5</namephoneticsVersion>
<metadatadeployVersion>1.7</metadatadeployVersion>
<metadatadeployVersion>1.13.0</metadatadeployVersion>
<metadatasharingVersion>1.2.2</metadatasharingVersion>
<emrapiVersion>1.21.0</emrapiVersion>
<providermanagementVersion>2.5.0</providermanagementVersion>
<emrapiVersion>1.31.0</emrapiVersion>
<providermanagementVersion>2.13.0</providermanagementVersion>
<uiframeworkVersion>3.21.0-SNAPSHOT</uiframeworkVersion>
<appuiVersion>1.7</appuiVersion>
<atlasVersion>2.2</atlasVersion>
Expand All @@ -63,7 +63,7 @@
<webservices.restVersion>2.16</webservices.restVersion>
<uicommonsVersion>2.12.0</uicommonsVersion>
<legacyuiVersion>1.2.3</legacyuiVersion>
<metadatamappingVersion>1.2.1</metadatamappingVersion>
<metadatamappingVersion>1.4.0</metadatamappingVersion>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -228,7 +228,7 @@

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>htmlformentry-api-1.10</artifactId>
<artifactId>htmlformentry-api-2.3</artifactId>
<version>${htmlformentryVersion}</version>
<scope>provided</scope>
</dependency>
Expand Down Expand Up @@ -460,7 +460,7 @@

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>htmlformentry-api-1.10</artifactId>
<artifactId>htmlformentry-api-2.3</artifactId>
</dependency>

<dependency>
Expand Down

0 comments on commit bbdb15e

Please sign in to comment.