Allow org owners to inspect any member's data scope via dual JWT; server blocks mutations and team page stays reachable for return. Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { APP_INTERCEPTOR } from '@nestjs/core';
|
|
import { JwtModule } from '@nestjs/jwt';
|
|
import { PassportModule } from '@nestjs/passport';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { MembershipsModule } from '../memberships/memberships.module';
|
|
import { BillingModule } from '../billing/billing.module';
|
|
import { AuthService } from './auth.service';
|
|
import { AuthController } from './auth.controller';
|
|
import { JwtStrategy } from './jwt.strategy';
|
|
import { RolesGuard } from './roles.guard';
|
|
import { ViewAsReadOnlyInterceptor } from './view-as-readonly.interceptor';
|
|
import { SmsService } from '../common/sms.service';
|
|
|
|
@Module({
|
|
imports: [
|
|
ConfigModule,
|
|
MembershipsModule,
|
|
BillingModule,
|
|
PassportModule.register({ defaultStrategy: 'jwt' }),
|
|
JwtModule.registerAsync({
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: (config: ConfigService) => ({
|
|
secret: config.get<string>('JWT_SECRET') ?? 'dev-secret',
|
|
signOptions: {
|
|
expiresIn: (config.get<string>('JWT_EXPIRES_IN') ?? '7d') as `${number}d`,
|
|
},
|
|
}),
|
|
}),
|
|
],
|
|
controllers: [AuthController],
|
|
providers: [
|
|
AuthService,
|
|
JwtStrategy,
|
|
RolesGuard,
|
|
SmsService,
|
|
{
|
|
provide: APP_INTERCEPTOR,
|
|
useClass: ViewAsReadOnlyInterceptor,
|
|
},
|
|
],
|
|
exports: [AuthService, RolesGuard, JwtModule],
|
|
})
|
|
export class AuthModule {}
|