Reference
Audit Logs Policy
Audit logging is an important part of API security that plays a critical role in detecting and correcting issues such as unauthorized access or permission elevations within your system. Audit logging is also a requirement for many compliance certifications as well as part of the buying criteria for larger enterprises.
Adding Audit Logging to your APIs that are secured with Zuplo is as easy as adding a policy. Typically you want to add audit logs to any API that modifies data, however depending on the API you may want it on read operations as well (i.e. retrieve a secret key, etc.)
Paid Add On
This policy is only available as a paid add-on. If you would like to try this please reach out to us: sales@zuplo.com
Configuration
The configuration shows how to configure the policy in the 'policies.json' document.
Policy Configuration
name
<string> - The name of your policy instance. This is used as a reference in your routes.policyType
<string> - The identifier of the policy. This is used by the Zuplo UI. Value should beaudit-log-inbound
.handler.export
<string> - The name of the exported type. Value should beAuditLogsInboundPolicy
.handler.module
<string> - The module containing the policy. Value should be$import(@zuplo/runtime)
.handler.options
<object> - The options for this policy. See Policy Options below.
Policy Options
The options for this policy are specified below. All properties are optional unless specifically marked as required.
logIpAddress
-if the IP address should be logged.Defaults totrue
.logUser
-if the user'sDefaults tosub
should be logged.true
.logGeolocation
-if the geolocation information should be logged (i.e. state, country, longitude, latitude, etc.).Defaults totrue
.logQueryParameters
-log the values of query parameters.Defaults totrue
.logRouteParameters
-The parameters in the route to log.Defaults totrue
.tenant
-if the route parameters should be logged (i.e. the value ofcustomerId
in the route/customers/:customerId
).metadata
-A function to add additional data to the audit logs.
Using the Policy
Adding Custom Metadata#
You can add any additional data to the audit logs with a custom function.
Note
Custom metadata functions cannot be asynchronous. Due to the frequency of their calls, asynchronous functions will add significant latency to your API.
Log Data#
The structure of an audit log is shown below.
Audit Logs in the Portal#
Audit logs are not currently surfaced in the Zuplo portal, but the feature is planned soon.
Audit Log API#
Audit logs can be retrieved using the Zuplo Management API. Logs can be
retrieved by time span and can be filtered by tenant
.
Read more about how policies work