Skip to content

WIP: add authz enforcement layer#48

Draft
burning-bush-dev wants to merge 1 commit intoNicTool:mainfrom
burning-bush-dev:feat/authz-enforcement
Draft

WIP: add authz enforcement layer#48
burning-bush-dev wants to merge 1 commit intoNicTool:mainfrom
burning-bush-dev:feat/authz-enforcement

Conversation

@burning-bush-dev
Copy link
Copy Markdown

This is 100% vibe coded by abe's claw (claude code). Every line. I haven't read most of it, just steered.

v3 didn't enforce permissions yet -- now it does. The approach is a Hapi onPreHandler plugin that reads app.permission metadata from route configs and runs the check before the handler fires. Keeps authz centralized instead of scattered across handlers, which is how v2's verify_obj_usage() worked conceptually.

The main pieces:

  • lib/authz.js, the engine -- group tree ownership checks, delegation access (including zone record pseudo-delegation via parent zone), per-resource permission checks. Mirrors v2's check_permission() flow.
  • lib/authz-plugin.js, the Hapi extension that wires it all together
  • routes/delegation.js, extracted and now caps delegation permissions by the caller's own permissions at write time
  • All routes annotated with what resource/action they need
  • Permission bounds enforcement on group and user create/edit (you can't grant permissions you don't have)

Test coverage: unit tests for the Authz class methods against real MySQL, plus integration tests via server.inject() hitting the full Hapi stack. v2 xt permission tests (14_permissions.t, 20_permission.t) should still pass -- 4892/4892 last run.

Known gaps -- 16_delegation.t still has 29 failures, and some pre-existing v3 route tests now fail because their fixture users don't have the right permissions for the objects they're testing (expected, those tests predate authz).

Abe

burning-bush-dev added a commit to burning-bush-dev/NicTool that referenced this pull request Apr 12, 2026
REST.pm gets error code mapping from v3's response body (error_code /
error_msg), delegation oid remapping, boolean coercion, permission
flattening in login responses, and delegation supplement handling.

xt tests adjusted to work with v3's centralized permission enforcement --
14_permissions.t and 20_permission.t both pass (4892/4892).

Companion to NicTool/api#48.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
burning-bush-dev added a commit to burning-bush-dev/validate that referenced this pull request Apr 12, 2026
Joi schemas for delegation CRUD (GET, POST, PUT, DELETE) and updated
index exports. Companion to NicTool/api#48.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v3 didn't have permission enforcement yet -- this adds it. Hapi
onPreHandler plugin reads route metadata and runs checks before handlers
execute, rather than scattering permission calls inside each one.

authz.js is the engine (checkPermission, group tree walks, delegation
lookups). authz-plugin.js wires it into Hapi's request lifecycle. All
routes annotated with what they need. Delegation routes now cap submitted
permissions by the caller's own permissions at write time, which matches
how v2 does it.

Unit tests for the Authz class and integration tests via server.inject()
included. v2 xt permission tests (14_permissions, 20_permission) should
still pass -- 4892/4892 last run.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant