Skip to content

Moost Integration

This section answers: how do I plug aoothjs into a Moost HTTP app, in what order, with which decorators, and which extension seams should I override? It covers two packages that together form the framework glue layer:

PackageConcern
@aooth/auth-moostAuthentication. authGuardInterceptor, useAuth(), AuthController, LoginWorkflow / RecoveryWorkflow / InviteWorkflow, magic-link outlets.
@aooth/arbac-moostAuthorization. arbacAuthorizeInterceptor, useArbac(), @ArbacResource / @ArbacAction / @ArbacAuthorize, AsArbacDbController, atscript-driven user provider.

The two packages share one decorator on purpose: @Public() writes both authPublic=true and arbacPublic=true, so a single annotation hides a route from both guards. Splitting the two into separate decorators was — in practice — a foot-gun.

Both guards are GUARD-priority interceptors

The auth guard and the ARBAC interceptor are both defineBeforeInterceptor at TInterceptorPriority.GUARD. The auth guard runs first (it has no dependencies on ARBAC state); the ARBAC interceptor calls useAuth().getUserId() indirectly through your ArbacUserProvider. Apply them in that order.

Where to start

If you want to…Read
Bootstrap a fresh app with both layers wiredSetup
Understand authGuardInterceptor token extraction, public-route handling, 401 mappingAuthGuard & useAuth
Understand arbacAuthorizeInterceptor resource/action resolution, scope plumbing, 403 mappingARBAC Authorize
Look up every decorator and composable in one placeDecorators
Wire up /auth/logout / /auth/refresh / /auth/status / /auth/triggerREST Controllers
Configure LoginWorkflow / RecoveryWorkflow / InviteWorkflow, subclass them, hook the email outletWorkflows
Add ARBAC scopes to your AsDbController-derived REST endpointsDB Controllers
Drive @arbac.* annotations from .as user modelsAtscript Models
Wire an audit sinkAudit Log
Look up AuthOptions and per-workflow tuning knobsConfig Reference

Mental model

HTTP request


authGuardInterceptor (GUARD)        ← reads bearer / cookie token, sets AuthContext or null


arbacAuthorizeInterceptor (GUARD)   ← resolves resource/action via @ArbacResource/@ArbacAction
   │                                   evaluates against ArbacUserProvider(roles, attrs)
   │                                   sets per-event scopes; 403 on deny

@Intercept / @Pipe (INTERCEPTOR / PIPE priorities)


Handler
   │  useAuth().getUserId()          ← throws 401 if no context
   │  useArbac().getScopes()         ← reads scopes set by the interceptor

Response

Workflow events (@moostjs/event-wf) inherit the originating HTTP event's AuthContext and option slot through Moost's parent chain. useAuth() and useArbac() traverse the parent chain so handler code inside a @Step can call them as if it were running inline. See Workflows for the details.

Released under the MIT License.