Files
kumomta/docs/reference/events/http_message_generated.md
T
Wez Furlong 07ab3d44a3 inject+xfer: cut over to AuthInfo from AuthKind
Replace the older type with the newer one.

Serialize a copy of auth_info when handling deferred generation,
so that we have a lossless representation of that state when
we eventually process the request.  That doesn't change really
anything today, but will enable more granular ACL checks in
the future.

Pass the auth_info through to the http_message_generated and
xfer_message_received events to enable more granular access
control policies to be scripted.
2025-12-18 10:19:09 +00:00

1.4 KiB

http_message_generated

kumo.on('http_message_generated', function(message, auth_info) end)

Called by the HTTP injection API endpoint after generating a message, but prior to injecting it into the queue.

The event handler will be passed a Message object, as well as an AuthInfo {{since('dev', inline=True)}} that can be used to implement more granular access control policies.

The HTTP injector does not add a Received header, but it will pre-set the following meta values in the message:

  • "http_auth" - will hold either the authenticated username or the peer IP address that satisfied the authentication check for the endpoint.

This event is the best place to carry out a number of important policy decisions:

You may use kumo.reject to raise an error to prevent this message from being queued for delivery.

kumo.on('http_message_generated', function(msg, auth_info)
  local signer = kumo.dkim.rsa_sha256_signer {
    domain = msg:from_header().domain,
    selector = 'default',
    headers = { 'From', 'To', 'Subject' },
    key = 'example-private-dkim-key.pem',
  }
  msg:dkim_sign(signer)
end)