Skip to content

route_auth_map: read NestJS controllers, guards and global guards - #2419

Closed
remigiusz-antczak wants to merge 2 commits into
mainfrom
fix/route-auth-nestjs
Closed

remigiusz-antczak wants to merge 2 commits into
mainfrom
fix/route-auth-nestjs

Conversation

@remigiusz-antczak

Copy link
Copy Markdown
Collaborator

Summary

route_auth_map.py now reads NestJS controllers. Before this change, a NestJS service showed almost no routes, so unauthenticated mutating handlers in NestJS apps were invisible to the route-auth check.

  • @Controller('prefix' | { path }) plus @Get/@Post/@Put/@Patch/@Delete/@All/@Head/@Options('path' | ['a', 'b']) members become inventoried routes (METHOD /prefix/path). A constant path reads {?}.
  • @UseGuards(X) on the member or the class counts as auth evidence. A rate-limit guard (Throttler*, RateLimit*) does not, unless its name also says Auth, Jwt, Session, Role or Permission.
  • A @Public()-style decorator reads auth=public.
  • An unguarded mutating route reads auth=none (HIGH), as for the other frameworks. When the scanned tree wires a non-rate-limit APP_GUARD or useGlobalGuards(), it reads "global guard, unverified" (INFO) instead.

Tests

  • New scripts/test_route_auth_nestjs.py: 14/14. It uses fictional fixtures with clean twins for a controller guard, a global auth guard versus a throttler-only global guard, and @Public under a global guard.
  • scripts/ci-tests.d/route-auth-map.sh: green.
  • On a read-only NestJS monorepo clone, the --all inventory went from 2 to 560 routes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B4dfwdDQiF3RQMUqYBqefc

remigiusz-antczak and others added 2 commits November 18, 2026 07:57
…Guards, global guard)

A class @controller('prefix' | { path }) with @Get/@Post/@Put/@Patch/@Delete/@All/@Head/
@options('path' | ['a', 'b']) members is an inventoried route (METHOD /prefix/path); a
constant path reads {?}. @UseGuards(X) on the member or the class is the auth evidence;
a rate-limit guard (Throttler*, RateLimit*) is not, unless its name also says Auth, Jwt,
Session, Role or Permission. A @public()-style decorator reads auth=public. An unguarded
mutating route reads auth=none (HIGH) like the other frameworks; when the scanned tree
wires a non-rate-limit APP_GUARD (provider object read in either key order) or
useGlobalGuards(), it reads "global guard, unverified" (INFO) instead. The class-guard
window stops at the previous class.

New per-feature test scripts/test_route_auth_nestjs.py with fictional fixtures and clean
twins, registered in scripts/ci-tests.d/route-auth-map.sh. On a read-only NestJS monorepo
clone the --all inventory went from 2 to 560 routes.

Tests: 14/14 (test_route_auth_nestjs), route-auth-map.sh green

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B4dfwdDQiF3RQMUqYBqefc
Widen the stale MUTANTS rows so each old text occurs exactly once in the script: the brace-walk decrement, the RCV new-prefix group, the analyze call that now passes glob, and the HIGH rule that now exempts HEAD and OPTIONS.

Tests: all route-auth-map suites pass

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B4dfwdDQiF3RQMUqYBqefc
@remigiusz-antczak

Copy link
Copy Markdown
Collaborator Author

Superseded by #2421 (same change, one squashed commit on current main).

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