Skip to main content
Version: Next

Builtin Lua functions

nauthilus_builtin.status_message_set​

Since 1.8.9

When multiple Lua environment/subject sources run in parallel and set a status message, Nauthilus uses the first non-empty message encountered during aggregation. Do not rely on ordering between scripts.

Sets a custom status message to be returned when a client request is rejected.

Syntax​

nauthilus_builtin.status_message_set(message)

Parameters​

  • message (string): The custom rejection message to display to the client

Returns​

None

Example​

nauthilus_builtin.status_message_set("Authentication failed: Too many login attempts")

nauthilus_builtin.custom_log_add​

Adds key-value pairs to the result log.

Syntax​

nauthilus_builtin.custom_log_add(key, value)

Parameters​

  • key (string): The name of the log field
  • value (string/number/boolean): The value to log (other types will be replaced with "UNSUPPORTED")

Returns​

None

Example​

nauthilus_builtin.custom_log_add("user_id", 12345)
nauthilus_builtin.custom_log_add("login_source", "mobile_app")
note

In environment sources, backend, and subject sources, logs are added to the final result log line. In actions, logging is appended to the action log line because actions may run asynchronously after the main request has closed.

You can call this function multiple times, even with the same key-value pairs. Logs cannot be removed once set.