Skip to content

feat(cors): Global CORS Configuration for AMRIT API Services #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/environment/admin_ci.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ [email protected]_SECRET_KEY@
#ELK logging file name
[email protected]_API_LOGGING_FILE_NAME@

[email protected]_URL@
[email protected]_URL@

cors.allowed-origins=@CORS_ALLOWED_ORIGINS@
4 changes: 3 additions & 1 deletion src/main/environment/admin_example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ videoConsultation-base-url=https://psmri.swymed.com:9274
spring.redis.host=localhost
spring.main.allow-bean-definition-overriding=true

common-url=http://localhost:8083/
common-url=http://localhost:8083/

cors.allowed-origins=http://localhost:*,http://127.0.0.1:*
25 changes: 25 additions & 0 deletions src/main/java/com/iemr/admin/config/CorsConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.iemr.admin.config;

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

@Configuration
public class CorsConfig implements WebMvcConfigurer {

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

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns(allowedOrigins.split(","))
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("*")
.exposedHeaders("Authorization", "Jwttoken") // Explicitly expose headers if needed
.allowCredentials(true)
.maxAge(3600)
;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void setServiceProvider_ServiceImpl(BlockingInter blockingInter) {
this.blockingInter = blockingInter;
}

@CrossOrigin()

@Operation(summary = "Block provider 1")
@RequestMapping(value = "/blockProvider1", headers = "Authorization", method = { RequestMethod.POST }, produces = {
"application/json" })
Expand Down Expand Up @@ -119,7 +119,7 @@ public String blockProvider1(@RequestBody String providerBlocking) {

}

@CrossOrigin()

@Operation(summary = "Block provider")
@RequestMapping(value = "/blockProvider", headers = "Authorization", method = { RequestMethod.POST }, produces = {
"application/json" })
Expand Down Expand Up @@ -178,7 +178,7 @@ public String blockProvider(@RequestBody String providerBlocking) {

}

@CrossOrigin()

@Operation(summary = "Block provider by service id")
@RequestMapping(value = { "/blockProviderByServiceId" }, method = { RequestMethod.POST }, produces = {
"application/json" }, headers = "Authorization")
Expand Down Expand Up @@ -239,7 +239,7 @@ public String blockProviderByServiceId(@RequestBody String blockProviderByServic

}

@CrossOrigin()

@Operation(summary = "Get provider status")
@RequestMapping(value = "/getProviderStatus", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand All @@ -266,7 +266,7 @@ public String getProviderStatus(@RequestBody String getProviderStatus) {

}

@CrossOrigin()

@Operation(summary = "Get provider status 1")
@RequestMapping(value = "/getProviderStatus1", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand All @@ -293,7 +293,7 @@ public String getProviderStatus1(@RequestBody String getProviderStatus) {

}

@CrossOrigin()

@Operation(summary = "Get service liens using provider")
@RequestMapping(value = "/getServiceLinesUsingProvider", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand All @@ -320,7 +320,7 @@ public String getServiceLiensUsingProvider(@RequestBody String getServiceLiensUs

}

@CrossOrigin()

@Operation(summary = "Get provider status by provider and service id")
@RequestMapping(value = "/getProviderStatusByProviderAndServiceId", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down Expand Up @@ -348,7 +348,7 @@ public String getProviderStatusByProviderAndServiceId(@RequestBody String getPro

}

@CrossOrigin()

@Operation(summary = "Block provider by service")
@RequestMapping(value = "/blockProviderByService", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down Expand Up @@ -401,7 +401,7 @@ public String blockProviderByService(@RequestBody String providerServiceBlocking

}

@CrossOrigin()

@Operation(summary = "Get provider status by service")
@RequestMapping(value = "/getProviderStatusByService", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down Expand Up @@ -430,7 +430,7 @@ public String getProviderStatusByService(@RequestBody String providerServiceBloc

}

@CrossOrigin()

@Operation(summary = "Block provider by state")
@RequestMapping(value = "/blockProviderByState", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down Expand Up @@ -491,7 +491,7 @@ public String blockProviderByState(@RequestBody String providerStateBlocking) {

}

@CrossOrigin()

@Operation(summary = "Get provider status by state")
@RequestMapping(value = "/getProviderStatusByState", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down Expand Up @@ -520,7 +520,7 @@ public String getProviderStatusByState(@RequestBody String providerStateBlocking

}

@CrossOrigin()

@Operation(summary = "Block user")
@RequestMapping(value = "/blockUser", headers = "Authorization", method = { RequestMethod.POST }, produces = {
"application/json" })
Expand Down Expand Up @@ -568,7 +568,7 @@ public String blockUser(@RequestBody String blockUser) {

}

@CrossOrigin()

@Operation(summary = "Get status")
@RequestMapping(value = "/getStatus", headers = "Authorization", method = { RequestMethod.POST }, produces = {
"application/json" })
Expand All @@ -593,7 +593,7 @@ public String getStatus(@RequestBody String getStatus) {

}

@CrossOrigin()

@Operation(summary = "Provider state and service lines")
@RequestMapping(value = "/addProviderStateAndServiceLines", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down Expand Up @@ -657,7 +657,7 @@ public String ProviderStateAndServiceLines(@RequestBody String ProviderStateAndS

}

@CrossOrigin()

@Operation(summary = "Delete provider state and service lines")
@RequestMapping(value = "/deleteProviderStateAndServiceLines", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down Expand Up @@ -701,7 +701,7 @@ public String deleteProviderStateAndServiceLines(@RequestBody String deleteProvi

}

@CrossOrigin()

@Operation(summary = "Create cit mapping with service lines")
@RequestMapping(value = "/createCitMappingwithServiceLines", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand All @@ -728,7 +728,7 @@ public String createCitMappingwithServiceLines(@RequestBody String createCitMapp

}

@CrossOrigin()

@Operation(summary = "Get mapped service lines and state to provider")
@RequestMapping(value = "/getMappedServiceLinesAndStatetoProvider", headers = "Authorization", method = {
RequestMethod.POST }, consumes = { "application/json" }, produces = { "application/json" })
Expand Down Expand Up @@ -756,7 +756,7 @@ public String getMappedServiceLinesAndStatetoProvider(@RequestBody String getMap

}

@CrossOrigin()

@Operation(summary = "Map provider and service lines")
@RequestMapping(value = "/mapServiceLinesAndStatetoProvider", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down Expand Up @@ -822,7 +822,7 @@ public String mapProviderAndServiceLines(@RequestBody String mapProviderAndServi

}

@CrossOrigin()

@Operation(summary = "Edit mapped service lines and state to provider")
@RequestMapping(value = "/editMappedServiceLinesAndStatetoProvider", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down Expand Up @@ -856,7 +856,7 @@ public String editMappedServiceLinesAndStatetoProvider(

}

@CrossOrigin()

@Operation(summary = "Delete mapped service lines and state to provider")
@RequestMapping(value = "/deleteMappedServiceLinesAndStatetoProvider", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class CalibrationController {
* @param request
* @return CalibrationStripMasterData
*/
@CrossOrigin()

@Operation(summary = "Create calibration strip")
@RequestMapping(value = "/createCalibrationStrip", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down Expand Up @@ -85,7 +85,7 @@ public String createCalibrationStrip(
* @param request
* @return CalibrationStripList
*/
@CrossOrigin()

@Operation(summary = "Fetch calibration strip")
@RequestMapping(value = "/fetchCalibrationStrips", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down Expand Up @@ -113,7 +113,7 @@ public String fetchCalibrationStrips(
* @param request
* @return Response
*/
@CrossOrigin()

@Operation(summary = "Delete calibration strip")
@RequestMapping(value = "/deleteCalibrationStrip", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down Expand Up @@ -141,7 +141,7 @@ public String deleteCalibrationStrip(

}

@CrossOrigin()

@Operation(summary = "Update calibration strip")
@RequestMapping(value = "/updateCalibrationStrip", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class CareStreamCreateOrderController {
private static final char START_OF_BLOCK = '\u000b';
private static final char CARRIAGE_RETURN = 13;

@CrossOrigin()

@Operation(summary = "Create order")
@RequestMapping(value = "/createOrder", headers = "Authorization", method = { RequestMethod.POST }, produces = {
"application/json" })
Expand Down Expand Up @@ -118,7 +118,7 @@ public String createOrder(@RequestBody String createOrder) throws UnknownHostExc
return response.toString();
}

@CrossOrigin()

@Operation(summary = "Update order")
@RequestMapping(value = "/UpdateOrder", headers = "Authorization", method = { RequestMethod.POST }, produces = {
"application/json" })
Expand Down Expand Up @@ -174,7 +174,7 @@ public String UpdateOrder(@RequestBody String UpdateOrder) throws UnknownHostExc
return response.toString();
}

@CrossOrigin()

@Operation(summary = "Delete order")
@RequestMapping(value = "/deleteOrder", headers = "Authorization", method = { RequestMethod.POST }, produces = {
"application/json" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class DrugStrength {
@Autowired
private DrugStrangthInter durgStrangthInter;

@CrossOrigin()

@Operation(summary = "Create drug strength")
@RequestMapping(value = "/createDrugStrangth", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down Expand Up @@ -76,7 +76,7 @@ public String createDrugStrangth(@RequestBody String createDrugStrangth) {

}

@CrossOrigin()

@Operation(summary = "Get drug strength")
@RequestMapping(value = "/getDrugStrangth", headers = "Authorization", method = { RequestMethod.POST }, produces = {
"application/json" })
Expand All @@ -103,7 +103,7 @@ public String getDrugStrangth(@RequestBody String getDrugStrangth) {

}

@CrossOrigin()

@Operation(summary = "Update drug strength")
@RequestMapping(value = "/updateDrugStrangth", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down Expand Up @@ -136,7 +136,7 @@ public String updateDrugStrangth(@RequestBody String updateDrugStrangth) {

}

@CrossOrigin()

@Operation(summary = "Delete drug strength")
@RequestMapping(value = "/deleteDrugStrangth", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class DrugtypeController {
@Autowired
private DrugtypeInter drugtypeInter;

@CrossOrigin()

@Operation(summary = "Create manufacturer")
@RequestMapping(value = "/createDrugtype", headers = "Authorization", method = { RequestMethod.POST }, produces = {
"application/json" })
Expand All @@ -75,7 +75,7 @@ public String createManufacturer(@RequestBody String createDrugtype) {

}

@CrossOrigin()

@Operation(summary = "Get manufacturer")
@RequestMapping(value = "/getDrugtype", headers = "Authorization", method = { RequestMethod.POST }, produces = {
"application/json" })
Expand All @@ -102,7 +102,7 @@ public String getManufacturer(@RequestBody String getDrugtype) {

}

@CrossOrigin()

@Operation(summary = "Edit manufacturer")
@RequestMapping(value = "/editDrugtype", headers = "Authorization", method = { RequestMethod.POST }, produces = {
"application/json" })
Expand Down Expand Up @@ -137,7 +137,7 @@ public String editManufacturer(@RequestBody String editDrugtype) {

}

@CrossOrigin()

@Operation(summary = "Delete manufacturer")
@RequestMapping(value = "/deleteDrugtype", headers = "Authorization", method = { RequestMethod.POST }, produces = {
"application/json" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class EmailConfigController {
@Autowired
EmailConfigService emailConfigService;

@CrossOrigin()

@Operation(summary = "Save configuration")
@RequestMapping(value = "/saveConfig", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String saveConfig(@RequestBody List<CreateAuthEmailRequestModel> createEmailRequests,
Expand All @@ -73,7 +73,7 @@ public String saveConfig(@RequestBody List<CreateAuthEmailRequestModel> createEm

}

@CrossOrigin()

@Operation(summary = "Get email configuration")
@RequestMapping(value = "/getEmailConfigs", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String getEmailConfigs(@RequestBody AuthEmailRequest authEmailRequest, HttpServletRequest request) {
Expand All @@ -93,7 +93,7 @@ public String getEmailConfigs(@RequestBody AuthEmailRequest authEmailRequest, Ht

}

@CrossOrigin()

@Operation(summary = "Update email configuration")
@RequestMapping(value = "/updateEmailConfig", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String updateEmailConfig(@RequestBody UpdateAuthEmailRequest updateEmailRequest,
Expand Down
Loading