From 15b1790b19746c866612e369ec4686f21abfc9bf Mon Sep 17 00:00:00 2001 From: bramjanssen Date: Fri, 26 Jan 2024 14:15:47 +0100 Subject: [PATCH] fix(#33): fixed client timeouts --- package.json | 1 + src/auth/bearer/bearer.strategy.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 757c763..d2b80d2 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "@types/express-session": "^1.17.5", "@types/jest": "27.0.2", "@types/node": "^16.0.0", + "@types/openid-client": "^3.7.0", "@types/supertest": "^2.0.11", "@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/parser": "^5.0.0", diff --git a/src/auth/bearer/bearer.strategy.ts b/src/auth/bearer/bearer.strategy.ts index 4236b3d..8da20b5 100644 --- a/src/auth/bearer/bearer.strategy.ts +++ b/src/auth/bearer/bearer.strategy.ts @@ -2,7 +2,7 @@ import { Injectable, Logger } from '@nestjs/common'; import { PassportStrategy } from '@nestjs/passport'; import { Strategy } from 'passport-http-bearer'; import { ConfigService } from '../../config/config/config.service'; -import { Client, IntrospectionResponse, Issuer } from 'openid-client'; +import { Client, custom, IntrospectionResponse, Issuer } from 'openid-client'; export const buildBearerClient = async (configService: ConfigService) => { const issuer = await Issuer.discover( @@ -12,6 +12,11 @@ export const buildBearerClient = async (configService: ConfigService) => { client_id: configService.get('auth.oidc.clientId'), client_secret: configService.get('auth.oidc.clientSecret'), }); + client[custom.http_options] = (options: any) => ({ + ...options, + timeout: 5000, + retry: 2, + }); return client; };