@@ -61,6 +61,7 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
6161 region : genericConfig . AwsRegion ,
6262 credentials,
6363 } ) ,
64+ redisClient : fastify . redisClient ,
6465 } ;
6566 fastify . log . info (
6667 `Assumed Entra role ${ roleArns . Entra } to get the Entra token.` ,
@@ -73,6 +74,7 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
7374 return {
7475 smClient : fastify . secretsManagerClient ,
7576 dynamoClient : fastify . dynamoClient ,
77+ redisClient : fastify . redisClient ,
7678 } ;
7779 } ;
7880 fastify . withTypeProvider < FastifyZodOpenApiTypeProvider > ( ) . patch (
@@ -94,12 +96,13 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
9496 } ) ;
9597 }
9698 const userOid = request . tokenPayload . oid ;
97- const entraIdToken = await getEntraIdToken (
98- await getAuthorizedClients ( ) ,
99- fastify . environmentConfig . AadValidClientId ,
100- undefined ,
101- genericConfig . EntraSecretName ,
102- ) ;
99+ const entraIdToken = await getEntraIdToken ( {
100+ clients : await getAuthorizedClients ( ) ,
101+ clientId : fastify . environmentConfig . AadValidClientId ,
102+ secretName : genericConfig . EntraSecretName ,
103+ encryptionSecret : fastify . secretConfig . encryption_key ,
104+ logger : request . log ,
105+ } ) ;
103106 await patchUserProfile (
104107 entraIdToken ,
105108 request . username ,
@@ -213,10 +216,13 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
213216 } ,
214217 async ( request , reply ) => {
215218 const emails = request . body . emails ;
216- const entraIdToken = await getEntraIdToken (
217- await getAuthorizedClients ( ) ,
218- fastify . environmentConfig . AadValidClientId ,
219- ) ;
219+ const entraIdToken = await getEntraIdToken ( {
220+ clients : await getAuthorizedClients ( ) ,
221+ clientId : fastify . environmentConfig . AadValidClientId ,
222+ secretName : genericConfig . EntraSecretName ,
223+ encryptionSecret : fastify . secretConfig . encryption_key ,
224+ logger : request . log ,
225+ } ) ;
220226 if ( ! entraIdToken ) {
221227 throw new InternalServerError ( {
222228 message : "Could not get Entra ID token to perform task." ,
@@ -306,10 +312,13 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
306312 group : groupId ,
307313 } ) ;
308314 }
309- const entraIdToken = await getEntraIdToken (
310- await getAuthorizedClients ( ) ,
311- fastify . environmentConfig . AadValidClientId ,
312- ) ;
315+ const entraIdToken = await getEntraIdToken ( {
316+ clients : await getAuthorizedClients ( ) ,
317+ clientId : fastify . environmentConfig . AadValidClientId ,
318+ secretName : genericConfig . EntraSecretName ,
319+ encryptionSecret : fastify . secretConfig . encryption_key ,
320+ logger : request . log ,
321+ } ) ;
313322 const groupMetadataPromise = getGroupMetadata ( entraIdToken , groupId ) ;
314323 const addResults = await Promise . allSettled (
315324 request . body . add . map ( ( email ) =>
@@ -550,12 +559,13 @@ No action is required from you at this time.
550559 group : groupId ,
551560 } ) ;
552561 }
553- const entraIdToken = await getEntraIdToken (
554- await getAuthorizedClients ( ) ,
555- fastify . environmentConfig . AadValidReadOnlyClientId ,
556- undefined ,
557- genericConfig . EntraReadOnlySecretName ,
558- ) ;
562+ const entraIdToken = await getEntraIdToken ( {
563+ clients : await getAuthorizedClients ( ) ,
564+ clientId : fastify . environmentConfig . AadValidClientId ,
565+ secretName : genericConfig . EntraSecretName ,
566+ encryptionSecret : fastify . secretConfig . encryption_key ,
567+ logger : request . log ,
568+ } ) ;
559569 const response = await listGroupMembers ( entraIdToken , groupId ) ;
560570 reply . status ( 200 ) . send ( response ) ;
561571 } ,
@@ -572,16 +582,17 @@ No action is required from you at this time.
572582 onRequest : fastify . authorizeFromSchema ,
573583 } ,
574584 async ( request , reply ) => {
575- const entraIdToken = await getEntraIdToken (
576- await getAuthorizedClients ( ) ,
577- fastify . environmentConfig . AadValidClientId ,
578- undefined ,
579- genericConfig . EntraSecretName ,
580- ) ;
585+ const entraIdToken = await getEntraIdToken ( {
586+ clients : await getAuthorizedClients ( ) ,
587+ clientId : fastify . environmentConfig . AadValidClientId ,
588+ secretName : genericConfig . EntraSecretName ,
589+ encryptionSecret : fastify . secretConfig . encryption_key ,
590+ logger : request . log ,
591+ } ) ;
581592 const { redisClient } = fastify ;
582593 const key = `entra_manageable_groups_${ fastify . environmentConfig . EntraServicePrincipalId } ` ;
583594 const redisResponse = await getKey < { displayName : string ; id : string } [ ] > (
584- { redisClient, key } ,
595+ { redisClient, key, logger : request . log } ,
585596 ) ;
586597 if ( redisResponse ) {
587598 request . log . debug ( "Got manageable groups from Redis cache." ) ;
0 commit comments