diff --git a/course-mw/course-actors/src/main/java/org/sunbird/learner/actors/coursebatch/CourseBatchManagementActor.java b/course-mw/course-actors/src/main/java/org/sunbird/learner/actors/coursebatch/CourseBatchManagementActor.java index b84c198ef611f59cf76f6d778cc3cb9badfc4775..39fcfdc80140995ac0b1ef5bf2c5e4c4b88329a8 100644 --- a/course-mw/course-actors/src/main/java/org/sunbird/learner/actors/coursebatch/CourseBatchManagementActor.java +++ b/course-mw/course-actors/src/main/java/org/sunbird/learner/actors/coursebatch/CourseBatchManagementActor.java @@ -1,6 +1,7 @@ package org.sunbird.learner.actors.coursebatch; import akka.actor.ActorRef; +import com.typesafe.config.ConfigFactory; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -430,7 +431,7 @@ public class CourseBatchManagementActor extends BaseActor { if (CollectionUtils.isNotEmpty(courseBatch.getMentors())) { canUpdateList.addAll(courseBatch.getMentors()); } - if (!canUpdateList.contains(requestedBy)) { + if (ConfigFactory.load().getBoolean(JsonKey.AUTH_ENABLED) && !canUpdateList.contains(requestedBy)) { throw new ProjectCommonException( ResponseCode.unAuthorized.getErrorCode(), ResponseCode.unAuthorized.getErrorMessage(), diff --git a/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/BaseRequestValidator.java b/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/BaseRequestValidator.java index 49c9eb4ef9c8d230e06ed259bf8ebb63fbf4e491..22d4f789b364342b683a4bf0db1a89ce385b146e 100644 --- a/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/BaseRequestValidator.java +++ b/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/BaseRequestValidator.java @@ -4,6 +4,8 @@ import java.text.MessageFormat; import java.util.Arrays; import java.util.List; import java.util.Map; + +import com.typesafe.config.ConfigFactory; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; @@ -493,10 +495,12 @@ public class BaseRequestValidator { } public void validateRequestedBy(String requestedBy) { - if(StringUtils.isBlank(requestedBy) || JsonKey.ANONYMOUS.contentEquals(requestedBy)) { - throw new ProjectCommonException(ResponseCode.unAuthorized.getErrorCode(), - ResponseCode.unAuthorized.getErrorMessage(), - ResponseCode.UNAUTHORIZED.getResponseCode()); + if (ConfigFactory.load().getBoolean(JsonKey.AUTH_ENABLED)) { + if (StringUtils.isBlank(requestedBy) || JsonKey.ANONYMOUS.contentEquals(requestedBy)) { + throw new ProjectCommonException(ResponseCode.unAuthorized.getErrorCode(), + ResponseCode.unAuthorized.getErrorMessage(), + ResponseCode.UNAUTHORIZED.getResponseCode()); + } } } } diff --git a/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/resources/application.conf b/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/resources/application.conf new file mode 100644 index 0000000000000000000000000000000000000000..b0548ee27a43138daf61ba281094c04ffdc9869c --- /dev/null +++ b/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/resources/application.conf @@ -0,0 +1,3 @@ +# This is the main configuration file for the application. +#optional config for making authentication optional +AuthenticationEnabled=true \ No newline at end of file diff --git a/service/conf/application.conf b/service/conf/application.conf index f7c8dfd9fad50892cf3fc5ae811da8fc09dcb7e3..320b7cd293cc36faca47095b3617ea8a2278ffbe 100644 --- a/service/conf/application.conf +++ b/service/conf/application.conf @@ -289,7 +289,7 @@ play.server { # ~~~~~ libraryDependencies += javaWs -AuthenticationEnabled = true +AuthenticationEnabled=true ## Cache # https://www.playframework.com/documentation/latest/JavaCache