Skip to content

AuthModuleOptions

U extends AuthUser = AuthUser

readonly auth: NestAuth<U>

The createAuth(...) result.


readonly optional clientIpHeader?: string

A single-address header your edge sets, such as cf-connecting-ip. Needs trustedHops as a list naming the edge (or hops that accept traffic only from it); read only when the socket address is inside that list and the value is exactly one IP, otherwise X-Forwarded-For decides. Off by default.


readonly csrf: CsrfOptions


readonly optional roles?: (user) => readonly string[] | Promise<readonly string[]>

The user’s roles, for @RequireRole(). Called on every request that needs a role, with the user just loaded from the store, so a role change takes effect on the next request.

U

readonly string[] | Promise<readonly string[]>


readonly optional shutdownTimeout?: Duration

How long shutdown waits for background work (mail sends) before it gives up, logs what it left running and lets the app close. Default '10s'.


readonly optional touch?: boolean | ((request) => boolean)

Whether a request counts as activity for the session’s idle timeout. true (the default) refreshes the session’s last-active time, at most once per touchInterval, on every request. A predicate decides per request, before the session is validated: return false for traffic the page makes on its own (a poll on a timer, a status check), so an idle session still expires while only such requests arrive. false touches on no request. A passive request is still answered with its session, and the CSRF checks and the guard’s decisions do not change.


readonly trustedHops: TrustedHops

How many reverse proxies sit in front of the app, counted from the right of X-Forwarded-For (see trustedHopsFromEnv), 0 when none; or a list of proxy addresses, CIDR ranges and the presets loopback, linklocal and uniquelocal, trusted by the socket address.