Skip to content

Commit 96fbf62

Browse files
authored
Remove paid members from IAM manageable list (#182)
Also, fix a long standing IAM audit logging issue.
1 parent 64a35e7 commit 96fbf62

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/api/routes/iam.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
399399
entry: {
400400
module: Modules.IAM,
401401
actor: request.username!,
402-
target: request.body.add[i],
402+
target: request.body.remove[i],
403403
message: `remove target from group ID ${groupId}`,
404404
requestId: request.id,
405405
},
@@ -412,20 +412,20 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
412412
entry: {
413413
module: Modules.IAM,
414414
actor: request.username!,
415-
target: request.body.add[i],
415+
target: request.body.remove[i],
416416
message: `failed to remove target from group ID ${groupId}`,
417417
requestId: request.id,
418418
},
419419
}),
420420
);
421421
if (result.reason instanceof EntraGroupError) {
422422
response.failure.push({
423-
email: request.body.add[i],
423+
email: request.body.remove[i],
424424
message: result.reason.message,
425425
});
426426
} else {
427427
response.failure.push({
428-
email: request.body.add[i],
428+
email: request.body.remove[i],
429429
message: "An unknown error occurred.",
430430
});
431431
}
@@ -597,7 +597,11 @@ No action is required from you at this time.
597597
entraIdToken,
598598
fastify.environmentConfig.EntraServicePrincipalId,
599599
)
600-
).filter((x) => !genericConfig.ProtectedEntraIDGroups.includes(x.id));
600+
).filter(
601+
(x) =>
602+
!genericConfig.ProtectedEntraIDGroups.includes(x.id) &&
603+
x.id !== fastify.environmentConfig.PaidMemberGroupId,
604+
);
601605
request.log.debug(
602606
"Got manageable groups from Entra ID, setting to cache.",
603607
);

tests/live/iam.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "../../src/common/types/iam.js";
88
import { allAppRoles, AppRoles } from "../../src/common/roles.js";
99
import { getBaseEndpoint } from "./utils.js";
10-
import { genericConfig } from "../../src/common/config.js";
10+
import { environmentConfig, genericConfig } from "../../src/common/config.js";
1111

1212
const baseEndpoint = getBaseEndpoint();
1313
test("getting groups", async () => {
@@ -28,6 +28,9 @@ test("getting groups", async () => {
2828
expect(item["displayName"].length).greaterThan(0);
2929
expect(item["id"].length).greaterThan(0);
3030
expect(genericConfig.ProtectedEntraIDGroups).not.toContain(item["id"]);
31+
expect(genericConfig.ProtectedEntraIDGroups).not.toStrictEqual(
32+
environmentConfig["dev"].PaidMemberGroupId,
33+
);
3134
}
3235
});
3336

0 commit comments

Comments
 (0)