Skip to content

Commit

Permalink
Merge pull request #56 from medgift/authorization_disable_verify
Browse files Browse the repository at this point in the history
Add env variable to disable matching tags verification
  • Loading branch information
nikpap authored Jun 29, 2023
2 parents ca22f23 + 4ade5e6 commit df343d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Authorization/context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
override="false"/>
<Parameter name="online.kheops.welcomebot.webhook" value="${kheops_welcomebot_webhook}"
override="false"/>
<Parameter name="online.kheops.auth.disableverification" value="${kheops_auth_disable_verification}"
override="false"/>
<Parameter name="online.kheops.auth.adminpassword" value="${kheops_auth_admin_password}"
override="false"/>
</Context>
1 change: 1 addition & 0 deletions Authorization/setenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ fi

sed -i "s|\${kheops_oauth_scope}|$KHEOPS_OAUTH_SCOPE|" ${REPLACE_FILE_PATH}
sed -i "s|\${kheops_welcomebot_webhook}|$KHEOPS_WELCOMEBOT_WEBHOOK|" ${REPLACE_FILE_PATH}
sed -i "s|\${kheops_auth_disable_verification}|$KHEOPS_AUTHORIZATION_DISABLE_VERIFICATION|" ${REPLACE_FILE_PATH}

export UMASK=022

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.servlet.ServletContext;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
Expand All @@ -35,6 +36,9 @@ public class VerifyInstanceResource {
@Context
private SecurityContext securityContext;

@Context
private ServletContext servletContext;

private static class StudyParam {
String studyInstanceUID;
String studyDate;
Expand Down Expand Up @@ -128,11 +132,14 @@ public Response verifyInstance(
final EntityManager em = EntityManagerListener.createEntityManager();
final EntityTransaction tx = em.getTransaction();

// Verification of matching tags can be disabled via environment variable
final boolean verificationDisabled = Boolean.parseBoolean(servletContext.getInitParameter("online.kheops.auth.disableverification"));

try {

study = getStudy(studyInstanceUID, em);

if (!isSameStudy(study, studyParam)) {
if (!verificationDisabled && !isSameStudy(study, studyParam)) {
final List<String> unmatchingTags = getReason(study, studyParam);
kheopsLogBuilder.isValid(false)
.authorized(true)
Expand All @@ -143,7 +150,7 @@ public Response verifyInstance(

series = getSeries(studyInstanceUID, seriesInstanceUID, em);

if (!isSameSeries(series, seriesParam)) {
if (!verificationDisabled && !isSameSeries(series, seriesParam)) {
final List<String> unmatchingTags = getReason(series, seriesParam);
kheopsLogBuilder.isValid(false)
.authorized(true)
Expand Down

0 comments on commit df343d1

Please sign in to comment.