Vue Storefront is now Alokai! Learn More
Protecting extension module with Basic Auth

Protecting extension module with Basic Auth

Extension configuration

Firstly, you have to extend configuration in the STRIPE_INTEGRATION_CONFIG environment variables with authentication property.

{
  "stripe": {
    "stripeProfile1": {
      "secretKey": "sk_test_xxx"
    }
  },
  "authentication": {
    "enabled": true,
    "username": "admin",
    "password": "some-strong-password"
  },
  "logLevel": 20
}

Updating a configuration requires restart of application.

Commercetools HTTP API Extension

The second step to configure the integration is to update your list of the extensions in your commercetools playground.

  1. Open API Playground,
  2. Make sure you've selected your desired project in the select input placed inside the page's header,
  3. Encode phrase like admin:some-strong-password (replace them with your values - these are the same, you set in the configuration - authentication.username and authentication.password) to Base64 (for example, using some online tool),
  4. Set:
  • Endpoint as Extensions,
  • Command as Create,
  • Payload as:
{
  "key": "ctp-stripe-integration-payment-extension",
  "destination": {
    "type": "HTTP",
    "url": "URL_TO_YOUR_EXTENSION_MODULE_INSTANCE",
    "authentication": {
      "type": "AuthorizationHeader",
      "headerValue": "Basic ENCODED_BASE64_VALUE"
    }
  },
  "triggers": [
    {
      "resourceTypeId": "payment",
      "actions": ["Create", "Update"],
      "condition": "paymentMethodInfo is defined AND paymentMethodInfo(paymentInterface is defined) AND paymentMethodInfo(paymentInterface=\"ctp-stripe-integration\")"
    }
  ],
  "timeoutInMs": 10000
}

Replace ENCODED_BASE64_VALUE with value generated in the third step.

As destination.url you have to set URL address where Extension module is available.

  1. Click Go!!! button.