* feat: restart cmd added in aio service * feat: nestjs config package added * test: fix all broken test case * feat: infra config module add with get-update-reset functionality * test: fix test case failure * feat: update infra configs mutation added * feat: utilise ConfigService in util functions * chore: remove saml stuff * feat: removed saml stuffs * fix: config service precedence * fix: mailer module init with right env value * feat: added mutations and query * feat: add query infra-configs * fix: mailer module init issue * chore: smtp url validation added * fix: all sso disabling is handled * fix: pnpm i without db connection * fix: allowedAuthProviders and enableAndDisableSSO * fix: validateSMTPUrl check * feat: get api added for fetch provider list * feat: feedback resolve * chore: update code comments * fix: uppercase issue of VITE_ALLOWED_AUTH_PROVIDERS * chore: update lockfile * fix: add validation checks for MAILER_ADDRESS_FROM * test: fix test case * chore: feedback resolve * chore: renamed an enum * chore: app shutdown way changed --------- Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { AuthService } from './auth.service';
|
|
import { AuthController } from './auth.controller';
|
|
import { UserModule } from 'src/user/user.module';
|
|
import { PrismaModule } from 'src/prisma/prisma.module';
|
|
import { PassportModule } from '@nestjs/passport';
|
|
import { JwtModule } from '@nestjs/jwt';
|
|
import { JwtStrategy } from './strategies/jwt.strategy';
|
|
import { RTJwtStrategy } from './strategies/rt-jwt.strategy';
|
|
import { GoogleStrategy } from './strategies/google.strategy';
|
|
import { GithubStrategy } from './strategies/github.strategy';
|
|
import { MicrosoftStrategy } from './strategies/microsoft.strategy';
|
|
import { AuthProvider, authProviderCheck } from './helper';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { loadInfraConfiguration } from 'src/infra-config/helper';
|
|
import { InfraConfigModule } from 'src/infra-config/infra-config.module';
|
|
|
|
@Module({
|
|
imports: [
|
|
PrismaModule,
|
|
UserModule,
|
|
PassportModule,
|
|
JwtModule.registerAsync({
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: async (configService: ConfigService) => ({
|
|
secret: configService.get('JWT_SECRET'),
|
|
}),
|
|
}),
|
|
InfraConfigModule,
|
|
],
|
|
providers: [AuthService, JwtStrategy, RTJwtStrategy],
|
|
controllers: [AuthController],
|
|
})
|
|
export class AuthModule {
|
|
static async register() {
|
|
const env = await loadInfraConfiguration();
|
|
const allowedAuthProviders = env.INFRA.VITE_ALLOWED_AUTH_PROVIDERS;
|
|
|
|
const providers = [
|
|
...(authProviderCheck(AuthProvider.GOOGLE, allowedAuthProviders)
|
|
? [GoogleStrategy]
|
|
: []),
|
|
...(authProviderCheck(AuthProvider.GITHUB, allowedAuthProviders)
|
|
? [GithubStrategy]
|
|
: []),
|
|
...(authProviderCheck(AuthProvider.MICROSOFT, allowedAuthProviders)
|
|
? [MicrosoftStrategy]
|
|
: []),
|
|
];
|
|
|
|
return {
|
|
module: AuthModule,
|
|
providers,
|
|
};
|
|
}
|
|
}
|