Lua Support
Nauthilus has Lua 5.1 support in all areas of the service. To understand the interfaces, you must first get an idea of what happens with an incoming authentication request.
Authentication workflow
An incoming authentication request first enters the brute_force check. After that it continues with the environment stage. After that has passed, it continues to process the request in a password backend. When the final result for the request was obtained, it passes subject sources.
Subject sources may change the backend result in one or the other way (accepting a formerly rejected message or vice versa). This is especially useful for other remote services that can influence the authentication process.
After all this has finished, it is possible to do some post actions, which are run independent of all other steps in the whole pipeline and therefore can not influence the final result anymore.
Policy-aware action semantics
Nauthilus distinguishes synchronous Lua actions from Lua POST-Actions.
Synchronous Lua actions are configured with action types such as brute_force, lua, tls_encryption, relay_domains, and rbl. In policy-authoritative paths, the selected policy decision dispatches them through the registered obligation auth.obligation.lua_action.dispatch and Nauthilus waits for the action before the request continues.
The triggering check, environment control, or environment source only emits facts. The action runs only when the selected decision includes the dispatch obligation. This keeps reports, observe-mode comparisons, and mutable side effects aligned with the same policy decision.
Lua POST-Actions use the post action type. They run after the request-time decision context is known and must not change the final decision, response marker, response message, or FSM terminal state. In top-level Policy authoritative paths, POST-Action enqueueing is requested through the registered obligation auth.obligation.lua_post_action.enqueue. Brute-force counter and learning updates are requested through auth.obligation.brute_force.update.
Observe-mode policy evaluation reports planned custom obligations but never executes them, so it does not dispatch synchronous Lua actions, enqueue custom POST-Actions, or mutate brute-force state.
In the following sequence diagram you can see the processing of the request in more detail.
Additional things to know
When starting the server, it is possible to call an init script, which may be used to register prometheus elements, start connection tracker or define custom redis pools. The latter is interesting, if you prefer using other redis servers for all your custom Lua scripts.
While runtime...
When an incoming authentication request is started, a Lua context is created.
All parts of a request share that common request context. Lua scripts can set arbitrary data in the context and read/delete things from there.
Lua scripts can modify the final log line by adding key-value pairs from each script.