Skip to content

AuthModuleAsyncOptions

@noctcore/auth-nestjs: a NestJS module for @noctcore/auth.

  • AuthModule.forRoot / forRootAsync provide the createAuth result under AUTH, register SessionGuard globally (closed by default, @Public() to open a route) and run CsrfMiddleware before every route.
  • @CurrentUser(), @CurrentSession() and @AuthMeta() read what the guard resolved; @RequireRole() and @RequireFreshAuth() narrow a route.
  • SessionCookies writes a new or ended session with its CSRF token.
  • configureTrustProxy and trustedHopsFromEnv read TRUST_PROXY and refuse to start in production without it.
  • describeRoutes lists every route with its access rule, for a test.

Express is the supported platform, for HTTP controllers. GraphQL, WebSocket and microservice handlers are refused unless @Public().

  • Pick<ModuleMetadata, "imports">

U extends AuthUser = AuthUser

optional imports?: (Type<any> | ForwardReference<any> | DynamicModule | Promise<DynamicModule>)[]

Optional list of imported modules that export the providers which are required in this module.

Pick.imports


readonly optional inject?: readonly (InjectionToken | OptionalFactoryDependency)[]


readonly useFactory: (…args) => AuthModuleOptions<U> | Promise<AuthModuleOptions<U>>

…never[]

AuthModuleOptions<U> | Promise<AuthModuleOptions<U>>