beckn / protocol-server

protocol-server
6 stars 11 forks source link

Add optional shared key authentication for BPP Webhook communication #152

Closed vbabuEM closed 3 months ago

vbabuEM commented 4 months ago

Problem: Currently the webhook communication between the BPP-Client and BPP Software is not secure. This is usually not an issue where the channel has other protection such as virtual private network. However in BPP software that is publicly accessible, this method will require whitelisting etc on the BPP Software side.

Requirement:

  1. Add an optional shared key authentication mechanism (such as HMAC- Hash based message authentication code) to the communication between the BPP-Client and BPP SW. Though we have public key authentication in other communications (such as between BAP and BPP), here since both BPP and BPP-PS are installed and controlled by same organisation, shared key authentication seems sufficient.
  2. Add a configuration key useHMACForWebhook which will be default false and assumed false if absent.
  3. Add a configuration key sharedKeyForWebhookHMAC which will be default empty and assumed empty is absent.
  4. If the useHMACForWebhook is true and if the sharedKeyForWebhookHMAC has a valid secret key, the content of the message is hashed, the signature calculated and sent in the Authorization header.
  5. In all other cases including current configuration (where both the above keys are missing), the webhook message is sent without this header.

The BPP Software with the shared key can authenticate the request.

em-abee commented 3 months ago

PR #https://github.com/beckn/protocol-server/pull/193