Skip to main content

Configuration

This is a membership management system based on a NestJS module. You can use this module to build a comprehensive membership system that meets ISO 27001 audit requirements. The module will automatically record various foundational elements, including hashed password history, audit logs, and password validation rules.

The module also includes a complete Casbin permission management model, allowing you to freely switch between common permission models such as RBAC, Domain with RBAC, and ABAC to tailor the system to your needs.

First, you need to configure it using forRoot in your root module. If you need to pre-load other modules, forRootAsync might be your choice.

src/app.module.ts
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { MemberBaseModule } from '@rytass/member-base-nestjs-module';

@Module({
imports: [
TypeOrmModule.forRoot({
type: 'postgres',
host: 'localhost',
username: 'cms',
password: 'password',
database: 'cms',
schema: 'cms',
synchronize: true,
autoLoadEntities: true,
uuidExtension: 'uuid-ossp',
}),
CMSBaseModule.forRoot(),
],
})
export class AppModule {}

References

Methods

forRoot()

static forRoot(options?: CMSBaseModuleOptionsDto);

Parameters:

NameTypeDefaultDescription
loginFailedBanThresholdnumber5Number of allowed password attempts
resetPasswordTokenExpirationnumber3600Seconds of reset password token expiration
resetPasswordTokenSecretstringReset password token secret, will generate automatically
cookieModebooleanUse cookie [token] to replace header authorization token
accessTokenSecretstringAccess token secret, will generate automatically
accessTokenExpirationnumber900Seconds of access token expiration
refreshTokenSecretstringRefresh token secret, will generate automatically
refreshTokenExpirationnumber900Seconds of refresh token expiration
onlyResetRefreshTokenExpirationByPasswordbooleanfalseRefresh token expiration only reassign by password request
enableGlobalGuardbooleantrueEnable Casbin globally
casbinAdapterOptionsTypeORMAdapterOptionsTypeORM configuration for casbin policies storage
casbinModelStringstringRBAC w/ DomainCasbin modal string
memberEntityTypeORM EntityundefinedCustom BaseMemberEntity
passwordShouldIncludeUppercasebooleantruePassword Policy: Uppercase
passwordShouldIncludeLowercasebooleantruePassword Policy: Lowercase
passwordShouldIncludeDigitbooleantruePassword Policy: Digit
passwordShouldIncludeSpecialCharactersbooleanfalsePassword Policy: Special Characters
passwordMinLengthnumber8Password Policy: Min Length
passwordPolicyRegExpRegExpPassword Policy: RegExp (Will overwrite above configure)
passwordHistoryLimitnumberPassword Policy: Password History Check (Not duplicate)
passwordAgeLimitInDaysnumberPassword Policy: Change reminder (When expired)
forceRejectLoginOnPasswordExpiredbooleanfalseIf true, reject login when password is expired
customizedJwtPayload(member) => PayloadCustomize jwt access token payload
oauth2ProvidersOAuth2Provider[]Configure OAuth2 login channel
oauth2ClientDestUrlstring/loginAfter oauth2 logged in, url redirect target in client

forRootAsync()

static forRootAsync(options: CMSBaseModuleAsyncOptionsDto);

Parameters:

NameTypeDefaultDescription
importsDynamicModule[][]Imported module before CMS module
useFactory(...args: any[]) => CMSBaseModuleOptionsDtoundefinedFactory method to generate async options
injectsany[][]Inject symbol for useFactory method
useClassType<CMSBaseModuleOptionFactory>undefinedOptions provider class
useExistingType<CMSBaseModuleOptionFactory>undefinedOptions provider class symbol