Skip to main content

OKM Audit API

The Audit API handles audit events. An OKM calls it when a user checks in a key. During this process:

  1. Audit events stored in the key are transferred to the OKM.
  2. The OKM sends a POST request with the event data.

This page describes the behaviour of the audit endpoints for OKM Service v1.2.20 and above. For the earlier behaviour, see OKM Audit API (before v1.2.20).

Audit Route​

POST /api/v1/audit/{serialNumber}

Like the config route, the audit route only accepts calls from OKMs the service knows and that have a valid api_token. See OKM API Tokens.

It then does the following:

  1. Update the OKM’s IP address, last sync time, and firmware version number.
  2. If auditing is enabled (okm.config.audit_enabled) and the payload is not empty, forward the audit events to the URLs configured to receive the audit records (okm.subscribe_urls.audit). These requests have a Content-Type: application/octet-stream.

Params and query params​

  1. serialNumber: string, a valid OKM serial number.

Body​

  1. Description: a byte array of audit events.
  2. Type: binary

Details​

  1. Bytes [0, 28[ : header.
    • The breakdown of bytes will be in following order:
      • 6 bytes: Header version (defines the version of the message header, currently on v1).
      • 10 bytes: Rest of the header (defines how to unpack the following data).
        • Brief:
          • Includes msgTkn: Identifies the message in the payload
          • Message handling flag: Specifies the type of message (command, reply, or unsolicited message).
          • Status: Indicates the handling status of the message.
      • 4 bytes: Count of audit records in this message.
      • 4 bytes: Count of unsent audit records remaining in the OKM.
      • 4 bytes: IPv4 address of KAS.
  2. Bytes [16, 19]: 4 bytes for event count as a 32-bit big endian unsigned int
  3. Bytes [24, 27]: 4 bytes for IP address as <27>.<26>.<25>.<24>

Responses​

Any successful request returns a 200, as part of the contract with the OKM.

CodeDescription
200The audit records were forwarded successfully, or there was nothing to forward.
424One or more forwards failed. The errors are stacked, logged, and sent in the reply.
500Any other error.

Default audit Route​

POST /embeddedv1/audit/kas

This route is hard-coded into the OKM firmware. When the OKM Service receives a request to this endpoint, and knows the OKM, it does several things:

  1. Update the status of the OKM (IP address, last sync time, firmware version).
  2. Send this information to the URLs registered for status updates (okm.subscribe_urls.status). All errors that happen here are logged and ignored.
  3. Reply to the OKM with a 200 and a message telling it to update its auditUrl to api/v1/audit.

Once the OKM receives this update, it pauses audit record transmission, updates itself with the new URL, then resumes sending audit records to the newly configured endpoint.

A 204 is returned if the processing of this request reaches the end of the steps. This can happen if there is no auditUrl parameter in the request, or there is no audit URL to send the OKM to.