• Resolved Shane

    (@shanemarsh28)


    Hello,

    We currently use your plugin but we recently updated our CDN to Cloudfront. Cloudfront caches based on a number of things but the one extra thing it does do is change the user-agent to “Amazon Cloudfront” for all requests.

    This causes the webhook to return a 400 code after line 93 of /includes/class-wc-stripe-webhook-handler.php.

    As a work around I have commented out lines 93-95 within your plugin.

    Please can we have a check within the plugin that allows for this issue that is specific to those using the Cloudfront CDN?

    Looking forward to your reply.
    Shane.

    • This topic was modified 4 years, 10 months ago by Shane.
    • This topic was modified 4 years, 10 months ago by Shane.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @shanemarsh28 – Have you followed the instructions here to setup the Webhook in Stripe?: https://docs.woocommerce.com/document/stripe/#section-3

    Also, please make sure that you select Receive all events when you set up your webhook.

    – Joey

    Thread Starter Shane

    (@shanemarsh28)

    Hi Joey,

    Thank for your reply. The issue has nothing to do with Receive all events.

    This line is the problem (as described above):

    if ( ! empty( $request_headers['USER-AGENT'] ) && ! preg_match( '/Stripe/', $request_headers['USER-AGENT'] ) ) {
        return false;
    }

    When this line is removed (as per my initial message), the webhook behaves correctly.

    For confirmation of the issue, see this document from AWS: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html

    Amazon say:

    User-Agent: “CloudFront replaces the value of this header field with Amazon CloudFront. If you want CloudFront to cache your content based on the device the user is using, see Configuring Caching Based on the Device Type.”

    We cannot disable this or work around it by altering the settings within the Cloudfront Distribution therefore we need you to be able to toggle this security test on or off from within your plugins settings. Commenting out the three lines is sufficient but it’s not a long term fix.

    I hope this makes more sense.

    Shane

    • This reply was modified 4 years, 10 months ago by Shane.
    Plugin Support dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @shanemarsh28

    Can I ask you to open up an Issue on GitHub with the details here, please? I’m unsure if we’d create a setting for specifically one CND but the development team can offer their advice around this.

    Thanks,

    Thread Starter Shane

    (@shanemarsh28)

    Plugin Support dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    Hi @shanemarsh28

    I’ll close off this forum thread and pass this to the development team for discussion. They will update that GitHub issue with any progress / thoughts.

    Thanks,

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Cloudfront & User Agent’ is closed to new replies.