This repository is a ColdBox module that provides a request firewall, annotation-driven security, JWT handling, CSRF integration, and security headers.
Keep guidance short and actionable. Prefer small, verifiable edits and reference the real files below.
- Big picture
- ColdBox module: entrypoint and wiring in
ModuleConfig.cfcandmodels/CBSecurity.cfc. - Runtime protection happens in the
cbsecurity.interceptors.Securityinterceptor (interceptors/Security.cfc) which:- loads and normalizes rules via
helpers/RulesLoader(seemodels/util/RulesLoader.cfc), - delegates validation to a Validator (default:
models/validators/AuthValidator.cfc) viaruleValidator()andannotationValidator(), - processes rule actions (redirect/override/block) and emits interception events (
cbSecurity_onInvalidAuthentication, etc.).
- loads and normalizes rules via
- Bundled sub-modules:
modules/cbauth/(authentication),modules/cbcsrf/(CSRF protection),modules/jwtcfml/(JWT library).
- Source layout at a glance
- Business logic & APIs:
models/—CBSecurity.cfc,jwt/JwtService.cfc,auth/(BasicAuth),delegates/(Auth, Authorizable, JwtSubject),validators/*(5 validators),util/(RulesLoader, DBLogger). - Request enforcement:
interceptors/Security.cfc(rule matching, IP/HTTP method validation, event overrides) andinterceptors/SecurityHeaders.cfc. - Handlers:
handlers/BasicAuth.cfc,handlers/Jwt.cfc,handlers/Visualizer.cfc. - Interfaces:
interfaces/IAuthService.cfc,IAuthUser.cfc,IModelRules.cfc,ISecurityValidator.cfc,IUserService.cfc,jwt/IJwtStorage.cfc,jwt/IJwtSubject.cfc. - Helpers:
helpers/mixins.cfm(mixin injections). - Config:
config/Router.cfc,config/security.json.cfm,config/security.xml.cfm,config/securityrules.sql. - Views:
views/home/(dashboard with tabs: activity, authentication, basicAuth, csrf, firewall, jwt, rules, security-headers). - Migrations:
migrations/2023_03_28_225839_create_security_logs_table.cfc. - Build/CI:
build/Build.cfc,build/release.boxr. - Module wiring:
ModuleConfig.cfcandbox.jsonfor dependencies and scripts.
- Developer workflows (how to run, test, build)
- Install deps and test harness:
box installat repo root, thencd test-harness && box install(or usebox installfrom root —box.jsonhasinstall:dependencies). - Run local server for integration/test harness:
box server start server-lucee@5.json(seebox.jsonscriptsstart:lucee/start:2023/start:2025/start:boxlang). - Run tests: this repo uses TestBox. The package
box.jsontest runner is configured tohttp://localhost:60299/tests/runner.cfmandbuild/Build.cfccallstestbox run. Start the server, then open that URL or runbox testbox run runner=http://localhost:60299/tests/runner.cfm. - Useful npm-like tasks are defined in
box.jsonunderscripts(e.g.box task run taskFile=build/Build.cfcused by CI). In VSCode use the TaskRun CommandBox Task. - Server configs available: Lucee 5, Lucee 6, Adobe 2023, Adobe 2025, BoxLang, BoxLang CFML.
- Patterns & conventions to follow
- Validators expose
ruleValidator(rule, controller)andannotationValidator(securedValue, controller). Return shape: { allow:boolean, type: "authentication"|"authorization", messages:[] }. - Rules normalized by
RulesLoaderand stored inproperties.firewall.rules.inline. Rule keys often used:securelist,whitelist,httpMethods,allowedIPs,action,redirect,overrideEvent. - When modifying or adding handlers, prefer ColdBox handler metadata (annotations) for security: see
test-harness/handlers/*andhandlers/Jwt.cfcfor examples. - JWT integration relies on
models/jwt/JwtService.cfc+models/jwt/storages/*(CacheTokenStorage, DBTokenStorage) andmodules/jwtcfml/dependency; preserve token storage API when changing. - WireBox IDs to preserve:
authenticationService@cbauth,CacheStorage@cbstorages,JwtService@cbsecurity.
- Events & integration points
- Interceptor announces:
cbSecurity_onInvalidAuthentication,cbSecurity_onInvalidAuthorization,cbSecurity_onFirewallBlockand many JWT lifecycle events (seeModuleConfig.cfcinterceptorSettings). - Modules can register rules in their
ModuleConfig.cfcand are merged into the global rules byinterceptors/Security.cfc(seeregisterModule()/postModuleLoad). - Module-level rules apps in
test-harness/modules_app/(api, mod1) demonstrate per-module security config.
- Tests & test-harness specifics
- Test harness lives in
test-harness/. It contains a minimal ColdBox app and TestBox specs. - Test specs:
test-harness/tests/specs/integration/(BasicAuthUserService, CBSecuritySpec, JWTSpec, SecuritySpec) andtest-harness/tests/specs/unit/(CBSecurityTest, SecurityTest). - Test resources:
test-harness/tests/resources/(Binder, security rules in CFC/JSON/XML formats). - Runner:
test-harness/tests/runner.cfmexpects a running CF server on port 60299. Start viabox server startusing one ofserver-*.jsonfiles. - Test harness handlers:
test-harness/handlers/admin.cfc,Annotations.cfc,jwt.cfc,Main.cfc,Public.cfc,PutPost.cfc.
- Small, high-value tasks for AI agents
- Add a focused unit test for a validator method in
test-harness/tests/specs/unit/. - When changing behavior in
Security.cfc, updatetest-harness/tests/specs/integration/*to cover rule matching and invalid action flows. - Preserve WireBox IDs and signatures when changing services (e.g.
authenticationService@cbauth,CacheStorage@cbstorages).
- Safety and CI
- CI uses the
build/Build.cfcandbox.jsonscripts. Do not modify CI scripts without updatingbox.jsonandbuild/Build.cfc. - GitHub Actions workflows in
.github/workflows/: cron, pr, release, snapshot, tests. .envfile for local environment overrides (see.env.example).
- AI agent skills (
.agents/skills/)
- 71 skill definitions are available in
.agents/skills/, sourced from ortus-boxlang/skills and coldbox/skills GitHub repos. - BoxLang (29): language fundamentals, OOP, async, caching, config, database, security, testing, web, CLI, CommandBox, miniserver, interceptors, modules, files, zip, scheduled tasks, cfml-migration, java-integration, docbox, code-documenter, code-reviewer, best-practices, functional-programming, templating, application-descriptor, file-watchers, ortus-coding-standards.
- ColdBox (32): handler/interceptor/layout/module development, routing, REST API, event model, DI (WireBox), cache, async, logging, config, CLI, proxy, decorators, flash messaging, request context, AI integration, app layouts, view rendering, scheduled tasks, reviewer, documenter, testing (base classes, handler, http-methods, integration, interceptor, model), database-migrations, wirebox-aop.
- TestBox (10): BDD, xUnit, assertions, expectations, mockbox, cbmockdata, runners, reporters, listeners, testing-coverage, testing-fixtures.
- Skills lock file:
skills-lock.jsontracks source hashes for all installed skills.
If anything above is unclear or missing (local server ports, preferred validator override patterns, or CI details), tell me which area to expand and I will iterate.