|
|
@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
@ -32,12 +33,14 @@ public class ShopifyWebhooksController {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PostMapping("/customer/request")
|
|
|
|
@PostMapping("/customer/request")
|
|
|
|
public void customerRequest(@RequestHeader("X-Shopify-Hmac-SHA256") String hmac,
|
|
|
|
public void customerRequest(@RequestHeader("X-Shopify-Hmac-SHA256") String hmac,
|
|
|
|
HttpServletRequest request) {
|
|
|
|
HttpServletRequest request,
|
|
|
|
|
|
|
|
HttpServletResponse response) {
|
|
|
|
String requestBody = ShopifyHttpUtils.getRequestBody(request);
|
|
|
|
String requestBody = ShopifyHttpUtils.getRequestBody(request);
|
|
|
|
if (!shopifyRequestValidator.verify(requestBody, hmac)) {
|
|
|
|
if (!shopifyRequestValidator.verify(requestBody, hmac)) {
|
|
|
|
throw new ShopifyRequestVerifyException("Unauthorized");
|
|
|
|
throw new ShopifyRequestVerifyException("Unauthorized");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ShopifyCustomerRequestCommand shopifyCustomerRequestCommand = JSONObject.parseObject(requestBody, ShopifyCustomerRequestCommand.class);
|
|
|
|
ShopifyCustomerRequestCommand shopifyCustomerRequestCommand = JSONObject.parseObject(requestBody, ShopifyCustomerRequestCommand.class);
|
|
|
|
|
|
|
|
response.setHeader("content-security-policy", "frame-ancestors https://" + shopifyCustomerRequestCommand.getShop_domain() + ".myshopify.com https://admin.shopify.com");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -46,12 +49,14 @@ public class ShopifyWebhooksController {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PostMapping("/customer/erasure")
|
|
|
|
@PostMapping("/customer/erasure")
|
|
|
|
public void customerRedact(@RequestHeader("X-Shopify-Hmac-SHA256") String hmac,
|
|
|
|
public void customerRedact(@RequestHeader("X-Shopify-Hmac-SHA256") String hmac,
|
|
|
|
HttpServletRequest request) {
|
|
|
|
HttpServletRequest request,
|
|
|
|
|
|
|
|
HttpServletResponse response) {
|
|
|
|
String requestBody = ShopifyHttpUtils.getRequestBody(request);
|
|
|
|
String requestBody = ShopifyHttpUtils.getRequestBody(request);
|
|
|
|
if (!shopifyRequestValidator.verify(requestBody, hmac)) {
|
|
|
|
if (!shopifyRequestValidator.verify(requestBody, hmac)) {
|
|
|
|
throw new ShopifyRequestVerifyException("Unauthorized");
|
|
|
|
throw new ShopifyRequestVerifyException("Unauthorized");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ShopifyCustomerRedactCommand shopifyCustomerRedactCommand = JSONObject.parseObject(requestBody, ShopifyCustomerRedactCommand.class);
|
|
|
|
ShopifyCustomerRedactCommand shopifyCustomerRedactCommand = JSONObject.parseObject(requestBody, ShopifyCustomerRedactCommand.class);
|
|
|
|
|
|
|
|
response.setHeader("content-security-policy", "frame-ancestors https://" + shopifyCustomerRedactCommand.getShop_domain() + ".myshopify.com https://admin.shopify.com");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -60,7 +65,8 @@ public class ShopifyWebhooksController {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PostMapping("/shop/erasure")
|
|
|
|
@PostMapping("/shop/erasure")
|
|
|
|
public void shopRedact(@RequestHeader("X-Shopify-Hmac-SHA256") String hmac,
|
|
|
|
public void shopRedact(@RequestHeader("X-Shopify-Hmac-SHA256") String hmac,
|
|
|
|
HttpServletRequest request) {
|
|
|
|
HttpServletRequest request,
|
|
|
|
|
|
|
|
HttpServletResponse response) {
|
|
|
|
String requestBody = ShopifyHttpUtils.getRequestBody(request);
|
|
|
|
String requestBody = ShopifyHttpUtils.getRequestBody(request);
|
|
|
|
if (!shopifyRequestValidator.verify(requestBody, hmac)) {
|
|
|
|
if (!shopifyRequestValidator.verify(requestBody, hmac)) {
|
|
|
|
throw new ShopifyRequestVerifyException("Unauthorized");
|
|
|
|
throw new ShopifyRequestVerifyException("Unauthorized");
|
|
|
@ -71,5 +77,6 @@ public class ShopifyWebhooksController {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
shopifyStoreService.modifyShopifyStore(shopifyShop.setStatus(0));
|
|
|
|
shopifyStoreService.modifyShopifyStore(shopifyShop.setStatus(0));
|
|
|
|
|
|
|
|
response.setHeader("content-security-policy", "frame-ancestors https://" + shopifyShopRedactCommand.getShop_domain() + ".myshopify.com https://admin.shopify.com");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|