@nestjs/passport#PassportModule TypeScript Examples
The following examples show how to use
@nestjs/passport#PassportModule.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: auth.module.ts From nestjs-rest-sample with GNU General Public License v3.0 | 7 votes |
@Module({
imports: [
ConfigModule.forFeature(jwtConfig),
UserModule,
PassportModule.register({ defaultStrategy: 'jwt' }),
JwtModule.registerAsync({
imports: [ConfigModule.forFeature(jwtConfig)],
useFactory: (config: ConfigType<typeof jwtConfig>) => {
return {
secret: config.secretKey,
signOptions: { expiresIn: config.expiresIn },
} as JwtModuleOptions;
},
inject: [jwtConfig.KEY],
}),
],
providers: [AuthService, LocalStrategy, JwtStrategy],
exports: [AuthService],
controllers: [AuthController],
})
export class AuthModule {}
Example #2
Source File: auth.module.ts From NestJs-youtube with MIT License | 6 votes |
@Module({
providers: [AuthService, LocalStrategy, JwtStrategy],
imports: [
UserModule,
PassportModule.register({ defaultStrategy: 'jwt' }),
JwtModule.register({
secret: jwtConstants.secret,
signOptions: { expiresIn: '1d' },
}),
],
exports: [AuthService],
})
export class AuthModule {}
Example #3
Source File: auth.module.ts From knests with MIT License | 6 votes |
@Module({
imports: [
UsersModule,
PassportModule,
JwtModule.register({
secret: jwtConstants.secret,
signOptions: { expiresIn: "60s" },
}),
],
providers: [AuthService, LocalStrategy, AuthResolver],
exports: [AuthService],
})
export class AuthModule {}
Example #4
Source File: auth.module.ts From pknote-backend with GNU General Public License v3.0 | 6 votes |
@Module({
imports: [
PassportModule.register({ defaultStrategy: 'jwt' }),
JwtModule.register({
secret: process.env.JWT_SECRET || jwtConfig.secret,
signOptions: {
expiresIn: jwtConfig.expiresIn,
},
}),
TypeOrmModule.forFeature([UserRepository]),
],
controllers: [AuthController],
providers: [AuthService, SmsService, JwtStragegy, RedisClientService],
exports: [JwtStragegy, PassportModule],
})
export class AuthModule {}
Example #5
Source File: auth.module.ts From nestjs-angular-starter with MIT License | 6 votes |
/**
* Responsible of authenticating the user requests using JWT authentication
* and Passport. It exposes the AuthService which allows managing user authentication,
* and the UserAuthGuard which allows authenticating each user request.
*/
@Module({
imports: [
PassportModule,
JwtModule.register({
secret: config.JWT.SECRET,
signOptions: config.JWT.OPTIONS,
}),
],
providers: [AuthService, JwtStrategy],
exports: [AuthService],
controllers: [AuthController],
})
export class AuthModule {}
Example #6
Source File: auth.module.ts From nestjs-starter with MIT License | 6 votes |
@Module({
imports: [
UsersModule,
PassportModule.registerAsync({
useFactory: async (configService: ConfigService) => configService.get<IAuthModuleOptions>(CONFIG_SERVER_PASSPORT),
inject: [ConfigService],
}),
JwtModule.registerAsync({
useFactory: async (configService: ConfigService) => configService.get(CONFIG_SERVER_JWT),
inject: [ConfigService],
}),
],
providers: [AuthService, LocalStrategy, JwtStrategy],
exports: [AuthService],
})
export class AuthModule {}
Example #7
Source File: AuthModule.ts From typescript-clean-architecture with MIT License | 6 votes |
@Module({
controllers: [
AuthController
],
imports: [
PassportModule,
JwtModule.register({
secret: ApiServerConfig.ACCESS_TOKEN_SECRET,
signOptions: {expiresIn: `${ApiServerConfig.ACCESS_TOKEN_TTL_IN_MINUTES}m`},
}),
UserModule,
],
providers: [
HttpAuthService,
HttpLocalStrategy,
HttpJwtStrategy
],
})
export class AuthModule {}
Example #8
Source File: index.ts From bank-server with MIT License | 6 votes |
@Module({
imports: [
forwardRef(() => UserModule),
PassportModule.register({ defaultStrategy: 'jwt' }),
],
controllers: [AuthController],
providers: [AuthService, JwtStrategy, JwtResetPasswordStrategy],
exports: [PassportModule.register({ defaultStrategy: 'jwt' }), AuthService],
})
export class AuthModule {}
Example #9
Source File: auth.module.ts From nestjs-starter-rest-api with MIT License | 6 votes |
@Module({
imports: [
SharedModule,
PassportModule.register({ defaultStrategy: STRATEGY_JWT_AUTH }),
JwtModule.registerAsync({
imports: [SharedModule],
useFactory: async (configService: ConfigService) => ({
publicKey: configService.get<string>('jwt.publicKey'),
privateKey: configService.get<string>('jwt.privateKey'),
signOptions: {
algorithm: 'RS256',
},
}),
inject: [ConfigService],
}),
UserModule,
],
controllers: [AuthController],
providers: [AuthService, LocalStrategy, JwtAuthStrategy, JwtRefreshStrategy],
})
export class AuthModule {}
Example #10
Source File: auth.module.ts From pandaid with MIT License | 6 votes |
@Module({
imports: [
UsersModule,
PassportModule,
JwtModule.register({
secret: 'secret',
signOptions: { expiresIn: '60m' }
})
],
controllers: [AuthController],
providers: [AuthService, LocalStrategy, JwtStrategy]
})
export class AuthModule {}
Example #11
Source File: auth.module.ts From svvs with MIT License | 6 votes |
/**
* Auth module contain logic of authentication
*/
@Module({
imports: [
UsersModule,
PassportModule.register({
defaultStrategy: 'jwt',
}),
JwtModule.register({
privateKey: environment.jwt.secret,
signOptions: {
expiresIn: environment.jwt.expiresIn,
},
}),
],
providers: [AuthService, PasswordService, JwtStrategy, AuthResolver],
exports: [AuthService, PassportModule],
})
export class AuthModule {
}
Example #12
Source File: auth.module.ts From 42_checkIn with GNU General Public License v3.0 | 6 votes |
@Module({
imports: [
HttpModule,
PassportModule,
JwtModule.registerAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
secret: configService.get('jwt.secret'),
signOptions: { expiresIn: '7d' },
}),
}),
LoggerModule,
],
providers: [AuthService, JwtStrategy, FtStrategy],
exports: [AuthService],
})
export class AuthModule {}
Example #13
Source File: auth.module.ts From nest-js-boilerplate with MIT License | 6 votes |
@Module({
imports: [
UsersModule,
PassportModule,
JwtModule.register({
secret: authConstants.jwt.secret,
}),
],
providers: [
AuthService,
LocalStrategy,
JwtAccessStrategy,
JwtRefreshStrategy,
AuthRepository,
],
controllers: [AuthController],
exports: [AuthService],
})
export default class AuthModule {}
Example #14
Source File: auth.module.ts From nest-js-boilerplate with MIT License | 6 votes |
@Module({
imports: [
UsersModule,
PassportModule.register({
defaultStrategy: 'local',
session: true,
}),
],
providers: [
AuthService,
GoogleStrategy,
GoogleAuthGuard,
GoogleDataSerializer,
],
controllers: [AuthController],
exports: [AuthService],
})
export default class AuthModule {}
Example #15
Source File: auth.module.ts From nest-js-boilerplate with MIT License | 6 votes |
@Module({
imports: [
UsersModule,
PassportModule.register({
defaultStrategy: 'local',
session: true,
}),
],
providers: [
AuthService,
LocalStrategy,
LocalSerializer,
LocalAuthGuard,
],
controllers: [AuthController],
exports: [AuthService],
})
export default class AuthModule {}
Example #16
Source File: auth.module.ts From nest-js-boilerplate with MIT License | 6 votes |
@Module({
imports: [
UsersModule,
PassportModule,
JwtModule.register({
secret: authConstants.jwt.secret,
}),
],
providers: [
AuthService,
LocalStrategy,
JwtAccessStrategy,
JwtRefreshStrategy,
AuthRepository,
JwtWSAccessStrategy,
],
controllers: [AuthController],
exports: [AuthService],
})
export default class AuthModule {}
Example #17
Source File: auth.module.ts From whispr with MIT License | 6 votes |
@Module({
imports: [
PassportModule,
ConfigModule,
JwtModule.register({
secret: 'some_secret_thing',
signOptions: { expiresIn: '60s' },
}),
],
providers: [JwtStrategy],
})
export class AuthModule {}
Example #18
Source File: user.service.spec.ts From barista with Apache License 2.0 | 6 votes |
describe('UserService', () => {
let service: UserService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [
PassportModule,
JwtModule.register({
secret: jwtConstants.secret,
signOptions: { expiresIn: '3600s' },
}),
],
providers: [
LocalStrategy,
JwtStrategy,
UserService,
LdapService,
{ provide: getRepositoryToken(User), useClass: mockRepository },
],
}).compile();
service = module.get<UserService>(UserService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
Example #19
Source File: auth.module.ts From uniauth-backend with MIT License | 6 votes |
@Module({
imports: [
UserModule,
PassportModule,
JwtModule.register({
secret: newJWTConstants.secret,
signOptions: { expiresIn: newJWTConstants.expiresIn },
}),
WinstonModule.forRoot(logger.console()),
],
controllers: [AuthController],
providers: [AuthService, LocalStrategy, JwtStrategy],
exports: [AuthService],
})
export class AuthModule {}
Example #20
Source File: services.module.ts From barista with Apache License 2.0 | 6 votes |
@Module({
imports: [
forwardRef(() => AppOrmModule),
AppQueueModule,
PassportModule,
CqrsModule,
JwtModule.register({
secret: jwtConstants.secret,
signOptions: { expiresIn: '28800s' },
}),
],
exports: services,
providers: [...services, ...CommandHandlers],
controllers: [],
})
export class ServicesModule {}
Example #21
Source File: auth.module.ts From nest-js-boilerplate with MIT License | 6 votes |
@Module({
imports: [
UsersModule,
PassportModule,
JwtModule.register({
secret: authConstants.jwt.secret,
}),
],
providers: [
AuthService,
LocalStrategy,
JwtAccessStrategy,
JwtRefreshStrategy,
JwtWSAccessStrategy,
AuthRepository,
],
controllers: [AuthController],
exports: [AuthService],
})
export default class AuthModule {}
Example #22
Source File: auth.module.ts From coronatest with GNU Affero General Public License v3.0 | 5 votes |
@Module({
imports: [PassportModule],
providers: [AuthService, APIKeyStrategy]
})
export class AuthModule {}
Example #23
Source File: auth.module.ts From MyAPI with MIT License | 5 votes |
passportModule = PassportModule.register({ defaultStrategy: 'jwt' })
Example #24
Source File: auth.module.ts From codeclannigeria-backend with MIT License | 5 votes |
Config = [
MongooseModule.forFeature([
{ name: TemporaryToken.modelName, schema: TemporaryToken.schema }
]),
PassportModule.register({ defaultStrategy: AUTH_GUARD_TYPE, session: true })
]
Example #25
Source File: auth.module.ts From aqualink-app with MIT License | 5 votes |
@Module({
imports: [PassportModule, TypeOrmModule.forFeature([User])],
providers: [FirebaseAuthStrategy],
})
export class AuthModule {}
Example #26
Source File: auth.module.ts From amplication with Apache License 2.0 | 5 votes |
@Module({
imports: [
ConfigModule,
PassportModule.register({ defaultStrategy: 'jwt' }),
JwtModule.registerAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
secret: configService.get('JWT_SECRET')
}),
inject: [ConfigService]
}),
AccountModule, // (AccountService, PasswordService)
PrismaModule, // (PrismaService)
PermissionsModule,
ExceptionFiltersModule,
WorkspaceModule,
UserModule,
GoogleSecretsManagerModule
],
providers: [
AuthService,
JwtStrategy,
{
provide: 'GitHubStrategy',
useFactory: async (
authService: AuthService,
configService: ConfigService,
googleSecretsManagerService: GoogleSecretsManagerService
) => {
const githubConfigService = new GitHubStrategyConfigService(
configService,
googleSecretsManagerService
);
const options = await githubConfigService.getOptions();
if (options === null) {
return;
}
return new GitHubStrategy(authService, options);
},
inject: [AuthService, ConfigService, GoogleSecretsManagerService]
},
GqlAuthGuard,
AuthResolver,
GitHubStrategyConfigService
],
controllers: [AuthController],
exports: [GqlAuthGuard, AuthService, AuthResolver]
})
export class AuthModule {}
Example #27
Source File: auth.module.ts From amplication with Apache License 2.0 | 5 votes |
@Module({
imports: [
forwardRef(() => UserModule),
PassportModule,
SecretsManagerModule,
JwtModule.registerAsync({
imports: [SecretsManagerModule],
inject: [SecretsManagerService, ConfigService],
useFactory: async (
secretsService: SecretsManagerService,
configService: ConfigService
) => {
const secret = await secretsService.getSecret<string>(JWT_SECRET_KEY);
const expiresIn = configService.get(JWT_EXPIRATION);
if (!secret) {
throw new Error("Didn't get a valid jwt secret");
}
if (!expiresIn) {
throw new Error("Jwt expire in value is not valid");
}
return {
secret: secret,
signOptions: { expiresIn },
};
},
}),
],
providers: [
AuthService,
BasicStrategy,
PasswordService,
AuthResolver,
JwtStrategy,
jwtSecretFactory,
TokenService,
],
controllers: [AuthController],
exports: [AuthService, PasswordService],
})
export class AuthModule {}
Example #28
Source File: auth.module.ts From nest-js-quiz-manager with MIT License | 5 votes |
@Module({
imports: [UserModule, PassportModule, JwtModule.registerAsync(jwtConfig)],
providers: [AuthService, LocalStrategy, JwtStrategy],
controllers: [AuthController],
})
export class AuthModule {}