Skip to content
Merged
4 changes: 4 additions & 0 deletions src/main/environment/common_ci.properties
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,7 @@ captcha.secret-key=@env.CAPTCHA_SECRET_KEY@
captcha.verify-url=@env.CAPTCHA_VERIFY_URL@
captcha.enable-captcha=@env.ENABLE_CAPTCHA@

cors.allowed-origins=@CORS_ALLOWED_ORIGINS@



2 changes: 2 additions & 0 deletions src/main/environment/common_example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,5 @@ captcha.secret-key= <Enter Cloudflare Secret Key>
captcha.verify-url= https://challenges.cloudflare.com/turnstile/v0/siteverify
captcha.enable-captcha=true

cors.allowed-origins=http://localhost:*

28 changes: 28 additions & 0 deletions src/main/java/com/iemr/common/config/CorsConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.iemr.common.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.Arrays;
import org.springframework.beans.factory.annotation.Value;

@Configuration
public class CorsConfig implements WebMvcConfigurer {

@Value("${cors.allowed-origins}")
private String allowedOrigins;

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns(
Arrays.stream(allowedOrigins.split(","))
.map(String::trim)
.toArray(String[]::new))
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("*")
.exposedHeaders("Authorization", "Jwttoken")
.allowCredentials(true)
.maxAge(3600);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
Expand All @@ -25,7 +24,6 @@ public class AbdmFacilityController {
@Autowired
private AbdmFacilityService abdmFacilityService;

@CrossOrigin
@Operation(summary = "Get Abdm facility mapped to worklocation")
@GetMapping(value = { "/getWorklocationMappedAbdmFacility/{workLocationId}" })
public String getAbdmFacilityDetails(@PathVariable int workLocationId, @RequestHeader(value = "Authorization") String Authorization) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
Expand Down Expand Up @@ -188,7 +187,6 @@ public void setGovtIdentityTypeService(GovtIdentityTypeService govtIdentityTypeS
private CallReportsService callReportsService;

@Operation(summary = "Create a new beneficiary")
@CrossOrigin()
@RequestMapping(value = "/create", method = RequestMethod.POST, produces = "application/json", consumes = "application/json", headers = "Authorization")

public String createBeneficiary(
Expand Down Expand Up @@ -219,7 +217,6 @@ public String createBeneficiary(
}

@Operation(summary = "Create a new beneficiary for customization")
@CrossOrigin()
@RequestMapping(value = "/createBeneficiary", method = RequestMethod.POST, produces = "application/json", consumes = "application/json", headers = "Authorization")
public String createBeneficiary(@RequestBody String request, HttpServletRequest httpRequest)
throws JsonMappingException, JsonProcessingException {
Expand Down Expand Up @@ -266,7 +263,6 @@ private String checkExtraFields(JsonElement json) {
return otherFieldsJson.toString();
}

@CrossOrigin()
@Operation(summary = "Provide the list of beneficiaries based on beneficiary id")
@RequestMapping(value = "/searchUserByID", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String searchUserByID(
Expand Down Expand Up @@ -315,7 +311,6 @@ public String searchUserByID(
}

@Operation(summary = "Provide the list of beneficiaries based on phone number")
@CrossOrigin()
@RequestMapping(value = "/searchUserByPhone", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String searchUserByPhone(
@Param(value = "{\"phoneNo\":\"String\",\"pageNo\":\"Integer\",\"rowsPerPage\":\"Integer\"}") @RequestBody String request,
Expand Down Expand Up @@ -346,7 +341,6 @@ public String searchUserByPhone(
return response.toString();
}

@CrossOrigin()
@Operation(summary = "Provide the list of beneficiaries based on search criteria")
@RequestMapping(value = "/searchBeneficiary", method = RequestMethod.POST, headers = "Authorization")
public String searchBeneficiary(
Expand All @@ -369,7 +363,6 @@ public String searchBeneficiary(
return output.toString();
}

@CrossOrigin()
@Operation(summary = "Provide all common data list needed for beneficiary registration")
@RequestMapping(value = "/getRegistrationData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String getRegistrationData() {
Expand Down Expand Up @@ -400,7 +393,6 @@ public String getRegistrationData() {
return response.toString();
}

@CrossOrigin()
@Operation(summary = "Provide all common data V1 list needed for beneficiary registration")
@RequestMapping(value = "/getRegistrationDataV1", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String getRegistrationDataV1(
Expand Down Expand Up @@ -435,7 +427,6 @@ public String getRegistrationDataV1(
return response.toString();
}

@CrossOrigin()
@Operation(summary = "Update beneficiary details")
@RequestMapping(value = "/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String updateBenefciary(
Expand Down Expand Up @@ -479,7 +470,6 @@ public String updateBenefciary(
return response.toString();
}

@CrossOrigin()
@Operation(summary = "Update beneficiary details")
@RequestMapping(value = "/updateBenefciaryDetails", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String updateBenefciaryDetails(@RequestBody String benificiaryRequest, HttpServletRequest httpRequest) {
Expand Down Expand Up @@ -514,7 +504,6 @@ public String updateBenefciaryDetails(@RequestBody String benificiaryRequest, Ht
return response.toString();
}

@CrossOrigin()
@Operation(summary = "Fetch beneficiary details by phone no")
@RequestMapping(value = "/getBeneficiariesByPhoneNo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String getBeneficiariesByPhone(@Param(value = "{\"phoneNo\":\"String\"}") @RequestBody String request,
Expand All @@ -534,7 +523,6 @@ public String getBeneficiariesByPhone(@Param(value = "{\"phoneNo\":\"String\"}")
return response.toString();
}

@CrossOrigin()
@Operation(summary = "Update beneficiary community or education")
@RequestMapping(value = "/updateCommunityorEducation", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String updateBenefciaryCommunityorEducation(
Expand Down Expand Up @@ -564,7 +552,6 @@ public String updateBenefciaryCommunityorEducation(
return response.toString();
}

@CrossOrigin()
@Operation(summary = "Generate beneficiary id")
@RequestMapping(value = "/generateBeneficiaryIDs", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
Expand All @@ -40,7 +39,6 @@

@RestController
@RequestMapping("/brd")
@CrossOrigin()
public class BRDIntegrationController {

private Logger logger = LoggerFactory.getLogger(BRDIntegrationController.class);
Expand All @@ -50,7 +48,6 @@ public class BRDIntegrationController {

@Operation(summary = "Get integration data")
@RequestMapping(value = "/getIntegrationData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
@CrossOrigin()
public String getDetails(@RequestBody String request) {
OutputResponse response = new OutputResponse();
String brdDetails = null;
Expand Down
Loading