For the complete documentation index, see llms.txt. This page is also available as Markdown.

Quickstart

Secure your first route in five minutes.

This takes you from install to a secured route with a passing test.

1. Install

install cbsecurity

This also installs cbauth (login state) and cbcsrf. See Installation for the supported engines.

2. Configure

Tell cbauth where your users live and tell the firewall where to send people who are not logged in:

// config/ColdBox.cfc
moduleSettings = {
    cbauth     : { userServiceClass : "models.UserService" },
    cbsecurity : {
        firewall : { invalidAuthenticationEvent : "security.login" }
    }
}

3. Provide Your Users

Your user service must implement isValidCredentials(), retrieveUserByUsername() and retrieveUserById() (cbsecurity.interfaces.IUserService). The user it returns must implement getId(), hasPermission() and hasRole() (IAuthUser). You can start from the bundled User object.

4. Secure a Route

With route middleware (ColdBox 8.2+), next to the route:

Or with an annotation on the handler, which works on any ColdBox version:

Prefer a central list? Use security rules instead. See Overview to choose.

5. Test It

Running middleware in get() and post() needs ColdBox 8.3+. Annotations and rules are tested the same way on any version.

Where Next

Last updated

Was this helpful?