JWT Auth flow gồm hai phần chính: AuthService xác thực credentials và cấp token, JwtStrategy/Guard bảo vệ routes. Cài đặt @nestjs/jwt, @nestjs/passport, passport, passport-jwt, bcryptjs. Tạo AuthModule import JwtModule.registerAsync() với ConfigService để lấy JWT_SECRET và expiresIn.
AuthService có method login(): tìm user theo email, compare password với bcrypt.compare(), nếu đúng sign JWT với payload { sub: userId, email, role } và trả về access_token (ngắn hạn 15m) + refresh_token (dài hạn 7d).
JwtStrategy extends PassportStrategy(Strategy) với config jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken() và secretOrKey. Method validate(payload) attach user vào request. Guard JwtAuthGuard extends AuthGuard('jwt') từ Passport. @Public() decorator dùng SetMetadata để bỏ qua guard cho login/register endpoints.