AuthModule
@noctcore/auth-nestjs: a NestJS module for @noctcore/auth.
AuthModule.forRoot/forRootAsyncprovide thecreateAuthresult underAUTH, registerSessionGuardglobally (closed by default,@Public()to open a route) and runCsrfMiddlewarebefore every route.@CurrentUser(),@CurrentSession()and@AuthMeta()read what the guard resolved;@RequireRole()and@RequireFreshAuth()narrow a route.SessionCookieswrites a new or ended session with its CSRF token.configureTrustProxyandtrustedHopsFromEnvreadTRUST_PROXYand refuse to start in production without it.describeRouteslists 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().
Implements
Section titled “Implements”NestModuleOnModuleInitBeforeApplicationShutdown
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AuthModule(
discovery,reflector,options):AuthModule
Parameters
Section titled “Parameters”discovery
Section titled “discovery”DiscoveryService
reflector
Section titled “reflector”Reflector
options
Section titled “options”ResolvedOptions
Returns
Section titled “Returns”AuthModule
Methods
Section titled “Methods”beforeApplicationShutdown()
Section titled “beforeApplicationShutdown()”beforeApplicationShutdown():
Promise<void>
Refuses to boot on a route whose decorators contradict each other, such
as @Public() on a controller and @RequireRole() on one of its
handlers, instead of leaving it to the guard to pick one at request time.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”BeforeApplicationShutdown.beforeApplicationShutdown
configure()
Section titled “configure()”configure(
consumer):void
Parameters
Section titled “Parameters”consumer
Section titled “consumer”MiddlewareConsumer
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”NestModule.configure
forRoot()
Section titled “forRoot()”
staticforRoot<U>(options):DynamicModule
Type Parameters
Section titled “Type Parameters”U extends AuthUser
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”DynamicModule
forRootAsync()
Section titled “forRootAsync()”
staticforRootAsync<U>(options):DynamicModule
Type Parameters
Section titled “Type Parameters”U extends AuthUser
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”DynamicModule
onModuleInit()
Section titled “onModuleInit()”onModuleInit():
void
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”OnModuleInit.onModuleInit