@@ -86,20 +86,13 @@ const membershipPlugin: FastifyPluginAsync = async (fastify, _options) => {
86
86
"/" ,
87
87
{
88
88
schema : withTags ( [ "Membership" ] , {
89
- querystring : z . object ( {
90
- list : z . string ( ) . min ( 1 ) . optional ( ) . meta ( {
91
- description :
92
- "Membership list to check from (defaults to ACM Paid Member list)." ,
93
- } ) ,
94
- } ) ,
95
89
headers : z . object ( {
96
90
"x-uiuc-token" : z . jwt ( ) . min ( 1 ) . meta ( {
97
91
description :
98
92
"An access token for the user in the UIUC Entra ID tenant." ,
99
93
} ) ,
100
94
} ) ,
101
- summary :
102
- "Authenticated check ACM @ UIUC paid membership (or partner organization membership) status." ,
95
+ summary : "Check self ACM @ UIUC paid membership." ,
103
96
response : {
104
97
200 : {
105
98
description : "List membership status." ,
@@ -110,7 +103,6 @@ const membershipPlugin: FastifyPluginAsync = async (fastify, _options) => {
110
103
givenName : z . string ( ) . min ( 1 ) ,
111
104
surname : z . string ( ) . min ( 1 ) ,
112
105
netId : illinoisNetId ,
113
- list : z . optional ( z . string ( ) . min ( 1 ) ) ,
114
106
isPaidMember : z . boolean ( ) ,
115
107
} )
116
108
. meta ( {
@@ -143,7 +135,7 @@ const membershipPlugin: FastifyPluginAsync = async (fastify, _options) => {
143
135
message : "ID token could not be parsed." ,
144
136
} ) ;
145
137
}
146
- const list = request . query . list || "acmpaid" ;
138
+ const list = "acmpaid" ;
147
139
const cacheKey = `membership:${ netId } :${ list } ` ;
148
140
const result = await getKey < { isMember : boolean } > ( {
149
141
redisClient : fastify . redisClient ,
@@ -234,131 +226,6 @@ const membershipPlugin: FastifyPluginAsync = async (fastify, _options) => {
234
226
. send ( { givenName, surname, netId, isPaidMember : false } ) ;
235
227
} ,
236
228
) ;
237
- fastify . withTypeProvider < FastifyZodOpenApiTypeProvider > ( ) . get (
238
- "/:netId" ,
239
- {
240
- schema : withTags ( [ "Membership" ] , {
241
- params : z . object ( { netId : illinoisNetId } ) ,
242
- querystring : z . object ( {
243
- list : z . string ( ) . min ( 1 ) . optional ( ) . meta ( {
244
- description :
245
- "Membership list to check from (defaults to ACM Paid Member list)." ,
246
- } ) ,
247
- } ) ,
248
- summary :
249
- "Check ACM @ UIUC paid membership (or partner organization membership) status." ,
250
- response : {
251
- 200 : {
252
- description : "List membership status." ,
253
- content : {
254
- "application/json" : {
255
- schema : z
256
- . object ( {
257
- netId : illinoisNetId ,
258
- list : z . optional ( z . string ( ) . min ( 1 ) ) ,
259
- isPaidMember : z . boolean ( ) ,
260
- } )
261
- . meta ( {
262
- example : {
263
- netId : "rjjones" ,
264
- isPaidMember : false ,
265
- } ,
266
- } ) ,
267
- } ,
268
- } ,
269
- } ,
270
- } ,
271
- } ) ,
272
- } ,
273
- async ( request , reply ) => {
274
- const netId = request . params . netId . toLowerCase ( ) ;
275
- const list = request . query . list || "acmpaid" ;
276
- const cacheKey = `membership:${ netId } :${ list } ` ;
277
- const result = await getKey < { isMember : boolean } > ( {
278
- redisClient : fastify . redisClient ,
279
- key : cacheKey ,
280
- logger : request . log ,
281
- } ) ;
282
- if ( result ) {
283
- return reply . header ( "X-ACM-Data-Source" , "cache" ) . send ( {
284
- netId,
285
- list : list === "acmpaid" ? undefined : list ,
286
- isPaidMember : result . isMember ,
287
- } ) ;
288
- }
289
- if ( list !== "acmpaid" ) {
290
- const isMember = await checkExternalMembership (
291
- netId ,
292
- list ,
293
- fastify . dynamoClient ,
294
- ) ;
295
- await setKey ( {
296
- redisClient : fastify . redisClient ,
297
- key : cacheKey ,
298
- data : JSON . stringify ( { isMember } ) ,
299
- expiresIn : MEMBER_CACHE_SECONDS ,
300
- logger : request . log ,
301
- } ) ;
302
- return reply . header ( "X-ACM-Data-Source" , "dynamo" ) . send ( {
303
- netId,
304
- list,
305
- isPaidMember : isMember ,
306
- } ) ;
307
- }
308
- const isDynamoMember = await checkPaidMembershipFromTable (
309
- netId ,
310
- fastify . dynamoClient ,
311
- ) ;
312
- if ( isDynamoMember ) {
313
- await setKey ( {
314
- redisClient : fastify . redisClient ,
315
- key : cacheKey ,
316
- data : JSON . stringify ( { isMember : true } ) ,
317
- expiresIn : MEMBER_CACHE_SECONDS ,
318
- logger : request . log ,
319
- } ) ;
320
- return reply
321
- . header ( "X-ACM-Data-Source" , "dynamo" )
322
- . send ( { netId, isPaidMember : true } ) ;
323
- }
324
- const entraIdToken = await getEntraIdToken ( {
325
- clients : await getAuthorizedClients ( ) ,
326
- clientId : fastify . environmentConfig . AadValidClientId ,
327
- secretName : genericConfig . EntraSecretName ,
328
- logger : request . log ,
329
- } ) ;
330
- const paidMemberGroup = fastify . environmentConfig . PaidMemberGroupId ;
331
- const isAadMember = await checkPaidMembershipFromEntra (
332
- netId ,
333
- entraIdToken ,
334
- paidMemberGroup ,
335
- ) ;
336
- if ( isAadMember ) {
337
- await setKey ( {
338
- redisClient : fastify . redisClient ,
339
- key : cacheKey ,
340
- data : JSON . stringify ( { isMember : true } ) ,
341
- expiresIn : MEMBER_CACHE_SECONDS ,
342
- logger : request . log ,
343
- } ) ;
344
- reply
345
- . header ( "X-ACM-Data-Source" , "aad" )
346
- . send ( { netId, isPaidMember : true } ) ;
347
- await setPaidMembershipInTable ( netId , fastify . dynamoClient ) ;
348
- return ;
349
- }
350
- await setKey ( {
351
- redisClient : fastify . redisClient ,
352
- key : cacheKey ,
353
- data : JSON . stringify ( { isMember : false } ) ,
354
- expiresIn : MEMBER_CACHE_SECONDS ,
355
- logger : request . log ,
356
- } ) ;
357
- return reply
358
- . header ( "X-ACM-Data-Source" , "aad" )
359
- . send ( { netId, isPaidMember : false } ) ;
360
- } ,
361
- ) ;
362
229
fastify . withTypeProvider < FastifyZodOpenApiTypeProvider > ( ) . get (
363
230
"/externalList" ,
364
231
{
0 commit comments