@@ -4,6 +4,7 @@ import { zodToJsonSchema } from "zod-to-json-schema";
44import {
55 addToTenant ,
66 getEntraIdToken ,
7+ listGroupMembers ,
78 modifyGroup ,
89} from "../functions/entraId.js" ;
910import {
@@ -188,7 +189,7 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
188189 Body : GroupModificationPatchRequest ;
189190 Querystring : { groupId : string } ;
190191 } > (
191- "/groupMembership /:groupId" ,
192+ "/groups /:groupId" ,
192193 {
193194 schema : {
194195 querystring : {
@@ -222,7 +223,7 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
222223 throw new EntraGroupError ( {
223224 code : 403 ,
224225 message :
225- "This group is protected and may not be modified by this service. You must log into Entra ID directly to modify this group." ,
226+ "This group is protected and cannot be modified by this service. You must log into Entra ID directly to modify this group." ,
226227 group : groupId ,
227228 } ) ;
228229 }
@@ -282,6 +283,47 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
282283 reply . status ( 202 ) . send ( response ) ;
283284 } ,
284285 ) ;
286+ fastify . get < {
287+ Querystring : { groupId : string } ;
288+ } > (
289+ "/groups/:groupId" ,
290+ {
291+ schema : {
292+ querystring : {
293+ type : "object" ,
294+ properties : {
295+ groupId : {
296+ type : "string" ,
297+ } ,
298+ } ,
299+ } ,
300+ } ,
301+ onRequest : async ( request , reply ) => {
302+ await fastify . authorize ( request , reply , [ AppRoles . IAM_ADMIN ] ) ;
303+ } ,
304+ } ,
305+ async ( request , reply ) => {
306+ const groupId = ( request . params as Record < string , string > ) . groupId ;
307+ if ( ! groupId || groupId === "" ) {
308+ throw new NotFoundError ( {
309+ endpointName : request . url ,
310+ } ) ;
311+ }
312+ if ( genericConfig . ProtectedEntraIDGroups . includes ( groupId ) ) {
313+ throw new EntraGroupError ( {
314+ code : 403 ,
315+ message :
316+ "This group is protected and cannot be read by this service. You must log into Entra ID directly to read this group." ,
317+ group : groupId ,
318+ } ) ;
319+ }
320+ const entraIdToken = await getEntraIdToken (
321+ fastify . environmentConfig . AadValidClientId ,
322+ ) ;
323+ const response = await listGroupMembers ( entraIdToken , groupId ) ;
324+ reply . status ( 200 ) . send ( response ) ;
325+ } ,
326+ ) ;
285327} ;
286328
287329export default iamRoutes ;
0 commit comments