File size: 1,428 Bytes
f78b36a
 
 
 
 
 
 
 
d4f519e
f78b36a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d4f519e
f78b36a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { Module } from "@nestjs/common";
import { JwtModule } from "@nestjs/jwt";
import { PassportModule } from "@nestjs/passport";
import { ConfigModule, ConfigService } from "@nestjs/config";
import { AuthController } from "./auth.controller";
import { AuthService } from "./auth.service";
import { JwtStrategy } from "./strategies/jwt.strategy";
import { NotificationsModule } from "../notifications/notifications.module";
import { EmailModule } from "../email/email.module";

/**
 * Authentication Module
 *
 * RESPONSIBILITIES:
 * - User authentication (JWT-based)
 * - Minimal PII storage
 * - No health data in auth tables
 * - No credential logging
 *
 * FEATURES:
 * - Email OR phone login
 * - Password hashing with bcrypt
 * - JWT access tokens (short-lived)
 * - Refresh token rotation
 * - Secure authentication flow
 */

@Module({
  imports: [
    NotificationsModule,
    EmailModule,
    PassportModule.register({ defaultStrategy: "jwt" }),
    JwtModule.registerAsync({
      imports: [ConfigModule],
      useFactory: (configService: ConfigService) => ({
        secret: configService.get("JWT_SECRET"),
        signOptions: {
          expiresIn: configService.get("JWT_EXPIRATION"),
        },
      }),
      inject: [ConfigService],
    }),
  ],
  controllers: [AuthController],
  providers: [AuthService, JwtStrategy],
  exports: [AuthService, JwtStrategy, PassportModule],
})
export class AuthModule {}