Policies
HMAC Auth Policy
Custom Policy Example
Zuplo is extensible, so we don't have a built-in policy for HMAC Auth, instead we have a template here that shows you how you can use your superpower (code) to achieve your goals. To learn more about custom policies see the documentation.
This example policy demonstrates how to use a shared secret to create an HMAC signature to sign a payload (in this case the body). When the request is sent, the signature is sent in the request header. The policy can then verify that the signature matches the payload - thus ensuring that the sender had the same shared secret.
This policy is configured with the value of the secret
. Normally, you would
store this as an environment variable secret. Additionally, the policy option
headerName
is used to set the header that will be used by the client to send
the signature.
Configuration
The example below shows how to configure a custom code policy in the 'policies.json' document that utilizes the above example policy code.
Policy Options
The options for this policy are specified below. All properties are optional unless specifically marked as required.
secret
<string> (Required) -The secret to use for HMAC authenticationheaderName
<string> (Required) -The header where the HMAC signature is send
Using the Policy
The example below demonstrates how you could sign a value in order to create an HMAC signature for use with this policy.
Read more about how policies work