Skip to content

Commit

Permalink
Merge pull request #420 from ubc-biztech/registrations-authorization
Browse files Browse the repository at this point in the history
Require admin authorization on registrations getAll
  • Loading branch information
voctory authored Jan 20, 2025
2 parents fb5ba20 + 979eeb6 commit 8095063
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions services/registrations/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,14 @@ export const get = async (event, ctx, callback) => {
);
}
} else if (queryString.eventID && queryString.year) {
const claims = event.requestContext.authorizer.claims;

if (!claims || !claims.email || !claims.email.endsWith("@ubcbiztech.com")) {
throw helpers.createResponse(403, {
message: "Unauthorized: Admin access required"
});
}

// Query by eventID;year using GSI
const eventIDYear = `${queryString.eventID};${queryString.year}`;
const keyCondition = {
Expand Down
4 changes: 4 additions & 0 deletions services/registrations/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ functions:
email: false
afterTimestamp: false
cors: true
authorizer:
name: ${self:service}-authorizer
type: COGNITO_USER_POOLS
arn: arn:aws:cognito-idp:us-west-2:432714361962:userpool/us-west-2_w0R176hhp
registrationDelete:
handler: handler.del
events:
Expand Down

0 comments on commit 8095063

Please sign in to comment.